nextload/Dockerfile
tobias 83ea63dde4
Some checks failed
continuous-integration/drone/push Build is failing
Copy entrypoint
2024-07-05 21:59:17 +02:00

51 lines
1.1 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 ./
COPY --from=builder /base/next.config.mjs ./
COPY --from=builder /base/docker-entrypoint.sh ./
# Production: serve the website
FROM runner as prod
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["pnpm start:standalone"]