浏览代码

OSS .devcontainer with all the tools

Viktor Sokolov 2 月之前
父节点
当前提交
f5399de81c
共有 4 个文件被更改,包括 123 次插入1 次删除
  1. 61 0
      .devcontainer/oss/Dockerfile
  2. 28 0
      .devcontainer/oss/README.md
  3. 33 0
      .devcontainer/oss/devcontainer.json
  4. 1 1
      .gitignore

+ 61 - 0
.devcontainer/oss/Dockerfile

@@ -0,0 +1,61 @@
+# Git build stage
+FROM ghcr.io/imgproxy/imgproxy-base:latest AS build
+
+ARG LYCHEE_VERSION="0.19.1"
+ARG GIT_VERSION="2.49.1"
+
+# lsb-release and gnupg are needed for the LLVM repository
+# TCL and gettext are needed for git
+RUN apt-get install -y lsb-release tcl gettext autoconf libz-dev libcurl4-openssl-dev
+
+# Install updated git
+RUN curl -O https://www.kernel.org/pub/software/scm/git/git-${GIT_VERSION}.tar.gz && \
+  tar -zxf git-${GIT_VERSION}.tar.gz && \
+  cd git-${GIT_VERSION} && \
+  make configure && \
+  ./configure prefix=/usr/git && \
+  make all && \
+  make install && \
+  rm -rf git-${GIT_VERSION}
+
+# Get lychee binary
+RUN curl -L "https://github.com/lycheeverse/lychee/releases/download/lychee-v${LYCHEE_VERSION}/lychee-$(uname -m)-unknown-linux-gnu.tar.gz" | \
+  tar -zxf -
+
+
+# Development container
+FROM ghcr.io/imgproxy/imgproxy-base:latest
+
+ENV GOPATH=$HOME/go
+ENV PATH=$PATH:$GOROOT/bin:$GOPATH/bin
+
+# gnupg is requiered for clang-format
+RUN apt-get install -y gnupg lsb-release ssh
+
+# Install air
+RUN go install github.com/air-verse/air@latest
+
+# Install lefthook
+RUN go install github.com/evilmartians/lefthook@latest
+
+# Install golangci-lint
+RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.1.6
+
+# Copy git from the git build stage
+COPY --from=build /usr/git /usr
+
+# Add the LLVM GPG key
+RUN curl https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor -o /usr/share/keyrings/llvm.gpg
+
+# Add the LLVM 20 APT repo (replace jammy with your distro if needed)
+RUN echo "deb [signed-by=/usr/share/keyrings/llvm.gpg] https://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-20 main" \
+  | tee /etc/apt/sources.list.d/llvm.list
+
+# Install clang-format-20
+RUN apt-get -y update && apt-get -y install clang-format-20
+
+# Use clang-format-20 as the default clang-format
+RUN ln -sf /usr/bin/clang-format-20 /usr/local/bin/clang-format
+
+# Copy the lychee binary from the git build stage
+COPY --from=build /app/lychee /usr/bin

+ 28 - 0
.devcontainer/oss/README.md

@@ -0,0 +1,28 @@
+# .devcontainer setup for local development of `imgproxy`
+
+All `imgproxy` dependencies are included in the `imgproxy-base` container image. Using this image for development is recommended.
+
+If you want to develop locally without using Docker, please install: `vips`, `clang-format`,`lychee` and `lefthook`.
+
+On MacOS:
+
+```sh
+brew install vips clang-format lychee lefthook
+```
+
+Then, run:
+```sh
+lefthook install
+```
+
+# Start the devcontainer
+
+You can use [`air`](https://github.com/air-verse/air) for hot-reloading during development. Simply run: `air`.
+
+Port `8080` is forwared to the host.
+
+# Test images
+
+[test images repo](https://github.com/imgproxy/test-images.git) will be automatically cloned or pulled to `.devcontainer/images` folder before the container starts.
+
+[Try it](http://localhost:8080/insecure/rs:fit:300:200/plain/local:///kitten.jpg@png). -->

+ 33 - 0
.devcontainer/oss/devcontainer.json

@@ -0,0 +1,33 @@
+{
+    "build": {
+        "dockerfile": "Dockerfile"
+    },
+    "name": "imgproxy OSS",
+    "forwardPorts": [
+        8080
+    ],
+    "containerEnv": {
+        "IMGPROXY_LOCAL_FILESYSTEM_ROOT": "/images",
+        "IMGPROXY_ENABLE_VIDEO_THUMBNAILS": "true",
+        "IMGPROXY_MAX_ANIMATION_FRAMES": "999",
+        "IMGPROXY_VIPS_LEAK_CHECK": "true",
+        "IMGPROXY_LOG_MEM_STATS": "true",
+        "IMGPROXY_DEVELOPMENT_ERRORS_MODE": "true"
+    },
+    "mounts": [
+        {
+            "source": "${localWorkspaceFolder}/.devcontainer/images",
+            "target": "/images",
+            "type": "bind"
+        }
+    ],
+    "customizations": {
+        "vscode": {
+            "extensions": [
+                "golang.go"
+            ]
+        }
+    },
+    "initializeCommand": "[ -d \"${localWorkspaceFolder}/.devcontainer/images/.git\" ] && git -C \"${localWorkspaceFolder}/.devcontainer/images\" pull || git clone https://github.com/imgproxy/test-images.git \"${localWorkspaceFolder}/.devcontainer/images\"",
+    "postCreateCommand": "lefthook install"
+}

+ 1 - 1
.gitignore

@@ -8,5 +8,5 @@ tmp/
 docker-base
 docs/sitemap.txt
 .env
-.devcontainer/*
+.devcontainer/images
 k6/*.json