47 lines
1004 B
Docker
47 lines
1004 B
Docker
# Build stage
|
|
FROM node:20-slim as base
|
|
|
|
WORKDIR /base
|
|
|
|
|
|
# Local Development
|
|
FROM base AS dev
|
|
ENTRYPOINT []
|
|
CMD ["pnpm", "dev:next"]
|
|
|
|
|
|
# Production: build
|
|
FROM base AS builder
|
|
ENV PNPM_HOME="/pnpm"
|
|
ENV PATH="$PNPM_HOME:$PATH"
|
|
RUN corepack enable
|
|
|
|
COPY package.json pnpm-lock.yaml ./
|
|
RUN pnpm install --frozen-lockfile
|
|
|
|
COPY . .
|
|
ENV NODE_ENV=production
|
|
RUN pnpm generate:types
|
|
RUN pnpm build
|
|
|
|
# Production: copy build artifacts
|
|
FROM node:20-slim as runner
|
|
WORKDIR /prod
|
|
|
|
ENV PNPM_HOME="/pnpm"
|
|
ENV PATH="$PNPM_HOME:$PATH"
|
|
RUN corepack enable
|
|
|
|
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 ./
|
|
|
|
# Production: serve the website
|
|
FROM runner as prod
|
|
EXPOSE 3000
|
|
COPY docker-entrypoint.sh /docker-entrypoint.sh
|
|
ENTRYPOINT ["/docker-entrypoint.sh"]
|
|
CMD ["pnpm", "start:standalone"]
|