correct config
This commit is contained in:
parent
8a96286551
commit
eeb9025210
@ -16,7 +16,7 @@ COPY --from=deps /app/node_modules ./node_modules
|
|||||||
COPY . .
|
COPY . .
|
||||||
RUN pnpm prisma generate
|
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"]
|
CMD ["sh", "-c", "pnpm prisma migrate deploy && pnpm build && node server.mjs"]
|
||||||
|
|||||||
@ -1,25 +1,44 @@
|
|||||||
services:
|
services:
|
||||||
fastify:
|
server:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
expose:
|
expose:
|
||||||
- '80'
|
- '3001'
|
||||||
environment:
|
environment:
|
||||||
- DATABASE_URL
|
- DATABASE_URL
|
||||||
- STRIPE_SECRET_KEY
|
- STRIPE_SECRET_KEY
|
||||||
- STRIPE_WEBHOOK_SECRET
|
- STRIPE_WEBHOOK_SECRET
|
||||||
- DOMAIN
|
- DOMAIN
|
||||||
- PORT=80
|
- PORT=3001
|
||||||
- ADMIN_EMAIL
|
- ADMIN_EMAIL
|
||||||
- ADMIN_PASSWORD
|
- ADMIN_PASSWORD
|
||||||
- COOKIE_SECRET
|
- COOKIE_SECRET
|
||||||
- NODE_ENV=production
|
- NODE_ENV=production
|
||||||
|
volumes:
|
||||||
|
- dist-data:/app/dist
|
||||||
networks:
|
networks:
|
||||||
- coolify
|
- coolify
|
||||||
- default
|
- default
|
||||||
restart: unless-stopped
|
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:
|
networks:
|
||||||
coolify:
|
coolify:
|
||||||
external: true
|
external: true
|
||||||
|
|||||||
@ -5,26 +5,45 @@ server {
|
|||||||
root /usr/share/nginx/html;
|
root /usr/share/nginx/html;
|
||||||
index index.html;
|
index index.html;
|
||||||
|
|
||||||
# HTML : jamais caché
|
# ── API proxy → Fastify ──────────────────────────────────────────────────
|
||||||
location ~* \.html$ {
|
location /api/ {
|
||||||
add_header Cache-Control "no-store";
|
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
|
# ── Admin proxy → Fastify (AdminJS) ──────────────────────────────────────
|
||||||
location ~* ^/_astro/ {
|
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";
|
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)$ {
|
location ~* \.(css|js)$ {
|
||||||
add_header Cache-Control "no-cache";
|
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)$ {
|
location ~* \.(jpg|jpeg|png|gif|webp|svg|woff2|woff|ttf|ico)$ {
|
||||||
add_header Cache-Control "public, max-age=604800";
|
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 / {
|
location / {
|
||||||
try_files $uri $uri/ $uri.html /index.html;
|
try_files $uri $uri/ $uri.html /index.html;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user