From 9be5c1b31f7d9ca3b5b265a9badc47f594012d45 Mon Sep 17 00:00:00 2001 From: chiyi Date: Wed, 1 Jul 2026 10:10:05 +0800 Subject: [PATCH] =?UTF-8?q?docker:=20compose=20=E5=8E=BB=E6=8E=89=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E5=8F=98=E9=87=8F=E4=BE=9D=E8=B5=96(=E5=80=BC?= =?UTF-8?q?=E5=86=85=E8=81=94),README=20=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - docker-compose.yml 所有 ${VAR:-default} 改为内联写死,无需 .env,直接 docker compose up -d --build - createbucket 服务保留(借 mc 客户端给 RustFS 建桶,一次性) - README(中英)改口径:自定义密码/密钥/CORS 直接改 compose 文件 Co-Authored-By: Claude Opus 4.8 --- README.en.md | 2 +- README.md | 2 +- docker-compose.yml | 44 ++++++++++++++++++++++---------------------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/README.en.md b/README.en.md index 0d7c1a7..9a29dd0 100644 --- a/README.en.md +++ b/README.en.md @@ -143,7 +143,7 @@ Images return OpenAI-style `{ "created": ..., "data": [{ "b64_json": "..." }] }` > Domain + HTTPS are handled by your own reverse proxy (this project issues no certificates). -**Docker (recommended)**: `docker compose up -d --build` brings up PostgreSQL + Redis + RustFS + backend + frontend (nginx serving **HTTP on container port 2000**); point your reverse proxy at `http://:2000` (port via `WEB_PORT`; set passwords / keys / `CORS_ORIGINS` in a `.env` beside the compose file, `COOKIE_SECURE=true` when your proxy serves HTTPS). +**Docker (recommended)**: `docker compose up -d --build` brings up PostgreSQL + Redis + RustFS + backend + frontend (nginx serving **HTTP on container port 2000**); point your reverse proxy at `http://:2000` (port via `WEB_PORT`; edit the values (passwords / keys / `CORS_ORIGINS`, and `COOKIE_SECURE=true` when your proxy serves HTTPS) directly in `docker-compose.yml`). Or **build from source** — bring your own **PostgreSQL · Redis · RustFS (or any S3) · reverse proxy**: diff --git a/README.md b/README.md index de1a678..ffda05a 100644 --- a/README.md +++ b/README.md @@ -151,7 +151,7 @@ curl https://你的域名/v1/images/edits \ > 域名 + HTTPS 由你自己的反向代理处理(本项目不内置证书签发)。 -**Docker(推荐)**:`docker compose up -d --build` 一条命令拉起 PostgreSQL + Redis + RustFS + 后端 + 前端(nginx **HTTP 监听容器 2000 端口**),把你的反向代理指到 `http://<本机>:2000`(端口用 `WEB_PORT` 改;要自定义密码 / 密钥 / `CORS_ORIGINS` 就在 compose 同目录建 `.env` 配,反代走 HTTPS 时设 `COOKIE_SECURE=true`)。 +**Docker(推荐)**:`docker compose up -d --build` 一条命令拉起 PostgreSQL + Redis + RustFS + 后端 + 前端(nginx **HTTP 监听容器 2000 端口**),把你的反向代理指到 `http://<本机>:2000`(端口用 `WEB_PORT` 改;要改密码 / 密钥 / `CORS_ORIGINS`(反代走 HTTPS 时把 `COOKIE_SECURE` 设为 `true`),直接改 `docker-compose.yml` 里对应值即可)。 也可**从源码手动构建**,自备 **PostgreSQL · Redis · RustFS(或任意 S3)· 反向代理**: diff --git a/docker-compose.yml b/docker-compose.yml index e063a48..80d9e99 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,17 +1,17 @@ # image2api — one-command stack: PostgreSQL + Redis + RustFS (S3) + backend -# (pre-built binary) + frontend/nginx (built here, HTTP only on port 2000). -# TLS + domain are NOT handled here — put your own reverse proxy in front of the -# web container (host port ${WEB_PORT:-2000}) and terminate TLS there. -# 1) cp .env.docker.example .env # 填 密码 / 密钥 / CORS_ORIGINS -# 2) docker compose up -d --build -# Then point your reverse proxy at http://:${WEB_PORT:-2000}. +# (built from source) + frontend/nginx (HTTP only on port 2000). Self-contained: +# docker compose up -d --build +# No .env needed — all values are inline below. TLS + domain are handled by YOUR +# OWN reverse proxy in front of the web container (host port 2000). +# ⚠ Before exposing to production, change the passwords/keys (POSTGRES_PASSWORD, +# RUSTFS_ACCESS_KEY/SECRET_KEY) and set CORS_ORIGINS to your real site origin. services: postgres: image: postgres:16-alpine environment: POSTGRES_DB: vivid_ai POSTGRES_USER: postgres - POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-change-me-postgres} + POSTGRES_PASSWORD: change-me-postgres volumes: - pgdata:/var/lib/postgresql/data healthcheck: @@ -39,8 +39,8 @@ services: rustfs: image: rustfs/rustfs:latest environment: - RUSTFS_ACCESS_KEY: ${S3_ACCESS_KEY:-vividai} - RUSTFS_SECRET_KEY: ${S3_SECRET_KEY:-vividai-secret-change-me} + RUSTFS_ACCESS_KEY: vividai + RUSTFS_SECRET_KEY: vividai-secret-change-me RUSTFS_ADDRESS: ":9000" RUSTFS_VOLUMES: /data volumes: @@ -55,10 +55,10 @@ services: - rustfs entrypoint: > /bin/sh -c " - until mc alias set s3 http://rustfs:9000 ${S3_ACCESS_KEY:-vividai} ${S3_SECRET_KEY:-vividai-secret-change-me}; do + until mc alias set s3 http://rustfs:9000 vividai vividai-secret-change-me; do echo 'waiting for rustfs...'; sleep 2; done; - mc mb -p s3/${S3_BUCKET:-vivid-ai} || true; + mc mb -p s3/vivid-ai || true; echo 'bucket ready'; " restart: "no" @@ -68,20 +68,20 @@ services: context: ./backend environment: APP_ENV: production - APP_TITLE: ${APP_TITLE:-image2api} + APP_TITLE: image2api HTTP_ADDR: 0.0.0.0:6666 - POSTGRES_DSN: host=postgres user=postgres password=${POSTGRES_PASSWORD:-change-me-postgres} dbname=vivid_ai port=5432 sslmode=disable TimeZone=Asia/Shanghai + POSTGRES_DSN: host=postgres user=postgres password=change-me-postgres dbname=vivid_ai port=5432 sslmode=disable TimeZone=Asia/Shanghai REDIS_ADDR: redis:6379 REDIS_PASSWORD: "" REDIS_DB: "0" RUSTFS_ENDPOINT: http://rustfs:9000 - RUSTFS_BUCKET: ${S3_BUCKET:-vivid-ai} - RUSTFS_ACCESS_KEY: ${S3_ACCESS_KEY:-vividai} - RUSTFS_SECRET_KEY: ${S3_SECRET_KEY:-vividai-secret-change-me} - # Your site origin(s), comma-separated (the URL your reverse proxy serves). - CORS_ORIGINS: ${CORS_ORIGINS:-http://localhost:2000} - # Keep true only if your reverse proxy serves HTTPS; false for plain HTTP. - COOKIE_SECURE: ${COOKIE_SECURE:-false} + RUSTFS_BUCKET: vivid-ai + RUSTFS_ACCESS_KEY: vividai + RUSTFS_SECRET_KEY: vividai-secret-change-me + # Set to the URL your reverse proxy serves the site on (comma-separated). + CORS_ORIGINS: http://localhost:2000 + # true only if your reverse proxy serves HTTPS; false for plain HTTP. + COOKIE_SECURE: "false" volumes: - generated:/app/data/generated depends_on: @@ -102,9 +102,9 @@ services: build: context: ./frontend # nginx serves the SPA + proxies the API on container port 2000 (HTTP only). - # Point your own reverse proxy at host:${WEB_PORT:-2000}. + # Point your own reverse proxy at host:2000. ports: - - "${WEB_PORT:-2000}:2000" + - "2000:2000" depends_on: - backend restart: unless-stopped