46 lines
1.5 KiB
Docker
46 lines
1.5 KiB
Docker
# Seiche — image de run (API Fastify + front Vite statique servis ensemble).
|
|
#
|
|
# Pas de stage de build séparé : le serveur s'exécute directement en TypeScript
|
|
# (tsx, pas de script de build — typecheck fait par CI/local), et le front est
|
|
# buildé par Vite puis servi par @fastify/static (SEICHE_PUBLIC_DIR).
|
|
#
|
|
# Base glibc (node:22-slim) volontairement : argon2 consomme des prébuilds glibc.
|
|
FROM node:22-slim
|
|
|
|
WORKDIR /app
|
|
RUN corepack enable
|
|
|
|
# Dépendances workspace (serveur + web), lockfile figé.
|
|
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml tsconfig.base.json ./
|
|
COPY server/package.json server/
|
|
COPY web/package.json web/
|
|
RUN pnpm install --frozen-lockfile
|
|
|
|
# Front : build de production (web/dist).
|
|
COPY web/ web/
|
|
RUN pnpm --filter seiche-web build
|
|
|
|
# Serveur : source TypeScript exécutée par tsx.
|
|
COPY server/ server/
|
|
|
|
ENV NODE_ENV=production \
|
|
SEICHE_HOST=0.0.0.0 \
|
|
SEICHE_PORT=8787 \
|
|
SEICHE_DATA_DIR=/data \
|
|
SEICHE_PUBLIC_DIR=/app/web/dist
|
|
|
|
RUN mkdir -p /data && chown node:node /data
|
|
|
|
EXPOSE 8787
|
|
VOLUME /data
|
|
|
|
USER node
|
|
|
|
# cwd = server/ pour que `node --import tsx` résolve tsx depuis server/node_modules
|
|
# (layout pnpm) et que dotenv retrouve .env comme en dev locale.
|
|
WORKDIR /app/server
|
|
CMD ["node", "--import", "tsx", "src/main.ts"]
|
|
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
|
|
CMD node -e "fetch('http://127.0.0.1:' + (process.env.SEICHE_PORT || '8787') + '/api/health').then((r) => process.exit(r.ok ? 0 : 1)).catch(() => process.exit(1))"
|