This commit is contained in:
parent
d92cf801d7
commit
177050fb28
35
Dockerfile
35
Dockerfile
@ -1,35 +1,38 @@
|
||||
FROM node:lts as base
|
||||
|
||||
# Set environment variables for pnpm
|
||||
ENV PNPM_HOME="/pnpm"
|
||||
ENV PATH="$PNPM_HOME:$PATH"
|
||||
RUN corepack enable
|
||||
|
||||
WORKDIR /base
|
||||
COPY package.json pnpm-lock.yaml ./
|
||||
RUN pnpm install --prod --frozen-lockfile
|
||||
RUN pnpm install --frozen-lockfile
|
||||
COPY . .
|
||||
|
||||
FROM base AS dev
|
||||
ENV NODE_ENV=development
|
||||
EXPOSE 3001
|
||||
CMD ["pnpm","dev"]
|
||||
|
||||
FROM base AS build
|
||||
# Build stage: build the Next.js application
|
||||
FROM base as build
|
||||
ENV NODE_ENV=production
|
||||
WORKDIR /build
|
||||
COPY --from=base /base .
|
||||
WORKDIR /base
|
||||
RUN pnpm build
|
||||
|
||||
FROM build as prod
|
||||
# Production stage: serve the application
|
||||
FROM node:lts as prod
|
||||
ENV NODE_ENV=production
|
||||
WORKDIR /prod
|
||||
COPY package*.json .
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files and install production dependencies
|
||||
COPY package.json pnpm-lock.yaml ./
|
||||
RUN pnpm install --production
|
||||
|
||||
COPY --from=build /build/tsconfig.json ./tsconfig.json
|
||||
COPY --from=build /build/dist ./dist
|
||||
COPY --from=build /build/build ./build
|
||||
# Copy build artifacts from the build stage
|
||||
COPY --from=build /base/.next ./.next
|
||||
COPY --from=build /base/public ./public
|
||||
COPY --from=build /base/next.config.js ./
|
||||
|
||||
EXPOSE 3000
|
||||
COPY docker-entrypoint.sh /docker-entrypoint.sh
|
||||
RUN chmod +x /docker-entrypoint.sh
|
||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||
CMD ["pnpm", "serve"]
|
||||
|
||||
CMD ["pnpm", "start"]
|
||||
|
Loading…
Reference in New Issue
Block a user