From fbb1c570c431f728300a1721636e736caba51d00 Mon Sep 17 00:00:00 2001 From: Steffen Illium Date: Mon, 15 Sep 2025 00:02:39 +0200 Subject: [PATCH] revert main workflow adjust Dockerfiel and integrate build proccess --- .gitea/workflows/main.yaml | 41 +------------------------------------- Dockerfile | 12 +++++++++++ 2 files changed, 13 insertions(+), 40 deletions(-) diff --git a/.gitea/workflows/main.yaml b/.gitea/workflows/main.yaml index d15e6382..dcfe1e48 100644 --- a/.gitea/workflows/main.yaml +++ b/.gitea/workflows/main.yaml @@ -17,46 +17,7 @@ jobs: registry: ${{vars.LOCAL_REGISTRY}} username: ${{ VARS.USER }} password: ${{ secrets.TOKEN }} - - - name: Generate Static Image Assets - run: | - echo "--- Runner workspace is at: ${{ gitea.workspace }} ---" - echo "--- Listing files on runner before mounting: ---" - ls -laR ${{ gitea.workspace }} - - docker run --rm \ - -v "${{ gitea.workspace }}:/work" \ - -w "/work" \ - archlinux:latest \ - bash -c ' - set -e - echo "--- Verifying files mounted inside container: ---" - ls -laR - - echo "--- Installing dependencies ---" - pacman -Syu --noconfirm imagemagick libwebp ghostscript - - echo "--- Generating assets ---" - chmod +x ./scripts/*.sh - bash ./scripts/first_page_image.sh - bash ./scripts/generate_webp.sh - - echo "--- Asset generation complete. Verifying output files: ---" - ls -laR ./public/assets - ' - - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: '20.x' - cache: 'npm' - - - name: Install Node.js Dependencies - run: npm ci - - - name: Build Next.js App - run: npm run build - + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 diff --git a/Dockerfile b/Dockerfile index ee45b45e..b868326c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,29 @@ # Stage 1: Builder FROM node:20-alpine AS builder +# Install system dependencies for image manipulation (ImageMagick v7+) +RUN apk add --no-cache imagemagick webp ghostscript + # Enable pnpm RUN corepack enable WORKDIR /app # Copy dependency files and install dependencies +# This is cached separately from the source code COPY package.json pnpm-lock.yaml ./ RUN pnpm install --frozen-lockfile # Copy the rest of the application source code COPY . . +# --- Asset Generation Step --- +# Run scripts to generate static images BEFORE the Next.js build +# The build needs these assets to be present. +RUN chmod +x ./scripts/*.sh && \ + ./scripts/first_page_image.sh && \ + ./scripts/generate_webp.sh + # Run the build command RUN pnpm run build @@ -28,6 +39,7 @@ RUN adduser --system --uid 1001 nextjs USER nextjs # Copy the standalone output from the builder stage +# The './public' directory now contains the newly generated assets COPY --from=builder /app/public ./public COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static