diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml new file mode 100644 index 0000000..c5cd123 --- /dev/null +++ b/.github/workflows/dev.yml @@ -0,0 +1,72 @@ +# This is the temporary workflow for building and pushing imgproxy-base images with v4-dev tag. +name: Build dev image + +on: + workflow_dispatch: + inputs: + tag: + description: "The tag to push the image with" + required: true + default: "v4-dev" + +concurrency: + group: build-v4-dev-${{ github.ref }} + cancel-in-progress: true + +env: + BASE_IMAGE_NAME: ghcr.io/imgproxy/imgproxy-base + +jobs: + build: + if: github.repository_owner == 'imgproxy' + strategy: + matrix: + build: + - arch: amd64 + dockerPlatform: linux/amd64 + image: linux-5.0 + - arch: arm64 + dockerPlatform: linux/arm64/v8 + image: arm-3.0 + runs-on: + - codebuild-imgproxy-${{ github.run_id }}-${{ github.run_attempt }} + - image:${{ matrix.build.image }} + permissions: + contents: read + packages: write + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + tags: ${{ env.BASE_IMAGE_NAME }}:${{ github.event.inputs.tag }}-${{ matrix.build.arch }} + platforms: ${{ matrix.build.dockerPlatform }} + provenance: false + push: true + + push_manifests: + needs: build + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Push manifests + run: | + docker buildx imagetools create -t ${{ env.BASE_IMAGE_NAME }}:${{ github.event.inputs.tag }} ${{ env.BASE_IMAGE_NAME }}:${{ github.event.inputs.tag }}-amd64 ${{ env.BASE_IMAGE_NAME }}:${{ github.event.inputs.tag }}-arm64 diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..1c0275f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "[dockerfile]": { + "editor.formatOnSave": false, + "editor.defaultFormatter": null + } +} diff --git a/Dockerfile b/Dockerfile index 697fed0..d556698 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,8 @@ -# Use Debian Bullseye as a base image to link against glibc 2.31. -FROM public.ecr.aws/debian/debian:bullseye-slim AS base +# Base image for building imgproxy and its dependencies. +ARG BASE_IMAGE=public.ecr.aws/ubuntu/ubuntu:22.04 + +# Use ubuntu 22.04 as a base image to link against glibc 2.35. +FROM ${BASE_IMAGE} AS base RUN apt-get update \ && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ @@ -27,7 +30,8 @@ FROM base AS deps COPY install-rust.sh ./ -RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ +RUN apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ autoconf \ autopoint \ automake \ @@ -61,24 +65,52 @@ RUN ./install-go.sh # ============================================================================== -FROM public.ecr.aws/debian/debian:bullseye-slim AS final +FROM ${BASE_IMAGE} AS final LABEL maintainer="Sergey Alexandrovich " RUN apt-get update \ && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ bash \ curl \ - git \ ca-certificates \ build-essential \ pkg-config \ libssl-dev \ - libstdc++-10-dev + libstdc++-10-dev \ + software-properties-common \ + gpg-agent \ + && apt-get clean \ + && truncate -s 0 /var/log/*log \ + && rm -rf /tmp/* \ + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +# Install LLVM 20 (for clang-format) and latest git (custom, newer versions) +RUN echo "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-20 main" > /etc/apt/sources.list.d/llvm20.list \ + && curl -sSL https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - + +RUN apt-add-repository ppa:git-core/ppa + +RUN apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + git \ + clang-format \ + && apt-get clean \ + && truncate -s 0 /var/log/*log \ + && rm -rf /tmp/* \ + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* WORKDIR /root COPY --from=golang /usr/local/go /usr/local/go -ENV PATH=$PATH:/usr/local/go/bin +ENV PATH=$PATH:/usr/local/go/bin:/root/go/bin + +RUN go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.5.0 \ + && go install github.com/evilmartians/lefthook@latest \ + && go install gotest.tools/gotestsum@latest \ + && go install github.com/air-verse/air@latest \ + && go clean -cache -modcache + +COPY --from=deps /root/deps/lychee/lychee /usr/local/bin/lychee COPY --from=deps /opt/imgproxy/lib /opt/imgproxy/lib COPY --from=deps /opt/imgproxy/include /opt/imgproxy/include @@ -87,5 +119,7 @@ COPY --from=deps /opt/imgproxy/bin /opt/imgproxy/bin COPY --from=deps /root/.bashrc /root/.bashrc ENV BASH_ENV=/root/.bashrc +ENV IMGPROXY_IN_BASE_CONTAINER=true + WORKDIR /app CMD ["bash"] diff --git a/download-deps.sh b/download-deps.sh index fa5473b..bb1ba15 100755 --- a/download-deps.sh +++ b/download-deps.sh @@ -229,3 +229,9 @@ mkdir $DEPS_SRC/vips cd $DEPS_SRC/vips curl -Ls https://github.com/libvips/libvips/releases/download/v$VIPS_VERSION/vips-$VIPS_VERSION.tar.xz \ | tar -xJC . --strip-components=1 + +print_download_stage lychee $LYCHEE_VERSION +mkdir $DEPS_SRC/lychee +cd $DEPS_SRC/lychee +curl -L "https://github.com/lycheeverse/lychee/releases/download/lychee-v${LYCHEE_VERSION}/lychee-$(uname -m)-unknown-linux-gnu.tar.gz" \ + | tar -xz diff --git a/versions.sh b/versions.sh index 13568a5..47d79a4 100644 --- a/versions.sh +++ b/versions.sh @@ -33,3 +33,6 @@ export FRIBIDI_VERSION=1.0.16 export PANGO_VERSION=1.57.0 export LIBRSVG_VERSION=2.61.1 export VIPS_VERSION=8.17.2 + +# dev depdendencies +export LYCHEE_VERSION=0.20.1