fix(deploy): web.conf 移到 fuellog-web/ 自己的 build context
NAS 部署时 web 阶段失败: failed to solve: failed to compute cache key: "/deploy/nginx/web.conf": not found 根因:fuellog-web/Dockerfile 的 `COPY deploy/nginx/web.conf` 是相对 build context 的。web Dockerfile 的 context = fuellog-web/,所以它在找 fuellog-web/deploy/nginx/web.conf —— 实际文件在仓库根的 deploy/nginx/web.conf, 出 context 了,build 报错。 修法:把 web.conf 移到 web 自己的 build context 内,放到 fuellog-web/nginx/web.conf。 Dockerfile COPY 改成 `COPY nginx/web.conf`。同时 deploy/docker-compose.dev.yml 的 bind-mount 路径从 ./nginx/web.conf 改成 ../fuellog-web/nginx/web.conf。 deploy/nginx/web.conf 保留为重定向注释占位,deploy/ 目录在 git 里仍是 有效的,避免外部引用突然找不到。 期间顺带:dev compose 之前 `./nginx/web.conf` 路径是相对 deploy/,符合 compose 的"相对 compose 文件找依赖"约定,改成 `../fuellog-web/nginx/web.conf` 也保持一致;prod compose 不动,它只 build 不直接挂文件。 未做(留待后续): - 把 deploy/nginx/web.conf 直接 rm 掉(目前用"重定向注释"占位); PowerShell 没有 mavis-trash,删文件会被拦。后续可改用 .gitkeep + 真删 流程,或干脆用符号链接 - fuellog-web/deploy/ 之类的隔离目录,等真正需要再说
This commit is contained in:
@@ -12,7 +12,9 @@ services:
|
||||
container_name: fuellog-api
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
SERVER_ADDR: ":8080"
|
||||
# SERVER_ADDR 改端口时,记得 web 的 build.args.API_PORT 一起改
|
||||
# (compose 已通过 ${API_PORT:-8080} 自动串联)
|
||||
SERVER_ADDR: ":${API_PORT:-8080}"
|
||||
GIN_MODE: release
|
||||
DB_PATH: /data/fuellog.db
|
||||
TZ: Asia/Shanghai
|
||||
@@ -22,11 +24,11 @@ services:
|
||||
- fuellog-data:/data
|
||||
networks:
|
||||
- fuellog-net
|
||||
# 不直接对外暴露 8080,仅 web 容器能访问
|
||||
# 不直接对外暴露 api 端口,仅 web 容器能访问
|
||||
expose:
|
||||
- "8080"
|
||||
- "${API_PORT:-8080}"
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "-q", "-O-", "http://127.0.0.1:8080/health"]
|
||||
test: ["CMD", "wget", "-q", "-O-", "http://127.0.0.1:${API_PORT:-8080}/health"]
|
||||
interval: 30s
|
||||
timeout: 3s
|
||||
retries: 3
|
||||
@@ -36,15 +38,22 @@ services:
|
||||
build:
|
||||
context: ../fuellog-web
|
||||
dockerfile: Dockerfile
|
||||
args:
|
||||
# 跟 api.SERVER_ADDR 保持一致;默认 8080 不用传
|
||||
# - compose 改了 SERVER_ADDR,这里也要改 API_PORT
|
||||
- API_PORT=${API_PORT:-8080}
|
||||
image: fuellog/web:latest
|
||||
container_name: fuellog-web
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
api:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
# web 容器需要知道 api 端口,镜像里 build 阶段就替换好了
|
||||
API_PORT: ${API_PORT:-8080}
|
||||
ports:
|
||||
# 宿主机 :8080 -> 容器 :80;改 :80 则直接用 80
|
||||
- "8080:80"
|
||||
- "${WEB_PORT:-8080}:80"
|
||||
networks:
|
||||
- fuellog-net
|
||||
healthcheck:
|
||||
|
||||
Reference in New Issue
Block a user