docker配置修改
This commit is contained in:
@@ -25,4 +25,4 @@ services:
|
||||
ports:
|
||||
# 选择避开了NAS常见的80, 443, 3000, 8080等端口,用 8090 作为外部访问端。
|
||||
# 你可以在NAS路由器或面板中直接访问: http://群晖NAS_IP:8090
|
||||
- "8090:80"
|
||||
- "8090:8090"
|
||||
@@ -1,18 +1,13 @@
|
||||
FROM node:18-alpine AS builder
|
||||
FROM node:18-alpine
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm install
|
||||
COPY . .
|
||||
|
||||
# NAS部署非常关键的一步:由于走Nginx同域反代,需将URL置空以使用相对路径,避免局域网IP锁死
|
||||
# NAS部署:使用相对路径,以便让Vite Preview接管同域/api路由并代理给backend容器
|
||||
ENV VITE_API_BASE_URL=""
|
||||
RUN npm run build
|
||||
|
||||
FROM nginx:alpine
|
||||
# 获取vite构件结果
|
||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||
# 覆盖Nginx默认配置
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
# 暴露的Web服务器访问端口
|
||||
EXPOSE 80
|
||||
# 安装一个轻量静态服务器 (http-server 或 serve),或者直接使用 vite preview
|
||||
EXPOSE 8090
|
||||
CMD ["npm", "run", "preview", "--", "--host", "0.0.0.0", "--port", "8090"]
|
||||
@@ -38,4 +38,24 @@ export default defineConfig({
|
||||
},
|
||||
},
|
||||
},
|
||||
server: {
|
||||
port: 8090,
|
||||
host: '0.0.0.0',
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://backend:8080',
|
||||
changeOrigin: true
|
||||
}
|
||||
}
|
||||
},
|
||||
preview: {
|
||||
port: 8090,
|
||||
host: '0.0.0.0',
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://backend:8080',
|
||||
changeOrigin: true
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user