Files
website/Dockerfile
Steffen Illium 18d480a77e
Some checks are pending
Next.js App CI / docker (push) Waiting to run
Dockerfile adjustments
2025-09-15 15:19:29 +02:00

49 lines
1.2 KiB
Docker

# Stage 1: Builder
FROM node:20-alpine AS builder
# Install system dependencies for image manipulation (ImageMagick v7+)
RUN apk add --no-cache imagemagick libwebp libwebp-tools 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 ls -la .
RUN ls -la /scripts
RUN chmod +x ./scripts/*.sh && ./scripts/first_page_image.sh
# Run the build command
RUN pnpm build
# ---
# Stage 2: Runner
FROM node:20-alpine AS runner
# WORKDIR /app
# Create a non-root user for security
RUN addgroup --system --gid 1001 nodejs
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 /public ./public
COPY --from=builder --chown=nextjs:nodejs .next/standalone ./
COPY --from=builder --chown=nextjs:nodejs .next/static ./.next/static
EXPOSE 3000
ENV PORT=3000
# The standalone output creates a server.js file that is the entrypoint
CMD ["node", "server.js"]