From 4ee154dee3763a0e49d2e5c953ff09b2d3feba07 Mon Sep 17 00:00:00 2001 From: Petar Zivkovic Date: Mon, 9 Feb 2026 16:52:02 +0100 Subject: [PATCH] update: remove production-like settings from Docker to focus on local use --- Dockerfile | 6 +++--- README-zh.md | 17 ----------------- compose.prod.yml | 44 -------------------------------------------- frontend/Dockerfile | 18 ------------------ frontend/nginx.conf | 32 -------------------------------- 5 files changed, 3 insertions(+), 114 deletions(-) delete mode 100644 compose.prod.yml delete mode 100644 frontend/nginx.conf diff --git a/Dockerfile b/Dockerfile index 954d39c9..5982194d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,11 +20,11 @@ ENV UV_PROJECT_ENVIRONMENT=/opt/venv # Copy dependency files first to maximize cache COPY pyproject.toml ./ -# If you have a lock file, uncomment the next line for reproducible builds: -# COPY uv.lock ./ +# reproducible builds: +COPY uv.lock ./ # 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 ---- FROM python:3.12-slim AS runtime diff --git a/README-zh.md b/README-zh.md index 4db5fd3a..db73c288 100755 --- a/README-zh.md +++ b/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` 文件。 diff --git a/compose.prod.yml b/compose.prod.yml deleted file mode 100644 index 237ebbb6..00000000 --- a/compose.prod.yml +++ /dev/null @@ -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: {} diff --git a/frontend/Dockerfile b/frontend/Dockerfile index b38d24c4..c0d4804c 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -13,21 +13,3 @@ COPY --from=deps /app/node_modules /app/node_modules COPY . . EXPOSE 5173 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;"] diff --git a/frontend/nginx.conf b/frontend/nginx.conf deleted file mode 100644 index 2138c209..00000000 --- a/frontend/nginx.conf +++ /dev/null @@ -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; - } -}