Create dev script
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
tobias
2024-06-20 10:37:21 +02:00
parent 02556b6d62
commit de5e8ab560
3 changed files with 51 additions and 46 deletions

View File

@ -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"]