This repository was archived by the owner on Mar 26, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompose.prod.yml
More file actions
70 lines (66 loc) · 1.77 KB
/
compose.prod.yml
File metadata and controls
70 lines (66 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Production environment (auto-deploy via Watchtower)
# Image from GHCR.io (latest tag)
# Database: Local (POSTGRES_HOST=db) or External (DBaaS like Supabase)
# No port exposure (use nginx + Cloudflare Proxy)
#
# Usage:
# make prod:deploy # Initial deployment
# make prod:logs # View logs
# make prod:ps # Check status
services:
server:
container_name: ${COMPOSE_PROJECT_NAME:-fastapi-template}-server-prod
image: ghcr.io/${GITHUB_REPOSITORY:-ukwhatn/fastapi-template}:latest
command:
- /bin/sh
- -c
- |
fastapi run app/main.py --host 0.0.0.0 --port 80 --proxy-headers
ports:
- "127.0.0.1:${APP_PORT}:80"
volumes:
- ./newrelic.ini:/etc/newrelic.ini:ro
env_file:
- .env.prod
environment:
- ENV_MODE=production
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:80/api/system/healthcheck/"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
depends_on:
db:
condition: service_healthy
required: false
networks:
- prod
db:
container_name: ${COMPOSE_PROJECT_NAME:-fastapi-template}-db-prod
image: postgres:17
env_file:
- .env.prod
environment:
POSTGRES_DB: ${POSTGRES_DB:-main}
TZ: Asia/Tokyo
volumes:
- pg_data_prod:/var/lib/postgresql/data
restart: unless-stopped
healthcheck:
test: pg_isready -U ${POSTGRES_USER:-user} -d ${POSTGRES_DB:-main}
interval: 2s
timeout: 5s
retries: 30
networks:
- prod
profiles:
- local-db
volumes:
pg_data_prod:
name: ${COMPOSE_PROJECT_NAME:-fastapi-template}-pg-data-prod
networks:
prod:
name: ${COMPOSE_PROJECT_NAME:-fastapi-template}-prod
driver: bridge