CI : Deployment
This commit is contained in:
55
Dockerfile
Normal file
55
Dockerfile
Normal file
@@ -0,0 +1,55 @@
|
||||
# Image du plan de contrôle : API, passerelle agents et dashboard compilé.
|
||||
# Les agents ne sont PAS conteneurisés — ils tournent nativement sur les VM,
|
||||
# aux côtés d'OBS (voir deploy/install-agent.sh et deploy/install-agent.ps1).
|
||||
|
||||
# --- Étape 1 : compilation --------------------------------------------------
|
||||
FROM node:24-alpine AS builder
|
||||
WORKDIR /app
|
||||
|
||||
# Le manifeste d'abord : cette couche est réutilisée tant que les dépendances
|
||||
# ne bougent pas, même quand le code source change.
|
||||
COPY package.json package-lock.json ./
|
||||
COPY packages/shared/package.json ./packages/shared/
|
||||
COPY packages/server/package.json ./packages/server/
|
||||
COPY packages/agent/package.json ./packages/agent/
|
||||
COPY packages/web/package.json ./packages/web/
|
||||
RUN npm ci
|
||||
|
||||
COPY tsconfig.base.json ./
|
||||
COPY packages ./packages
|
||||
RUN npm run build
|
||||
|
||||
# --- Étape 2 : exécution ----------------------------------------------------
|
||||
FROM node:24-alpine AS runtime
|
||||
WORKDIR /app
|
||||
ENV NODE_ENV=production
|
||||
|
||||
# Installation propre sans dépendances de développement. Les manifestes de tous
|
||||
# les workspaces sont nécessaires : npm ci refuse un lockfile incomplet.
|
||||
COPY package.json package-lock.json ./
|
||||
COPY packages/shared/package.json ./packages/shared/
|
||||
COPY packages/server/package.json ./packages/server/
|
||||
COPY packages/agent/package.json ./packages/agent/
|
||||
COPY packages/web/package.json ./packages/web/
|
||||
RUN npm ci --omit=dev --ignore-scripts && npm cache clean --force
|
||||
|
||||
COPY --from=builder /app/packages/shared/dist ./packages/shared/dist
|
||||
COPY --from=builder /app/packages/server/dist ./packages/server/dist
|
||||
COPY --from=builder /app/packages/web/dist ./packages/web/dist
|
||||
|
||||
# La base SQLite vit ici ; à monter en volume pour survivre aux mises à jour.
|
||||
RUN mkdir -p /app/data && chown -R node:node /app/data
|
||||
VOLUME ["/app/data"]
|
||||
|
||||
USER node
|
||||
EXPOSE 8080
|
||||
|
||||
# Le port interne est fixe : c'est le compose qui décide de la publication.
|
||||
ENV PORT=8080 \
|
||||
HOST=0.0.0.0 \
|
||||
DB_PATH=./data/stream-control.sqlite
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
||||
CMD wget -qO- http://127.0.0.1:8080/healthz >/dev/null || exit 1
|
||||
|
||||
CMD ["node", "--disable-warning=ExperimentalWarning", "packages/server/dist/index.js"]
|
||||
Reference in New Issue
Block a user