fix(deploy/web): injecter les VITE_* env vars au build (sinon bundle invalide)
All checks were successful
Build & Deploy Web / build-and-deploy (push) Successful in 20s
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>
This commit is contained in:
parent
985e817289
commit
27771ed538
@ -49,6 +49,12 @@ jobs:
|
||||
${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ github.sha }}
|
||||
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE }}:cache
|
||||
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE }}:cache,mode=max
|
||||
# Vars Vite injectées dans le bundle au build time. Pour staging,
|
||||
# créer un workflow séparé avec d'autres VITE_API_URL.
|
||||
build-args: |
|
||||
VITE_API_URL=https://app.rubis.arthurbarre.fr
|
||||
VITE_PUBLIC_LANDING_URL=https://rubis.arthurbarre.fr
|
||||
VITE_USE_MOCKS=false
|
||||
|
||||
- name: Install kubectl
|
||||
run: |
|
||||
|
||||
@ -8,6 +8,16 @@ 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/
|
||||
# -----------------------------------------------------------------------------
|
||||
@ -33,9 +43,18 @@ RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store \
|
||||
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).
|
||||
RUN pnpm --filter @rubis/web exec vite build
|
||||
# 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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user