diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b6816e4 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +node_modules +dist +.env* +.git +tests +*.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0757d52 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +# Stage 1: build +FROM node:20-alpine AS builder +WORKDIR /app +COPY package*.json ./ +RUN npm ci +COPY . . + +# Variables de entorno inyectadas como build args desde Dokploy +ARG VITE_SUPABASE_URL +ARG VITE_SUPABASE_ANON_KEY +ENV VITE_SUPABASE_URL=$VITE_SUPABASE_URL +ENV VITE_SUPABASE_ANON_KEY=$VITE_SUPABASE_ANON_KEY + +RUN npm run build + +# Stage 2: serve +FROM nginx:alpine +COPY --from=builder /app/dist /usr/share/nginx/html +COPY nginx.conf /etc/nginx/conf.d/default.conf +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/docs/.dockerignore b/docs/.dockerignore new file mode 100644 index 0000000..8f5fd76 --- /dev/null +++ b/docs/.dockerignore @@ -0,0 +1,6 @@ +node_modules +dist +.env* +.git +tests +*.md \ No newline at end of file diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..a728dde --- /dev/null +++ b/nginx.conf @@ -0,0 +1,25 @@ +server { + listen 80; + root /usr/share/nginx/html; + index index.html; + + # SPA routing — todas las rutas van a index.html + location / { + try_files $uri $uri/ /index.html; + } + + # Cache agresivo para assets con hash en el nombre + location /assets/ { + expires 1y; + add_header Cache-Control "public, immutable"; + } + + # No cachear index.html + location = /index.html { + add_header Cache-Control "no-cache, no-store, must-revalidate"; + } + + gzip on; + gzip_types text/plain text/css application/javascript application/json image/svg+xml; + gzip_min_length 1000; +} \ No newline at end of file