Files
website/Dockerfile
Steffen Illium 2d33c4242e
Some checks failed
Next.js App CI / docker (push) Failing after 59s
store path adjusted
2025-09-15 15:49:38 +02:00

50 lines
1.3 KiB
Docker

# Stage 1: Dependency Fetching
FROM node:20-alpine AS deps
WORKDIR /app
RUN npm i -g pnpm
COPY package.json pnpm-lock.yaml ./
RUN pnpm fetch
# Stage 2: Builder
FROM node:20-alpine AS builder
WORKDIR /app
RUN npm i -g pnpm
# Install system dependencies
RUN apk add --no-cache imagemagick ghostscript
# Copy the dependency manifests and then run install.
COPY --from=deps /root/AppData/Local/pnpm/store/v3 /root/AppData/Local/pnpm/store/v3
COPY --from=deps /root/.local/share/pnpm/store/v3 /root/.local/share/pnpm/store/v3
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile --offline
# Copy the rest
COPY . .
# --- Asset Generation Step ---
RUN chmod +x ./scripts/*.sh && ./scripts/first_page_image.sh
# Run the build.
RUN pnpm build
# Stage 3: Runner
FROM node:20-alpine AS runner
WORKDIR /app
# Create a non-root user for better security
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
USER nextjs
# Copy only the necessary production artifacts from the builder stage
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
EXPOSE 3000
ENV PORT=3000
# The standalone output creates a server.js file that is the entrypoint
CMD ["node", "server.js"]