Files
datacat/infra/Dockerfile.prod
z3n 921a6e652b feat: initial scaffold — MVP catalogue de données d'API
- Backend NestJS : CRUD api_entries + categories, upload YAML multi-fichiers,
  génération docs AsyncAPI (@asyncapi/cli@6.0.0) et OpenAPI (redocly)
- Fix: route wildcard GET /api/apis/:id/*path pour servir les assets statiques
  (CSS/JS) générés par AsyncAPI HTML template (contournement bug path-to-regexp v8)
- Frontend Angular 19 : pages catalog, browse, api-detail, doc-viewer, upload (DSFR)
- Seeder de données de démo (idempotent)
- Docker Compose dev + Dockerfiles + manifests K8s
- Documentation : README, architecture, référence API REST

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-05-22 08:42:54 +00:00

114 lines
4.1 KiB
Docker

# =============================================================================
# Dockerfile Multi-Target pour datacat
# Usage:
# docker build --target back -t datacat/back:latest .
# docker build --target front -t datacat/front:latest .
# =============================================================================
# -----------------------------------------------------------------------------
# Stage: base-node
# -----------------------------------------------------------------------------
FROM node:22-alpine AS base-node
RUN npm install -g pnpm@10.33.0
WORKDIR /app
# -----------------------------------------------------------------------------
# Stage: deps-back
# -----------------------------------------------------------------------------
FROM base-node AS deps-back
COPY pnpm-workspace.yaml ./
COPY package.json ./
COPY shared/package.json ./shared/
COPY back/package.json ./back/
RUN pnpm install --frozen-lockfile
# -----------------------------------------------------------------------------
# Stage: build-back
# -----------------------------------------------------------------------------
FROM deps-back AS build-back
COPY shared ./shared
COPY back ./back
WORKDIR /app/back
RUN pnpm run build
# -----------------------------------------------------------------------------
# Stage: deps-front
# -----------------------------------------------------------------------------
FROM base-node AS deps-front
COPY pnpm-workspace.yaml ./
COPY package.json ./
COPY shared/package.json ./shared/
COPY front-public/package.json ./front-public/
RUN pnpm install --frozen-lockfile
# -----------------------------------------------------------------------------
# Stage: build-front
# -----------------------------------------------------------------------------
FROM deps-front AS build-front
COPY shared ./shared
COPY front-public ./front-public
WORKDIR /app/front-public
ARG ANGULAR_API_URL=https://api.datacat.dev.chmod777.dev
ENV ANGULAR_API_URL=$ANGULAR_API_URL
RUN pnpm run build:prod
# =============================================================================
# IMAGES FINALES
# =============================================================================
# -----------------------------------------------------------------------------
# Target: back
# -----------------------------------------------------------------------------
FROM node:22-alpine AS back
# Install git (required by asyncapi html-template installer) and tools
RUN apk add --no-cache git
# Install AsyncAPI CLI and Redocly CLI for docs generation
RUN npm install -g pnpm@10.33.0 @asyncapi/cli@6.0.0 @redocly/cli
# Pre-cache the AsyncAPI html-template so generation works on first startup
RUN mkdir -p /tmp/asyncapi-warmup /tmp/asyncapi-warmup/out && \
printf 'asyncapi: "3.0.0"\ninfo:\n title: Warmup\n version: "1.0.0"\nchannels: {}\n' \
> /tmp/asyncapi-warmup/spec.yaml && \
asyncapi generate fromTemplate /tmp/asyncapi-warmup/spec.yaml @asyncapi/html-template \
--output /tmp/asyncapi-warmup/out --no-interactive --install --force-write 2>&1 || true && \
rm -rf /tmp/asyncapi-warmup
WORKDIR /app
COPY --from=build-back /app/node_modules ./node_modules
COPY --from=build-back /app/shared ./shared
COPY --from=build-back /app/back/dist ./back/dist
COPY --from=build-back /app/back/package.json ./back/
# Volume mount point for generated docs
RUN mkdir -p /app/docs-output
ENV NODE_ENV=production
ENV PORT=3000
ENV DOCS_OUTPUT_DIR=/app/docs-output
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/health || exit 1
WORKDIR /app/back
CMD ["node", "dist/main"]
# -----------------------------------------------------------------------------
# Target: front
# -----------------------------------------------------------------------------
FROM nginx:alpine AS front
COPY infra/nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build-front /app/front-public/dist/front-public/browser /usr/share/nginx/html
EXPOSE 80
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost/ || exit 1
CMD ["nginx", "-g", "daemon off;"]