mirror of
https://github.com/OpenBMB/ChatDev.git
synced 2026-04-25 11:18:06 +00:00
update: remove production-like settings from Docker to focus on local use
This commit is contained in:
parent
b3a22b4fbd
commit
4ee154dee3
@ -20,11 +20,11 @@ ENV UV_PROJECT_ENVIRONMENT=/opt/venv
|
|||||||
|
|
||||||
# Copy dependency files first to maximize cache
|
# Copy dependency files first to maximize cache
|
||||||
COPY pyproject.toml ./
|
COPY pyproject.toml ./
|
||||||
# If you have a lock file, uncomment the next line for reproducible builds:
|
# reproducible builds:
|
||||||
# COPY uv.lock ./
|
COPY uv.lock ./
|
||||||
|
|
||||||
# Create the project virtualenv and install deps
|
# Create the project virtualenv and install deps
|
||||||
RUN uv sync --no-cache
|
RUN uv sync --no-cache --frozen
|
||||||
|
|
||||||
# ---- Runtime: minimal image with only runtime libs + app ----
|
# ---- Runtime: minimal image with only runtime libs + app ----
|
||||||
FROM python:3.12-slim AS runtime
|
FROM python:3.12-slim AS runtime
|
||||||
|
|||||||
17
README-zh.md
17
README-zh.md
@ -190,23 +190,6 @@ make dev
|
|||||||
|
|
||||||
> 服务在异常退出后会自动重启,本地文件的修改会同步映射到容器中,便于实时开发。
|
> 服务在异常退出后会自动重启,本地文件的修改会同步映射到容器中,便于实时开发。
|
||||||
|
|
||||||
#### 生产环境(Docker + nginx)
|
|
||||||
|
|
||||||
- 构建并运行:
|
|
||||||
```bash
|
|
||||||
docker compose -f compose.yml -f compose.prod.yml up -d --build
|
|
||||||
```
|
|
||||||
- 访问:
|
|
||||||
- 前端:http://localhost:8080
|
|
||||||
- 后端:不对外暴露,由 nginx 通过 /api 与 /ws 转发
|
|
||||||
- 停止:
|
|
||||||
```bash
|
|
||||||
docker compose -f compose.yml -f compose.prod.yml down
|
|
||||||
```
|
|
||||||
- 说明:
|
|
||||||
- .env 保存密钥(API Keys),.env.docker 保存容器相关配置。
|
|
||||||
- nginx 将 /api 与 /ws 代理到 backend:6400(见 frontend/nginx.conf)。
|
|
||||||
|
|
||||||
### 🔑 配置
|
### 🔑 配置
|
||||||
|
|
||||||
* **环境变量**:在项目根目录创建一个 `.env` 文件。
|
* **环境变量**:在项目根目录创建一个 `.env` 文件。
|
||||||
|
|||||||
@ -1,44 +0,0 @@
|
|||||||
services:
|
|
||||||
backend:
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
target: runtime
|
|
||||||
container_name: chatdev_backend
|
|
||||||
env_file:
|
|
||||||
- .env
|
|
||||||
- .env.docker
|
|
||||||
expose:
|
|
||||||
- "6400"
|
|
||||||
restart: unless-stopped
|
|
||||||
networks:
|
|
||||||
- appnet
|
|
||||||
# Optional healthcheck (adjust path if different)
|
|
||||||
# healthcheck:
|
|
||||||
# test: ["CMD-SHELL", "curl -fsS http://localhost:6400/api/health || exit 1"]
|
|
||||||
# interval: 10s
|
|
||||||
# timeout: 3s
|
|
||||||
# retries: 5
|
|
||||||
|
|
||||||
frontend:
|
|
||||||
build:
|
|
||||||
context: ./frontend
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
target: prod
|
|
||||||
container_name: chatdev_frontend
|
|
||||||
ports:
|
|
||||||
- "8080:80"
|
|
||||||
depends_on:
|
|
||||||
- backend
|
|
||||||
restart: unless-stopped
|
|
||||||
networks:
|
|
||||||
- appnet
|
|
||||||
# Optional healthcheck
|
|
||||||
# healthcheck:
|
|
||||||
# test: ["CMD-SHELL", "wget -q -O - http://localhost/ >/dev/null 2>&1 || exit 1"]
|
|
||||||
# interval: 10s
|
|
||||||
# timeout: 3s
|
|
||||||
# retries: 5
|
|
||||||
|
|
||||||
networks:
|
|
||||||
appnet: {}
|
|
||||||
@ -13,21 +13,3 @@ COPY --from=deps /app/node_modules /app/node_modules
|
|||||||
COPY . .
|
COPY . .
|
||||||
EXPOSE 5173
|
EXPOSE 5173
|
||||||
CMD ["npm", "run", "dev", "--", "--host"]
|
CMD ["npm", "run", "dev", "--", "--host"]
|
||||||
|
|
||||||
# ---- Build: create production assets ----
|
|
||||||
FROM node:24-alpine AS build
|
|
||||||
WORKDIR /app
|
|
||||||
ENV NODE_ENV=production
|
|
||||||
ARG VITE_API_BASE_URL=http://backend:6400
|
|
||||||
ENV VITE_API_BASE_URL=""
|
|
||||||
COPY --from=deps /app/node_modules /app/node_modules
|
|
||||||
COPY . .
|
|
||||||
RUN npm run build
|
|
||||||
|
|
||||||
# ---- Prod runtime: serve static dist with nginx ----
|
|
||||||
FROM nginx:alpine AS prod
|
|
||||||
# For SPA deep links you might add a custom nginx.conf with index.html fallback.
|
|
||||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
|
||||||
COPY --from=build /app/dist /usr/share/nginx/html
|
|
||||||
EXPOSE 80
|
|
||||||
CMD ["nginx", "-g", "daemon off;"]
|
|
||||||
|
|||||||
@ -1,32 +0,0 @@
|
|||||||
server {
|
|
||||||
listen 80;
|
|
||||||
server_name _;
|
|
||||||
|
|
||||||
# Serve built assets
|
|
||||||
root /usr/share/nginx/html;
|
|
||||||
index index.html;
|
|
||||||
|
|
||||||
# Proxy API
|
|
||||||
location /api/ {
|
|
||||||
proxy_pass http://backend:6400/api/;
|
|
||||||
proxy_http_version 1.1;
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Proxy WebSocket
|
|
||||||
location /ws {
|
|
||||||
proxy_pass http://backend:6400/ws;
|
|
||||||
proxy_http_version 1.1;
|
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
|
||||||
proxy_set_header Connection "upgrade";
|
|
||||||
proxy_set_header Host $host;
|
|
||||||
}
|
|
||||||
|
|
||||||
# SPA fallback
|
|
||||||
location / {
|
|
||||||
try_files $uri $uri/ /index.html;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user