nextload/Dockerfile

38 lines
802 B
Docker
Raw Normal View History

2024-06-05 20:25:53 +00:00
FROM node:lts as base
2024-06-05 20:41:46 +00:00
FROM node:20-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
2024-06-05 20:25:53 +00:00
WORKDIR /base
2024-06-05 20:33:56 +00:00
COPY package.json pnpm-lock.yaml ./
2024-06-05 20:41:46 +00:00
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile
2024-06-05 20:25:53 +00:00
COPY . .
FROM base AS dev
ENV NODE_ENV=development
EXPOSE 3001
CMD ["pnpm","dev"]
FROM base AS build
ENV NODE_ENV=production
WORKDIR /build
COPY --from=base /base .
2024-06-05 20:31:53 +00:00
RUN pnpm build
2024-06-05 20:25:53 +00:00
FROM build as prod
ENV NODE_ENV=production
WORKDIR /prod
COPY package*.json .
2024-06-05 20:31:53 +00:00
RUN pnpm install --production
2024-06-05 20:25:53 +00:00
COPY --from=build /build/tsconfig.json ./tsconfig.json
COPY --from=build /build/dist ./dist
COPY --from=build /build/build ./build
EXPOSE 3000
COPY docker-entrypoint.sh /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["pnpm", "serve"]