This commit is contained in:
36
Dockerfile
36
Dockerfile
@ -1,38 +1,44 @@
|
||||
# Build stage
|
||||
FROM node:20-slim as builder
|
||||
FROM node:20-slim as base
|
||||
|
||||
ENV PNPM_HOME="/pnpm"
|
||||
ENV PATH="$PNPM_HOME:$PATH"
|
||||
RUN corepack enable
|
||||
|
||||
|
||||
WORKDIR /builder
|
||||
WORKDIR /base
|
||||
COPY package.json pnpm-lock.yaml ./
|
||||
RUN pnpm install --frozen-lockfile
|
||||
|
||||
ENV NODE_ENV=production
|
||||
|
||||
COPY . .
|
||||
|
||||
|
||||
# Development
|
||||
FROM base AS dev
|
||||
ENTRYPOINT []
|
||||
CMD ["pnpm", "dev:next"]
|
||||
|
||||
|
||||
# Production
|
||||
FROM base AS builder
|
||||
ENV NODE_ENV=production
|
||||
RUN pnpm build
|
||||
|
||||
# Production stage: serve the application
|
||||
# Production: copy build artifacts
|
||||
FROM node:20-slim as runner
|
||||
WORKDIR /runner
|
||||
WORKDIR /prod
|
||||
|
||||
ENV PNPM_HOME="/pnpm"
|
||||
ENV PATH="$PNPM_HOME:$PATH"
|
||||
RUN corepack enable
|
||||
|
||||
## Copy build artifacts from the build stage
|
||||
COPY --from=builder /builder/package.json ./
|
||||
#COPY --from=builder /builder/node_modules ./node_modules
|
||||
COPY --from=builder /builder/.next/standalone ./.next/standalone/
|
||||
COPY --from=builder /builder/.next/static ./.next/standalone/.next/static
|
||||
COPY --from=builder /builder/public ./.next/standalone/public
|
||||
COPY --from=builder /builder/next.config.mjs ./
|
||||
COPY --from=builder /base/package.json ./
|
||||
COPY --from=builder /base/.next/standalone ./.next/standalone/
|
||||
COPY --from=builder /base/.next/static ./.next/standalone/.next/static
|
||||
COPY --from=builder /base/public ./.next/standalone/public
|
||||
COPY --from=builder /base/next.config.mjs ./
|
||||
|
||||
FROM runner as server
|
||||
# Production: serve the website
|
||||
FROM runner as prod
|
||||
EXPOSE 3000
|
||||
COPY docker-entrypoint.sh /docker-entrypoint.sh
|
||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||
|
Reference in New Issue
Block a user