nextload/Dockerfile
tobias b6357c5676
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is passing
Modify dockerfile
2024-06-26 11:20:50 +02:00

49 lines
1.0 KiB
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
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
COPY docker-entrypoint.sh /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["pnpm", "start:standalone"]