From d5c8f2dc7d6ba7f76d734a6e6131497f99f0b30c Mon Sep 17 00:00:00 2001 From: ildyria Date: Sun, 24 Dec 2023 20:51:48 +0100 Subject: [PATCH 01/11] add vite compilation step --- Dockerfile | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index f550d12..00d00dc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM debian:bookworm-slim +FROM debian:bookworm-slim as base # Set version label LABEL maintainer="lycheeorg" @@ -45,6 +45,7 @@ RUN \ gifsicle \ webp \ cron \ + rsync \ composer \ unzip && \ addgroup --gid "$PGID" "$USER" && \ @@ -74,6 +75,53 @@ RUN \ apt-get clean -qy &&\ rm -rf /var/lib/apt/lists/* +# Multi-stage build: Build static assets +# This allows us to not include Node within the final container +FROM node:20 as node_modules_go_brrr + +RUN mkdir /app + +RUN mkdir -p /app +WORKDIR /app +COPY --from=base /var/www/html/Lychee /app + +# Use yarn or npm depending on what type of +# lock file we might find. Defaults to +# NPM if no lock file is found. +# Note: We run "production" for Mix and "build" for Vite +RUN if [ -f "vite.config.js" ]; then \ + ASSET_CMD="build"; \ + else \ + ASSET_CMD="production"; \ + fi; \ + if [ -f "yarn.lock" ]; then \ + yarn install --frozen-lockfile; \ + yarn $ASSET_CMD; \ + elif [ -f "pnpm-lock.yaml" ]; then \ + corepack enable && corepack prepare pnpm@latest-8 --activate; \ + pnpm install --frozen-lockfile; \ + pnpm run $ASSET_CMD; \ + elif [ -f "package-lock.json" ]; then \ + npm ci --no-audit; \ + npm run $ASSET_CMD; \ + else \ + npm install; \ + npm run $ASSET_CMD; \ + fi; + +# From our base container created above, we +# create our final image, adding in static +# assets that we generated above +FROM base + +# Packages like Laravel Nova may have added assets to the public directory +# or maybe some custom assets were added manually! Either way, we merge +# in the assets we generated above rather than overwrite them +COPY --from=node_modules_go_brrr /app/public /var/www/html/Lychee/public-npm +RUN rsync -ar /var/www/html/Lychee/public-npm/ /var/www/html/Lychee/public/ \ + && rm -rf /var/www/html/Lychee/public-npm \ + && chown -R www-data:www-data /var/www/html/Lychee/public + # Add custom Nginx configuration COPY default.conf /etc/nginx/nginx.conf From b923687970527369c8a47383df298af3f0bf591a Mon Sep 17 00:00:00 2001 From: ildyria Date: Sun, 24 Dec 2023 21:03:02 +0100 Subject: [PATCH 02/11] lower version of node --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 00d00dc..94c428f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -77,7 +77,7 @@ RUN \ # Multi-stage build: Build static assets # This allows us to not include Node within the final container -FROM node:20 as node_modules_go_brrr +FROM node:18 as node_modules_go_brrr RUN mkdir /app From e7aae9094b03b5dfa1a171cb38f5678babc17c98 Mon Sep 17 00:00:00 2001 From: ildyria Date: Sun, 24 Dec 2023 21:05:18 +0100 Subject: [PATCH 03/11] more details? --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 94c428f..0bd6289 100644 --- a/Dockerfile +++ b/Dockerfile @@ -77,7 +77,7 @@ RUN \ # Multi-stage build: Build static assets # This allows us to not include Node within the final container -FROM node:18 as node_modules_go_brrr +FROM node:20-bookworm-slim as node_modules_go_brrr RUN mkdir /app From edc2f8408f69b664d9296bb62873aca7bff1493f Mon Sep 17 00:00:00 2001 From: ildyria Date: Sun, 24 Dec 2023 21:06:59 +0100 Subject: [PATCH 04/11] try without armv6 --- .github/workflows/cron.yml | 3 ++- Dockerfile | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml index ecedc90..ebdd066 100644 --- a/.github/workflows/cron.yml +++ b/.github/workflows/cron.yml @@ -35,7 +35,8 @@ jobs: with: context: . file: ./Dockerfile - platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 + platforms: linux/amd64,linux/arm/v7,linux/arm64 + # platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 push: true tags: | lycheeorg/lychee:testing-${{ github.run_id }} diff --git a/Dockerfile b/Dockerfile index 0bd6289..8d41676 100644 --- a/Dockerfile +++ b/Dockerfile @@ -77,7 +77,7 @@ RUN \ # Multi-stage build: Build static assets # This allows us to not include Node within the final container -FROM node:20-bookworm-slim as node_modules_go_brrr +FROM node:20-bookworm as node_modules_go_brrr RUN mkdir /app From 3762c61583733ad8fe27153dab6fe955bd2d1693 Mon Sep 17 00:00:00 2001 From: ildyria Date: Sun, 24 Dec 2023 21:13:02 +0100 Subject: [PATCH 05/11] update action --- .github/workflows/cron.yml | 19 +++++++++---------- .github/workflows/pull.yml | 8 ++++---- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml index ebdd066..6c452ee 100644 --- a/.github/workflows/cron.yml +++ b/.github/workflows/cron.yml @@ -19,24 +19,23 @@ jobs: uses: actions/checkout@v3 - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Login to DockerHub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v5 with: context: . file: ./Dockerfile - platforms: linux/amd64,linux/arm/v7,linux/arm64 - # platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 + platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 push: true tags: | lycheeorg/lychee:testing-${{ github.run_id }} @@ -49,19 +48,19 @@ jobs: uses: actions/checkout@v3 - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Login to DockerHub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v5 with: context: . file: ./Dockerfile diff --git a/.github/workflows/pull.yml b/.github/workflows/pull.yml index 77c0110..6e927fe 100644 --- a/.github/workflows/pull.yml +++ b/.github/workflows/pull.yml @@ -19,13 +19,13 @@ jobs: uses: actions/checkout@v3 - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3.0.0 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3.0.0 - name: Test multiarch building - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v5.1.0 with: context: . file: ./Dockerfile @@ -36,7 +36,7 @@ jobs: lycheeorg/lychee:testing-${{ github.run_id }} - name: Save amd64 image to pass to testing - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v5.1.0 with: context: . file: ./Dockerfile From c6eadc943276330897a99d402904ef33dcdb4f5f Mon Sep 17 00:00:00 2001 From: ildyria Date: Sun, 24 Dec 2023 21:24:30 +0100 Subject: [PATCH 06/11] No armv6 for now --- .github/workflows/pull.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pull.yml b/.github/workflows/pull.yml index 6e927fe..34f9b70 100644 --- a/.github/workflows/pull.yml +++ b/.github/workflows/pull.yml @@ -29,7 +29,8 @@ jobs: with: context: . file: ./Dockerfile - platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 + platforms: linux/amd64,linux/arm/v7,linux/arm64 + # platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 load: false push: false tags: | From fdef51824efa385553e2c77b8b19cbbc182eb147 Mon Sep 17 00:00:00 2001 From: ildyria Date: Sun, 24 Dec 2023 21:40:27 +0100 Subject: [PATCH 07/11] use latest instead of 20? --- .github/workflows/cron.yml | 16 ++++++++-------- .github/workflows/pull.yml | 3 +-- .github/workflows/release.yml | 8 ++++---- Dockerfile | 2 +- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml index 6c452ee..a48f4c8 100644 --- a/.github/workflows/cron.yml +++ b/.github/workflows/cron.yml @@ -19,19 +19,19 @@ jobs: uses: actions/checkout@v3 - name: Set up QEMU - uses: docker/setup-qemu-action@v3 + uses: docker/setup-qemu-action@v3.0.0 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 + uses: docker/setup-buildx-action@v3.0.0 - name: Login to DockerHub - uses: docker/login-action@v3 + uses: docker/login-action@v3.0.0 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v5.1.0 with: context: . file: ./Dockerfile @@ -48,19 +48,19 @@ jobs: uses: actions/checkout@v3 - name: Set up QEMU - uses: docker/setup-qemu-action@v3 + uses: docker/setup-qemu-action@v3.0.0 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 + uses: docker/setup-buildx-action@v3.0.0 - name: Login to DockerHub - uses: docker/login-action@v3 + uses: docker/login-action@v3.0.0 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v5.1.0 with: context: . file: ./Dockerfile diff --git a/.github/workflows/pull.yml b/.github/workflows/pull.yml index 34f9b70..6e927fe 100644 --- a/.github/workflows/pull.yml +++ b/.github/workflows/pull.yml @@ -29,8 +29,7 @@ jobs: with: context: . file: ./Dockerfile - platforms: linux/amd64,linux/arm/v7,linux/arm64 - # platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 + platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 load: false push: false tags: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6070de0..6eccd87 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,19 +22,19 @@ jobs: uses: actions/checkout@v3 - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3.0.0 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3.0.0 - name: Login to DockerHub - uses: docker/login-action@v2 + uses: docker/login-action@v3.0.0 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v5.1.0 with: context: . file: ./Dockerfile diff --git a/Dockerfile b/Dockerfile index 8d41676..c67865c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -77,7 +77,7 @@ RUN \ # Multi-stage build: Build static assets # This allows us to not include Node within the final container -FROM node:20-bookworm as node_modules_go_brrr +FROM node:latest as node_modules_go_brrr RUN mkdir /app From 2b589ffd8d054e33a6ce6f31bb3deb790f305b24 Mon Sep 17 00:00:00 2001 From: ildyria Date: Sun, 24 Dec 2023 22:04:19 +0100 Subject: [PATCH 08/11] use alpine --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c67865c..51f0048 100644 --- a/Dockerfile +++ b/Dockerfile @@ -77,7 +77,7 @@ RUN \ # Multi-stage build: Build static assets # This allows us to not include Node within the final container -FROM node:latest as node_modules_go_brrr +FROM node:20-alpine as node_modules_go_brrr RUN mkdir /app From 704a41b480a27ccb9080833e9a600caa911d58a8 Mon Sep 17 00:00:00 2001 From: ildyria Date: Sun, 24 Dec 2023 23:28:14 +0100 Subject: [PATCH 09/11] bye bye armv6 --- .github/workflows/build_push.yml | 3 ++- .github/workflows/cron.yml | 6 ++++-- .github/workflows/pull.yml | 3 ++- .github/workflows/release.yml | 3 ++- Dockerfile | 24 ++++-------------------- 5 files changed, 14 insertions(+), 25 deletions(-) diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index 1d2c9de..be000cf 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -38,7 +38,8 @@ jobs: with: context: . file: ./Dockerfile - platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 + platforms: linux/amd64,linux/arm/v7,linux/arm64 + # platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 push: true tags: | lycheeorg/lychee:testing-${{ github.run_id }} diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml index a48f4c8..d47789f 100644 --- a/.github/workflows/cron.yml +++ b/.github/workflows/cron.yml @@ -35,7 +35,8 @@ jobs: with: context: . file: ./Dockerfile - platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 + platforms: linux/amd64,linux/arm/v7,linux/arm64 + # platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 push: true tags: | lycheeorg/lychee:testing-${{ github.run_id }} @@ -64,7 +65,8 @@ jobs: with: context: . file: ./Dockerfile - platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 + platforms: linux/amd64,linux/arm/v7,linux/arm64 + # platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 push: true build-args: | COMPOSER_NO_DEV=0 diff --git a/.github/workflows/pull.yml b/.github/workflows/pull.yml index 6e927fe..34f9b70 100644 --- a/.github/workflows/pull.yml +++ b/.github/workflows/pull.yml @@ -29,7 +29,8 @@ jobs: with: context: . file: ./Dockerfile - platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 + platforms: linux/amd64,linux/arm/v7,linux/arm64 + # platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 load: false push: false tags: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6eccd87..1ec1e9e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -38,7 +38,8 @@ jobs: with: context: . file: ./Dockerfile - platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 + platforms: linux/amd64,linux/arm/v7,linux/arm64 + # platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 push: true build-args: | TARGET=release diff --git a/Dockerfile b/Dockerfile index 51f0048..4a922a5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -77,7 +77,7 @@ RUN \ # Multi-stage build: Build static assets # This allows us to not include Node within the final container -FROM node:20-alpine as node_modules_go_brrr +FROM node:20 as node_modules_go_brrr RUN mkdir /app @@ -89,25 +89,9 @@ COPY --from=base /var/www/html/Lychee /app # lock file we might find. Defaults to # NPM if no lock file is found. # Note: We run "production" for Mix and "build" for Vite -RUN if [ -f "vite.config.js" ]; then \ - ASSET_CMD="build"; \ - else \ - ASSET_CMD="production"; \ - fi; \ - if [ -f "yarn.lock" ]; then \ - yarn install --frozen-lockfile; \ - yarn $ASSET_CMD; \ - elif [ -f "pnpm-lock.yaml" ]; then \ - corepack enable && corepack prepare pnpm@latest-8 --activate; \ - pnpm install --frozen-lockfile; \ - pnpm run $ASSET_CMD; \ - elif [ -f "package-lock.json" ]; then \ - npm ci --no-audit; \ - npm run $ASSET_CMD; \ - else \ - npm install; \ - npm run $ASSET_CMD; \ - fi; +RUN \ + npm ci --no-audit \ + npm run build # From our base container created above, we # create our final image, adding in static From 4f0cc4c9c70035d561eb988c2e08b416691c30d7 Mon Sep 17 00:00:00 2001 From: ildyria Date: Sun, 24 Dec 2023 23:48:13 +0100 Subject: [PATCH 10/11] remove useless comments --- Dockerfile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4a922a5..da47185 100644 --- a/Dockerfile +++ b/Dockerfile @@ -85,10 +85,6 @@ RUN mkdir -p /app WORKDIR /app COPY --from=base /var/www/html/Lychee /app -# Use yarn or npm depending on what type of -# lock file we might find. Defaults to -# NPM if no lock file is found. -# Note: We run "production" for Mix and "build" for Vite RUN \ npm ci --no-audit \ npm run build From 5fa3e63775ef82437eb277bd96f68b1a2cb86210 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Viguier?= Date: Sun, 24 Dec 2023 23:52:55 +0100 Subject: [PATCH 11/11] Update Dockerfile Co-authored-by: Martin Stone <1611702+d7415@users.noreply.github.com> --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index da47185..34ae422 100644 --- a/Dockerfile +++ b/Dockerfile @@ -97,7 +97,7 @@ FROM base # Packages like Laravel Nova may have added assets to the public directory # or maybe some custom assets were added manually! Either way, we merge # in the assets we generated above rather than overwrite them -COPY --from=node_modules_go_brrr /app/public /var/www/html/Lychee/public-npm +COPY --from=node_modules_go_brrr --chown=www-data:www-data /app/public /var/www/html/Lychee/public-npm RUN rsync -ar /var/www/html/Lychee/public-npm/ /var/www/html/Lychee/public/ \ && rm -rf /var/www/html/Lychee/public-npm \ && chown -R www-data:www-data /var/www/html/Lychee/public