From acaff441bc9620fe872707e72b98a67a1391561b Mon Sep 17 00:00:00 2001 From: Xiaoxia AI Date: Sat, 20 Jun 2026 14:08:27 +0800 Subject: [PATCH] fix: correct web Dockerfile for Vite (not Next.js) --- infra/docker/nginx.conf | 32 ++++++++++++++++++++++++++++++++ infra/docker/web.Dockerfile | 22 ++++++++++------------ 2 files changed, 42 insertions(+), 12 deletions(-) create mode 100644 infra/docker/nginx.conf diff --git a/infra/docker/nginx.conf b/infra/docker/nginx.conf new file mode 100644 index 000000000..cfaf3afaf --- /dev/null +++ b/infra/docker/nginx.conf @@ -0,0 +1,32 @@ +server { + listen 80; + server_name _; + root /usr/share/nginx/html; + index index.html; + + # Gzip compression + gzip on; + gzip_vary on; + gzip_min_length 1024; + gzip_types text/plain text/css text/xml text/javascript application/javascript application/json application/xml+rss; + + # SPA routing - all routes to index.html + location / { + try_files $uri $uri/ /index.html; + } + + # API proxy + location /api/ { + proxy_pass http://api:8000/api/; + 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 static assets + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { + expires 1y; + add_header Cache-Control "public, immutable"; + } +} diff --git a/infra/docker/web.Dockerfile b/infra/docker/web.Dockerfile index 4ed81576d..f331e1fa3 100644 --- a/infra/docker/web.Dockerfile +++ b/infra/docker/web.Dockerfile @@ -1,7 +1,8 @@ +# Build stage FROM node:20 AS builder WORKDIR /app -ARG NEXT_PUBLIC_API_URL=http://47.98.113.167:8089 -ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL +ARG VITE_API_URL=http://47.98.113.167:8000 +ENV VITE_API_URL=$VITE_API_URL COPY apps/web/package.json ./apps/web/package.json COPY apps/web/ ./apps/web/ WORKDIR /app/apps/web @@ -9,13 +10,10 @@ RUN npm config set registry https://registry.npmmirror.com \ && npm install \ && npm run build -FROM node:20 AS runner -WORKDIR /app/apps/web -ENV NODE_ENV=production -ENV NEXT_TELEMETRY_DISABLED=1 -COPY --from=builder /app/apps/web/package.json ./package.json -COPY --from=builder /app/apps/web/.next ./.next -COPY --from=builder /app/apps/web/public ./public -COPY --from=builder /app/apps/web/node_modules ./node_modules -EXPOSE 3000 -CMD ["npm", "run", "start"] +# Production stage with nginx +FROM nginx:alpine AS runner +WORKDIR /usr/share/nginx/html +COPY --from=builder /app/apps/web/dist ./ +COPY infra/docker/nginx.conf /etc/nginx/conf.d/default.conf +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"]