'Refine' dockerfile
Some checks failed
continuous-integration/drone Build is failing

This commit is contained in:
tobias 2024-06-06 08:05:16 +02:00
parent d92cf801d7
commit 177050fb28

View File

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