fix: correct web Dockerfile for Vite (not Next.js)

This commit is contained in:
Xiaoxia AI
2026-06-20 14:08:27 +08:00
parent 3b72307bee
commit 0f42ca1a7b
2 changed files with 42 additions and 12 deletions
+32
View File
@@ -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";
}
}
+10 -12
View File
@@ -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;"]