todowindy/docker-compose.yml

70 lines
2.2 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.

version: "3.9"
services:
# Backend API service (Go app)
todowindy:
build: .
image: todowindy:latest
container_name: todowindy
restart: unless-stopped
# Do not publish container port directly; expose to compose network only.
ports: ["8080:8080"]
expose:
- "8080"
env_file:
- .env
environment:
# Ensure server binds on all interfaces in container
- TW_ADDR=:8080
# Use external writable volume for SQLite (align with image default path)
- TW_DB_PATH=/app/data/todowindy.db
# Run in production mode by default
- GIN_MODE=release
# Optional timeouts (RFC3339 duration strings or seconds)
- TW_HTTP_WRITE_TIMEOUT=${TW_HTTP_WRITE_TIMEOUT:-240s}
- TW_HTTP_READ_TIMEOUT=${TW_HTTP_READ_TIMEOUT:-60s}
- TW_HTTP_IDLE_TIMEOUT=${TW_HTTP_IDLE_TIMEOUT:-90s}
# Optional timezone for tzdata
- TZ=${TZ:-UTC}
volumes:
# Persist DB to host; image user has write perms for /app/data
- ./data:/app/data
healthcheck:
test: ["CMD", "curl", "-fsS", "http://127.0.0.1:8080/healthz"]
interval: 30s
timeout: 5s
start_period: 10s
retries: 3
stop_grace_period: 10s
# Front proxy + static file server
nginx:
image: nginx:1.25-alpine
container_name: todowindy-nginx
depends_on:
- todowindy
ports:
- "8088:80" # 本机用 8088 访问;也可改为 "80:80"
# 不要先开 443:443本地无证书
volumes:
- ./web:/usr/share/nginx/html:ro
- ./deploy/prod/nginx.http.conf:/etc/nginx/conf.d/default.conf:ro
# 本地开发不需要这些证书相关挂载,先删掉/注释掉
# - ./deploy/letsencrypt:/etc/letsencrypt
# - ./deploy/certbot/www:/var/www/certbot:ro
restart: unless-stopped
# Optional named volumes for persistence can be declared here if needed
# volumes:
# letsencrypt:
# certbot-www:
# Certbot helper service (run on-demand for issue/renew)
certbot:
image: certbot/certbot:latest
container_name: todowindy-certbot
volumes:
- ./deploy/letsencrypt:/etc/letsencrypt
- ./deploy/certbot/www:/var/www/certbot
# No ports; invoke with `docker compose run --rm certbot ...`
restart: "no"