-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
110 lines (105 loc) · 3.49 KB
/
docker-compose.yml
File metadata and controls
110 lines (105 loc) · 3.49 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
services:
# -------------------------------------------------------------------------
# Database: PostgreSQL with PostGIS
# -------------------------------------------------------------------------
db:
image: postgres:16-alpine
container_name: ph_geo_db
restart: always
environment:
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-secure_password_here}
POSTGRES_DB: ${POSTGRES_DB:-ph_geo_db}
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- geo_net # Internal only
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres} -d ${POSTGRES_DB:-ph_geo_db}"]
interval: 10s
timeout: 5s
retries: 10
start_period: 60s
# -------------------------------------------------------------------------
# Cache: Redis
# -------------------------------------------------------------------------
redis:
image: redis:7-alpine
container_name: ph_geo_redis
restart: always
volumes:
- redis_data:/data
networks:
- geo_net # Internal only
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 5
# -------------------------------------------------------------------------
# Backend: FastAPI (Python)
# -------------------------------------------------------------------------
backend:
build:
context: ./backend
dockerfile: Dockerfile
container_name: ph_geo_api
restart: always
depends_on:
- db
- redis
environment:
# DATABASE_URL constructed in app to handle encoding
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-secure_password_here}
POSTGRES_DB: ${POSTGRES_DB:-ph_geo_db}
POSTGRES_HOST: ph_geo_db
REDIS_URL: redis://ph_geo_redis:6379
ADMIN_SECRET: ${ADMIN_SECRET:-change_this_secret_locally}
# Important: Allow the proxy domain
ALLOWED_ORIGINS: "https://barangays.sanchez.ph,http://localhost:3000"
volumes:
# - ./backend:/app <-- Removed for Production (Use built image)
- static_exports:/app/static_exports
networks:
- geo_net # To talk to DB
- net # To talk to Nginx Proxy Manager
# ports:
# - "8000:8000" <-- Removed for Production (Use Proxy)
# -------------------------------------------------------------------------
# Frontend: Next.js
# -------------------------------------------------------------------------
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
args:
NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL:-https://barangays.sanchez.ph/api}
container_name: ph_geo_web
restart: always
depends_on:
- backend
environment:
# Browser-side URL (The Public Domain)
NEXT_PUBLIC_API_URL: https://barangays.sanchez.ph/api
# Server-side URL (Internal Docker DNS)
INTERNAL_API_URL: http://backend:8000
# ports:
# - "3000:3000" <-- Removed for Production (Use Proxy)
volumes:
- static_exports:/app/public/downloads
networks:
- geo_net
- net # To talk to Nginx Proxy Manager
# -------------------------------------------------------------------------
# Volumes & Networks
# -------------------------------------------------------------------------
volumes:
postgres_data:
redis_data:
static_exports:
networks:
geo_net:
driver: bridge
net:
external: true # <--- Looks for your existing NPM network