# FuelLog 生产部署 # 用法: # docker compose -f deploy/docker-compose.yml up -d # 浏览器访问 http://your-host services: api: build: context: ../fuellog-api dockerfile: Dockerfile image: fuellog/api:latest container_name: fuellog-api restart: unless-stopped environment: # 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 LOG_LEVEL: info CORS_ORIGINS: "*" volumes: - fuellog-data:/data networks: - fuellog-net # 不直接对外暴露 api 端口,仅 web 容器能访问 expose: - "${API_PORT:-8080}" healthcheck: test: ["CMD", "wget", "-q", "-O-", "http://127.0.0.1:${API_PORT:-8080}/health"] interval: 30s timeout: 3s retries: 3 start_period: 10s web: 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 - "${WEB_PORT:-8080}:80" networks: - fuellog-net healthcheck: test: ["CMD", "wget", "-q", "-O-", "http://127.0.0.1/"] interval: 30s timeout: 3s retries: 3 networks: fuellog-net: driver: bridge volumes: fuellog-data: # SQLite 持久化 volume,容器删了数据还在 name: fuellog-data