From 84ebdbd793f1661c9cb78b7e837869b0a7216c3d Mon Sep 17 00:00:00 2001 From: admin <572701190@qq.com> Date: Sat, 9 May 2026 19:08:21 +0800 Subject: [PATCH] inline compose environment for container station --- README.md | 2 +- docker_compose.yaml | 6 ++++-- docker_compose_Nas.yaml | 20 ++++++++------------ 迁移部署说明.md | 23 +++++++++++++---------- 4 files changed, 26 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index d835a14..d4388ca 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ For Agent-facing image generation and editing instructions, see `API图片绘制 ## Docker Compose Deploy -Create `.env.local` first: +For Docker Compose deployment, edit `docker_compose.yaml` and fill the `environment` values: ```env GEMINI_API_KEY="YOUR_GEMINI_API_KEY" diff --git a/docker_compose.yaml b/docker_compose.yaml index 7e55af5..e179539 100644 --- a/docker_compose.yaml +++ b/docker_compose.yaml @@ -6,11 +6,13 @@ services: container_name: gemini-draw init: true restart: unless-stopped - env_file: - - .env.local environment: + GEMINI_API_KEY: "CHANGE_ME_TO_YOUR_GEMINI_API_KEY" + API_AUTH_TOKEN: "CHANGE_ME_TO_A_LONG_RANDOM_TOKEN" API_PORT: "3002" API_AUTH_DISABLED: "false" + APP_PASSWORD: "123456" + APP_URL: "http://localhost:3000" ports: - "3000:3000" - "3002:3002" diff --git a/docker_compose_Nas.yaml b/docker_compose_Nas.yaml index 4ab64be..ebab57c 100644 --- a/docker_compose_Nas.yaml +++ b/docker_compose_Nas.yaml @@ -8,17 +8,11 @@ services: # If your project is in a different folder, update `build.context` below # or run compose from the project folder and change it to `.`. # - # First-time setup on NAS: + # First-time setup on NAS source folder: # cd /share/Container/gemini-drawpicture - # cp .env.example .env.local - # vi .env.local # - # Required values in .env.local: - # GEMINI_API_KEY="your_gemini_api_key" - # API_AUTH_TOKEN="a_long_random_api_access_token" - # API_AUTH_DISABLED="false" - # APP_PASSWORD="your_web_login_password" - # APP_URL="http://192.168.31.5:4001" + # Container Station validates compose files from /tmp, so do not use + # relative environment-file paths here. Fill values directly below. # # Build and start: # cd /share/Container/gemini-drawpicture @@ -40,12 +34,14 @@ services: container_name: gemini-drawpicture init: true restart: unless-stopped - env_file: - - .env.local environment: - # Keep API auth enabled on NAS. Use API_AUTH_TOKEN from .env.local. + # Required business settings. + GEMINI_API_KEY: "CHANGE_ME_TO_YOUR_GEMINI_API_KEY" + API_AUTH_TOKEN: "CHANGE_ME_TO_A_LONG_RANDOM_TOKEN" API_AUTH_DISABLED: "false" API_PORT: "3002" + APP_PASSWORD: "CHANGE_ME_TO_YOUR_WEB_PASSWORD" + APP_URL: "http://192.168.31.5:4001" # Optional proxy settings. Keep them if NAS needs OpenClash/proxy # to reach Google/Gemini; otherwise comment these lines out. diff --git a/迁移部署说明.md b/迁移部署说明.md index 1fed52e..eeb39ef 100644 --- a/迁移部署说明.md +++ b/迁移部署说明.md @@ -12,7 +12,7 @@ ## 必须修改的配置 -在目标机器项目根目录创建 `.env.local`: +如果使用 `npm run dev` / `npm run api` 本地运行,在目标机器项目根目录创建 `.env.local`: ```env GEMINI_API_KEY="你的_Gemini_API_Key" @@ -32,6 +32,8 @@ APP_URL="http://目标机器IP:3000" - `APP_PASSWORD`:网页登录密码,默认用户名是 `admin`。 - `APP_URL`:前端访问地址,迁移到 NAS 时建议写成 `http://NAS_IP:3000`。 +如果使用 Docker Compose,尤其是在 Container Station 里粘贴 YAML 创建应用,请直接修改 `docker_compose.yaml` 或 `docker_compose_Nas.yaml` 里的 `environment` 字段。Container Station 会从 `/tmp` 校验 YAML,相对环境文件路径容易被解析到 `/tmp` 并失败,所以当前 compose 文件把必要变量直接写在 `environment` 中。 + 生成随机 `API_AUTH_TOKEN` 的示例: ```bash @@ -168,15 +170,16 @@ cd /share/Container/gemini-drawpicture docker compose -f docker_compose_Nas.yaml up -d --build ``` -`.env.local` 示例: +`docker_compose_Nas.yaml` 的 `environment` 示例: -```env -GEMINI_API_KEY="你的_Gemini_API_Key" -API_AUTH_TOKEN="你的_API_访问密钥" -API_AUTH_DISABLED="false" -API_PORT="3002" -APP_PASSWORD="你的网页登录密码" -APP_URL="http://192.168.31.5:3000" +```yaml +environment: + GEMINI_API_KEY: "你的_Gemini_API_Key" + API_AUTH_TOKEN: "你的_API_访问密钥" + API_AUTH_DISABLED: "false" + API_PORT: "3002" + APP_PASSWORD: "你的网页登录密码" + APP_URL: "http://192.168.31.5:4001" ``` 如果 NAS 上 `3000` 或 `3002` 已被占用,就只改 `docker_compose.yaml` 左侧宿主机端口: @@ -227,7 +230,7 @@ GEMINI_API_KEY="你的_Gemini_API_Key" x-gemini-api-key: 你的_Gemini_API_Key ``` -### 修改 `.env.local` 后没有生效 +### 修改环境变量后没有生效 重启容器: