Tots els compose
This commit is contained in:
17
astro/Dockerfile
Normal file
17
astro/Dockerfile
Normal file
@@ -0,0 +1,17 @@
|
||||
# ── Fase 1: Compilació amb Node.js ────────
|
||||
FROM node:20-alpine AS builder
|
||||
WORKDIR /app
|
||||
# Instal·la dependències primer (aprofita la cache de Docker)
|
||||
COPY package*.json ./
|
||||
RUN npm ci
|
||||
# Copia el codi font i compila
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
# ── Fase 2: Servir amb Nginx (imatge mínima) ──
|
||||
FROM nginx:alpine
|
||||
# Copia NOMÉS la carpeta dist/ de la fase anterior
|
||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||
# Configuració Nginx per a SPA i rutes d'Astro
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
EXPOSE 80
|
||||
28
astro/docker-compose.yml
Normal file
28
astro/docker-compose.yml
Normal file
@@ -0,0 +1,28 @@
|
||||
# /opt/stacks/astro-web/docker-compose.yml
|
||||
|
||||
services:
|
||||
|
||||
astro-web:
|
||||
container_name: astro-web
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
image: astro-web:local # Nom explícit per a la imatge buildada
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
TZ: Europe/Madrid
|
||||
ports:
|
||||
- "8087:80" # Només local → via Nginx Proxy Manager
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:80"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 15s
|
||||
networks:
|
||||
- shared_net
|
||||
|
||||
networks:
|
||||
shared_net:
|
||||
external: true
|
||||
name: shared_net
|
||||
16
astro/nginx.conf
Normal file
16
astro/nginx.conf
Normal file
@@ -0,0 +1,16 @@
|
||||
server {
|
||||
listen 80;
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
# Rutes d'Astro: si no troba el fitxer, retorna 404.html
|
||||
location / {
|
||||
try_files $uri $uri/ $uri.html =404;
|
||||
}
|
||||
|
||||
# Cache agressiva per a assets compilats (hash al nom)
|
||||
location /_astro/ {
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user