All checks were successful
Next.js App CI / docker (push) Successful in 4m18s
45 lines
1.0 KiB
Docker
45 lines
1.0 KiB
Docker
# --- Stage 1: Base (Development) ---
|
|
FROM dhi.io/node:25-alpine3.23-dev AS base
|
|
ENV PNPM_HOME="/pnpm"
|
|
ENV PATH="$PNPM_HOME:$PATH"
|
|
|
|
# Enable corepack
|
|
RUN corepack enable
|
|
|
|
# --- Stage 2: Builder ---
|
|
FROM base AS builder
|
|
WORKDIR /app
|
|
|
|
# Install system dependencies
|
|
RUN apk add --no-cache imagemagick libwebp libwebp-tools ghostscript
|
|
|
|
COPY package.json pnpm-lock.yaml ./
|
|
RUN pnpm install --frozen-lockfile
|
|
|
|
COPY . .
|
|
|
|
# Run scripts
|
|
RUN chmod +x ./scripts/*.sh && ./scripts/first_page_image.sh
|
|
|
|
# Build the application
|
|
RUN pnpm build
|
|
|
|
# --- Stage 3: Runner (Production) ---
|
|
FROM dhi.io/node:25-alpine3.23 AS runner
|
|
WORKDIR /app
|
|
|
|
ENV NODE_ENV=production
|
|
ENV PORT=3000
|
|
|
|
# Copy standalone output with ownership set to the 'node' user
|
|
COPY --from=builder --chown=node:node /app/.next/standalone ./
|
|
COPY --from=builder --chown=node:node /app/public ./public
|
|
COPY --from=builder --chown=node:node /app/.next/static ./.next/static
|
|
|
|
# Switch to the non-root user provided by the base image
|
|
USER node
|
|
|
|
EXPOSE 3000
|
|
|
|
# Run
|
|
CMD ["node", "server.js"] |