diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..060927e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +node_modules +.pnpm-store +.output +dist +.git +Dockerfile diff --git a/Dockerfile b/Dockerfile index 9694b1e..adf72d1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,19 @@ -# Stage de build -FROM node:20-alpine AS build - +# Stage 1: Build +FROM node:20 AS builder WORKDIR /app -RUN npm install -g pnpm -COPY package.json pnpm-lock.yaml* ./ -RUN pnpm install --frozen-lockfile +COPY package.json pnpm-lock.yaml ./ +RUN npm install -g pnpm && pnpm install --frozen-lockfile + COPY . . RUN pnpm build -# Stage production -FROM node:20-alpine - +# Stage 2: Runtime +FROM node:20-slim AS runner WORKDIR /app -COPY --from=build /app/.output .output -COPY --from=build /app/package.json ./ -COPY --from=build /app/node_modules ./node_modules +COPY --from=builder /app/.output ./.output +COPY package.json pnpm-lock.yaml ./ EXPOSE 3000 CMD ["node", ".output/server/index.mjs"]