42 lines
1.2 KiB
Docker
42 lines
1.2 KiB
Docker
# Image des services API Node. Un seul Dockerfile pour Cloud et CRM :
|
|
# APP_DIR choisit quelle application on construit, donc les deux deploiements
|
|
# ne peuvent pas diverger dans leur methode de construction.
|
|
FROM node:22-slim AS builder
|
|
|
|
ARG APP_DIR
|
|
|
|
WORKDIR /repo
|
|
|
|
COPY package.json package-lock.json tsconfig.json tsconfig.base.json ./
|
|
COPY frontend ./frontend
|
|
COPY backend ./backend
|
|
|
|
RUN npm ci --no-audit --no-fund --fetch-retries=5
|
|
RUN npm run build --workspace=backend/shared
|
|
RUN npm run build --workspace=${APP_DIR}
|
|
|
|
# On ne embarque pas les devDependencies dans l'image de production.
|
|
RUN npm prune --omit=dev && npm cache clean --force
|
|
|
|
FROM node:22-alpine AS export
|
|
|
|
ARG APP_DIR
|
|
|
|
ENV NODE_ENV=production
|
|
|
|
WORKDIR /repo
|
|
|
|
COPY --from=builder /repo/package.json ./package.json
|
|
COPY --from=builder /repo/package-lock.json ./package-lock.json
|
|
COPY --from=builder /repo/node_modules ./node_modules
|
|
# backend/shared est le paquet @cohaise/server : les liens de workspace
|
|
# de node_modules pointent dessus, il doit donc voyager avec l'application.
|
|
COPY --from=builder /repo/backend/shared ./backend/shared
|
|
COPY --from=builder /repo/${APP_DIR} ./${APP_DIR}
|
|
|
|
WORKDIR /repo/${APP_DIR}
|
|
|
|
EXPOSE 8080
|
|
|
|
CMD ["node", "dist/index.js"]
|