correct config

This commit is contained in:
ordinarthur 2026-03-12 20:03:57 +01:00
parent 8a96286551
commit eeb9025210
3 changed files with 50 additions and 12 deletions

View File

@ -16,7 +16,7 @@ COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN pnpm prisma generate
EXPOSE 80
EXPOSE 3001
# Astro SSG needs the DB at build time → build happens at startup after Postgres is ready
# Build Astro (needs DB) then start Fastify API
CMD ["sh", "-c", "pnpm prisma migrate deploy && pnpm build && node server.mjs"]

View File

@ -1,25 +1,44 @@
services:
fastify:
server:
build:
context: .
dockerfile: Dockerfile
expose:
- '80'
- '3001'
environment:
- DATABASE_URL
- STRIPE_SECRET_KEY
- STRIPE_WEBHOOK_SECRET
- DOMAIN
- PORT=80
- PORT=3001
- ADMIN_EMAIL
- ADMIN_PASSWORD
- COOKIE_SECRET
- NODE_ENV=production
volumes:
- dist-data:/app/dist
networks:
- coolify
- default
restart: unless-stopped
client:
image: nginx:alpine
expose:
- '80'
volumes:
- dist-data:/usr/share/nginx/html:ro
- ./docker/nginx.conf:/etc/nginx/conf.d/default.conf:ro
depends_on:
- server
networks:
- coolify
- default
restart: unless-stopped
volumes:
dist-data:
networks:
coolify:
external: true

View File

@ -5,26 +5,45 @@ server {
root /usr/share/nginx/html;
index index.html;
# HTML : jamais caché
location ~* \.html$ {
add_header Cache-Control "no-store";
# ── API proxy Fastify ──────────────────────────────────────────────────
location /api/ {
proxy_pass http://server:3001;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# Fichiers Astro avec hash dans _astro/ : cache long immutable
location ~* ^/_astro/ {
# ── Admin proxy Fastify (AdminJS) ──────────────────────────────────────
location /admin {
proxy_pass http://server:3001;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# ── Cache : Astro hashed files immutable ───────────────────────────────
location /_astro/ {
add_header Cache-Control "public, max-age=31536000, immutable";
}
# CSS / JS sans hash (style.css, main.js) : revalidation
# ── Cache : CSS/JS sans hash revalidation ─────────────────────────────
location ~* \.(css|js)$ {
add_header Cache-Control "no-cache";
}
# Assets (images, fonts) : cache 7 jours
# ── Cache : assets (images, fonts) 7 jours ────────────────────────────
location ~* \.(jpg|jpeg|png|gif|webp|svg|woff2|woff|ttf|ico)$ {
add_header Cache-Control "public, max-age=604800";
}
# ── HTML : jamais caché ──────────────────────────────────────────────────
location ~* \.html$ {
add_header Cache-Control "no-store";
}
# ── SPA fallback pour les routes Astro ───────────────────────────────────
location / {
try_files $uri $uri/ $uri.html /index.html;
}