41 lines
1.1 KiB
Docker
41 lines
1.1 KiB
Docker
FROM node:20-bookworm-slim AS deps
|
|
WORKDIR /app
|
|
COPY package.json package-lock.json* ./
|
|
RUN npm ci --omit=dev
|
|
|
|
FROM node:20-bookworm-slim AS build
|
|
WORKDIR /app
|
|
COPY package.json package-lock.json* ./
|
|
RUN npm ci
|
|
COPY tsconfig.json ./
|
|
COPY prisma ./prisma
|
|
COPY src ./src
|
|
RUN npx prisma generate
|
|
RUN npm run build
|
|
|
|
FROM node:20-bookworm-slim AS runner
|
|
WORKDIR /app
|
|
ENV NODE_ENV=production
|
|
|
|
# optional but nice (health check uses wget)
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends ca-certificates wget \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# 1) deps: prod node_modules
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
|
|
# 2) app build output
|
|
COPY --from=build /app/dist ./dist
|
|
COPY --from=build /app/prisma ./prisma
|
|
|
|
# 3) 🔑 copy the generated Prisma client/artifacts from build stage
|
|
COPY --from=build /app/node_modules/@prisma/client ./node_modules/@prisma/client
|
|
COPY --from=build /app/node_modules/.prisma ./node_modules/.prisma
|
|
|
|
COPY entrypoint.sh ./entrypoint.sh
|
|
RUN sed -i 's/\r$//' /app/entrypoint.sh && chmod +x /app/entrypoint.sh
|
|
|
|
EXPOSE 8080
|
|
CMD ["/app/entrypoint.sh"]
|