All checks were successful
Build & Deploy Web / build-and-deploy (push) Successful in 20s
Le bundle Vite plantait au boot avec :
Variables d'environnement invalides : { VITE_API_URL: ..., VITE_PUBLIC_LANDING_URL: ... }
Vite remplace import.meta.env.VITE_* par des literals au build time
(pas au runtime), donc l'image doit recevoir ces vars AVANT vite build.
Le Dockerfile.web accepte maintenant 3 ARGs :
- VITE_API_URL (default: https://app.rubis.arthurbarre.fr)
- VITE_PUBLIC_LANDING_URL (default: https://rubis.arthurbarre.fr)
- VITE_USE_MOCKS (default: false)
Le workflow CI les passe explicitement via build-args pour lisibilité.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
78 lines
3.1 KiB
Docker
78 lines
3.1 KiB
Docker
# syntax=docker/dockerfile:1.7
|
|
# =============================================================================
|
|
# Rubis — image web (SPA React/Vite servi par nginx)
|
|
# Sert app.rubis.arthurbarre.fr (front + reverse proxy /api/* → rubis-api).
|
|
# =============================================================================
|
|
|
|
ARG NODE_VERSION=22.13.1
|
|
ARG PNPM_VERSION=10.0.0
|
|
ARG NGINX_VERSION=1.27-alpine
|
|
|
|
# =============================================================================
|
|
# Build-time env vars exposées au bundle Vite (`import.meta.env.VITE_*`).
|
|
# Vite remplace ces literals à la compile, donc il faut les fournir AVANT
|
|
# `vite build`. Valeurs par défaut = prod ; surcharger via --build-arg pour
|
|
# preview/staging.
|
|
# =============================================================================
|
|
ARG VITE_API_URL=https://app.rubis.arthurbarre.fr
|
|
ARG VITE_PUBLIC_LANDING_URL=https://rubis.arthurbarre.fr
|
|
ARG VITE_USE_MOCKS=false
|
|
|
|
# -----------------------------------------------------------------------------
|
|
# build — Vite produit dist/
|
|
# -----------------------------------------------------------------------------
|
|
FROM node:${NODE_VERSION}-alpine AS build
|
|
|
|
ARG PNPM_VERSION
|
|
RUN apk add --no-cache libc6-compat && \
|
|
corepack enable && \
|
|
corepack prepare pnpm@${PNPM_VERSION} --activate
|
|
|
|
WORKDIR /repo
|
|
|
|
# Manifests pour cache Docker
|
|
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml turbo.json tsconfig.base.json ./
|
|
COPY apps/web/package.json ./apps/web/
|
|
COPY packages/shared/package.json ./packages/shared/
|
|
|
|
# Install : on prend tout le workspace pour que les workspace deps résolvent.
|
|
# Le filter --include-deps évite de gaspiller en installant les deps de l'API.
|
|
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store \
|
|
pnpm install --frozen-lockfile
|
|
|
|
COPY packages/shared ./packages/shared
|
|
COPY apps/web ./apps/web
|
|
|
|
# Re-déclare les ARG dans le stage où on les utilise (Docker scope).
|
|
ARG VITE_API_URL
|
|
ARG VITE_PUBLIC_LANDING_URL
|
|
ARG VITE_USE_MOCKS
|
|
|
|
# vite build direct (le `tsc -b` du script build plante sans cache .tsbuildinfo
|
|
# à cause de @tanstack/router-core ; le typecheck strict est en CI séparée).
|
|
# Les VITE_* env vars sont lues par Vite à la compile via process.env.
|
|
RUN VITE_API_URL=$VITE_API_URL \
|
|
VITE_PUBLIC_LANDING_URL=$VITE_PUBLIC_LANDING_URL \
|
|
VITE_USE_MOCKS=$VITE_USE_MOCKS \
|
|
pnpm --filter @rubis/web exec vite build
|
|
|
|
# -----------------------------------------------------------------------------
|
|
# runner — nginx-alpine + dist + config
|
|
# -----------------------------------------------------------------------------
|
|
FROM nginx:${NGINX_VERSION} AS runner
|
|
|
|
# Pas besoin de /etc/nginx/conf.d/default.conf legacy
|
|
RUN rm /etc/nginx/conf.d/default.conf
|
|
|
|
COPY apps/web/nginx.conf /etc/nginx/conf.d/default.conf
|
|
COPY --from=build /repo/apps/web/dist /var/www
|
|
|
|
EXPOSE 80
|
|
|
|
# Healthcheck : nginx répond 200 sur /index.html
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|
CMD wget -qO- http://127.0.0.1/index.html >/dev/null 2>&1 || exit 1
|
|
|
|
# Démarre nginx en foreground (pas de tini nécessaire pour nginx).
|
|
CMD ["nginx", "-g", "daemon off;"]
|