Files
InfoGenie/infogenie-backend-go/docker-compose.yml

31 lines
1.6 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 生产:宿主机 12364 -> 容器内 5002容器名 infogenie-backend-go
#
# 推荐(不在服务器编译 Go先在 Windows 运行 build-linux-amd64.bat 生成 dist\server
# 再执行: docker compose up -d --build
# 镜像使用 Dockerfile.prebuilt仅打包 Alpine + 二进制。
#
# 若要在 Docker 内多阶段编译,改用: docker compose -f docker-compose.yml -f docker-compose.sourcebuild.yml up -d --build
#
# ========== 前端连不上 Docker 后端时排查 ==========
# 1) 容器是否起来: docker ps 看 infogenie-backend-go宿主机 curl http://127.0.0.1:12364/api/health
# 2) .env.production 里 DB_HOST/REDIS_ADDR容器内 127.0.0.1 是容器自己,不是宿主机。
# MySQL/Redis 在宿主机时Linux 常用 172.17.0.1 或宿主机内网 IPDocker Desktop 可用 host.docker.internal
# 3) REDIS_ENABLED=true 时 Redis 必须可达否则进程启动失败main 里 cache.Init 会报错退出)
# 4) 前端生产构建的 VITE_API_URL 必须是浏览器能访问的地址HTTPS 域名反代到 12364或公网 IP+端口),
# 勿指向仅内网可达的 IP与 env.js 里生产默认 https://infogenie.api.shumengya.top 一致时需 DNS/反代已配置
# 5) 云服务器安全组/防火墙放行 12364若直连端口
services:
infogenie-backend-go:
build:
context: .
dockerfile: Dockerfile.prebuilt
image: infogenie-backend-go:latest
container_name: infogenie-backend-go
ports:
- "12364:5002"
env_file:
- .env.production
environment:
APP_ENV: production
restart: unless-stopped