-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.prodDB.yml
136 lines (126 loc) · 4.48 KB
/
docker-compose.prodDB.yml
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# Production Docker Compose
# 2/7 - CC added dbsetup to API, also changed .env.production to .env
version: "3.9"
services:
frontend:
build:
context: ./frontend
dockerfile: ./Dockerfile_production
ports:
- "3000:80"
depends_on:
- api
- traefik
labels:
- "traefik.enable=true"
- "traefik.http.routers.frontend.rule=Host(`pvacd.newmexicowaterdata.org`)"
- "traefik.http.routers.frontend.entrypoints=websecure,web"
- "traefik.http.routers.frontend.tls=true"
- "traefik.http.routers.frontend.tls.certresolver=myresolver"
# - "traefik.http.routers.frontend-insecure.middlewares=force-secure"
# - "traefik.http.middlewares.force-secure.redirectscheme.scheme=https"
# - "traefik.http.middlewares.force-secure.redirectscheme.permanent=true"
api:
build:
context: ./api
dockerfile: ./Dockerfile
command: bash -c "
while !</dev/tcp/db/5432; do sleep 1; done;
uvicorn api.main:app
--host 0.0.0.0
--proxy-headers --root-path /api/v1
"
ports:
- "8000:8000"
volumes:
- ./api:/api
depends_on:
- db
- traefik
env_file:
- ./api/.env
labels:
- "traefik.enable=true"
- "traefik.http.routers.api.rule=Host(`pvacd.newmexicowaterdata.org`) && PathPrefix(`/api/v1`)"
- "traefik.http.routers.api.entrypoints=websecure"
- "traefik.http.routers.api.tls=true"
- "traefik.http.routers.api.tls.certresolver=myresolver"
- "traefik.http.routers.api.middlewares=api-sp"
- "traefik.http.middlewares.api-sp.stripprefix.prefixes=/api/v1"
- "traefik.http.middlewares.api-sp.stripprefix.forceSlash=false"
- "traefik.http.routers.api-insecure.rule=Host(`pvacd.newmexicowaterdata.org`) && PathPrefix(`/api/v1`)"
- "traefik.http.routers.api-insecure.entrypoints=web"
# - "traefik.http.routers.api-insecure.middlewares=force-secure"
# - "traefik.http.middlewares.force-secure.redirectscheme.scheme=https"
# - "traefik.http.middlewares.force-secure.redirectscheme.permanent=true"
db:
image: postgis/postgis
volumes:
- postgis-data:/var/lib/postgresql
env_file:
- ./api/.env
environment:
# If you need to create multiple database you can add coma separated databases eg gis,data
- ALLOW_IP_RANGE=0.0.0.0/0
# Add extensions you need to be enabled by default in the DB. Default are the five specified below
- POSTGRES_MULTIPLE_EXTENSIONS=postgis,hstore,postgis_topology,postgis_raster,pgrouting
- TZ=America/Denver
- PGTZ=America/Denver
ports:
- "5432:5432"
restart: on-failure
healthcheck:
test: "exit 0"
traefik:
image: "traefik:v2.9"
command:
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
- "--entrypoints.web.http.redirections.entrypoint.to=websecure"
- "--entrypoints.web.http.redirections.entrypoint.scheme=https"
# - "--certificatesresolvers.myresolver.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory"
- "--certificatesresolvers.myresolver.acme.tlschallenge=true"
- "--certificatesresolvers.myresolver.acme.email=newmexicowaterdata@gmail.com"
- "--certificatesresolvers.myresolver.acme.storage=acme.json"
- "--certificatesresolvers.myresolver.acme.httpchallenge.entrypoint=web"
# - "--traefik.http.middlewares.force-secure.redirectscheme.scheme=https"
# - "--traefik.http.middlewares.force-secure.redirectscheme.permanent=true"
ports:
- "80:80"
- "443:443"
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
pgbackups:
image: prodrigestivill/postgres-backup-local
restart: always
user: postgres:postgres # Optional: see below
volumes:
- /var/opt/pgbackups:/backups
links:
- db
depends_on:
- db
env_file:
- ./api/.env
environment:
- POSTGRES_EXTRA_OPTS=-Z6 --schema=public --blobs
- SCHEDULE=@daily
- BACKUP_KEEP_DAYS=7
- BACKUP_KEEP_WEEKS=4
- BACKUP_KEEP_MONTHS=6
- HEALTHCHECK_PORT=8080
# pgadmin:
# container_name: pgadmin4_container
# image: dpage/pgadmin4
# restart: always
# environment:
# PGADMIN_DEFAULT_EMAIL: [email protected]
# PGADMIN_DEFAULT_PASSWORD: root
# ports:
# - "5050:80"
volumes:
postgis-data: