- apps/api/Dockerfile: multi-stage pnpm build, runtime node:22-alpine, port 3001 - apps/web/Dockerfile: multi-stage pnpm + Vite, runtime nginx:alpine with SPA config - .dockerignore: excludes node_modules, dist, .env, .git, IDE folders, design docs - Brand logo (naturcalabacera.webp) integrated as favicon, sidebar icon, header logo - index.html title updated to 'Naturcalabacera · Reservas'
53 lines
1.4 KiB
Docker
53 lines
1.4 KiB
Docker
# syntax=docker/dockerfile:1
|
|
|
|
# ───── Stage 1: build ─────
|
|
FROM node:22-alpine AS builder
|
|
WORKDIR /repo
|
|
RUN corepack enable
|
|
|
|
COPY pnpm-workspace.yaml package.json pnpm-lock.yaml ./
|
|
COPY packages/shared/package.json ./packages/shared/
|
|
COPY apps/web/package.json ./apps/web/
|
|
|
|
RUN pnpm install --frozen-lockfile
|
|
|
|
COPY packages/shared ./packages/shared
|
|
COPY apps/web ./apps/web
|
|
|
|
# Variables públicas inyectadas en el bundle por Vite (build-time)
|
|
ARG VITE_SUPABASE_URL
|
|
ARG VITE_SUPABASE_ANON_KEY
|
|
ARG VITE_SUPABASE_SCHEMA
|
|
ARG VITE_API_URL
|
|
ENV VITE_SUPABASE_URL=$VITE_SUPABASE_URL
|
|
ENV VITE_SUPABASE_ANON_KEY=$VITE_SUPABASE_ANON_KEY
|
|
ENV VITE_SUPABASE_SCHEMA=$VITE_SUPABASE_SCHEMA
|
|
ENV VITE_API_URL=$VITE_API_URL
|
|
|
|
RUN pnpm --filter @naturcalabacera/web build
|
|
|
|
# ───── Stage 2: runtime (Nginx sirviendo SPA) ─────
|
|
FROM nginx:alpine
|
|
COPY --from=builder /repo/apps/web/dist /usr/share/nginx/html
|
|
|
|
# Config SPA: cualquier ruta cae en index.html (React Router friendly)
|
|
RUN printf 'server {\n\
|
|
listen 80;\n\
|
|
server_name _;\n\
|
|
root /usr/share/nginx/html;\n\
|
|
index index.html;\n\
|
|
\n\
|
|
location / {\n\
|
|
try_files $uri $uri/ /index.html;\n\
|
|
}\n\
|
|
\n\
|
|
# Cache largo para assets con hash\n\
|
|
location /assets/ {\n\
|
|
expires 1y;\n\
|
|
add_header Cache-Control "public, immutable";\n\
|
|
}\n\
|
|
}\n' > /etc/nginx/conf.d/default.conf
|
|
|
|
EXPOSE 80
|
|
CMD ["nginx", "-g", "daemon off;"]
|