-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocker-compose.yml
128 lines (123 loc) · 4.99 KB
/
docker-compose.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
version: "3.8"
x-logging: &default-logging
options:
max-size: "10m"
max-file: "2"
driver: json-file
# Debug config with docker-compose --env-file <...> config
services:
backend:
image: ${PROJECT_PREFIX:?not set}-${APP_ENV:?not set}-backend:latest
container_name: backend_${PROJECT_PREFIX:?not set}_${APP_ENV:?not set}
user: ${CONTAINER_USER:?not set}
networks:
- traefik-net
build:
context: ./backend
dockerfile: Dockerfile.${APP_ENV:?not set}
args:
- "CONTAINER_USER=${CONTAINER_USER:?not set}"
volumes:
- /backend/.pytest_cache/
- /backend/__pycache__/
- /backend/.mypy_cache/
- /backend/.venv/
- ./backend/:/backend/
- ./backend/logs/:/backend/logs/
- ./backend/.env.${APP_ENV:?not set}:/backend/.env.${APP_ENV:?not set}
# command: uvicorn app.api.server:app --reload --reload-dir app/ --workers 2 --host 0.0.0.0 --port ${BACKEND_PORT_DEV:?not set}
env_file:
- ./backend/.env.${APP_ENV:?not set}
environment:
APP_ENV: ${APP_ENV:?not set}
depends_on:
- db
restart: unless-stopped
labels:
- traefik.enable=true
- traefik.http.routers.${PROJECT_PREFIX:?not set}-${APP_ENV:?not set}-backend.rule=Host(`${DOMAIN:?not set}`) && PathPrefix("/api")
- traefik.http.routers.${PROJECT_PREFIX:?not set}-${APP_ENV:?not set}-backend.middlewares=strip_prefix,test-compress
- traefik.http.middlewares.test-compress.compress=true
- traefik.http.middlewares.strip_prefix.stripprefix.prefixes=/api
- traefik.docker.network=traefik-net
- traefik.http.routers.${PROJECT_PREFIX:?not set}-${APP_ENV:?not set}-backend.entrypoints=websecure
- traefik.http.routers.${PROJECT_PREFIX:?not set}-${APP_ENV:?not set}-backend.tls=true
- traefik.http.services.${PROJECT_PREFIX:?not set}-${APP_ENV:?not set}-backend.loadbalancer.server.port=${BACKEND_PORT:?not set}
logging: *default-logging
db:
image: ${PROJECT_PREFIX:?not set}-postgres:latest
build:
context: ./postgres
dockerfile: Dockerfile
container_name: postgres_db_${PROJECT_PREFIX:?not set}_${APP_ENV:?not set}
user: postgres
shm_size: 2g
networks:
- traefik-net
environment:
PGDATA: /var/lib/postgresql/data
volumes:
- ./fts-postgres.conf:/etc/postgresql/postgresql.conf
- ./.psqlrc:/var/lib/postgresql/.psqlrc
command: postgres -c "config_file=/etc/postgresql/postgresql.conf"
ports:
- ${DB_PORT:?not set}:5432
env_file:
- ./backend/.env.${APP_ENV:?not set}
restart: unless-stopped
logging: *default-logging
frontend:
image: ${PROJECT_PREFIX:?not set}-${APP_ENV:?not set}-frontend:latest
container_name: frontend_${PROJECT_PREFIX:?not set}_${APP_ENV:?not set}
networks:
- traefik-net
build:
context: ./frontend
dockerfile: Dockerfile.${APP_ENV:?not set}
args:
- "VITE_BACKEND_API=${BACKEND_API:?not set}"
- "VITE_BUILD_NUMBER=${BUILD_NUMBER:?not set}"
env_file:
- ./.env
depends_on:
- db
restart: unless-stopped
labels:
- traefik.enable=true
- traefik.http.routers.${PROJECT_PREFIX:?not set}-${APP_ENV:?not set}-frontend.rule=Host(`${DOMAIN:?not set}`)
- traefik.docker.network=traefik-net
- traefik.http.routers.${PROJECT_PREFIX:?not set}-${APP_ENV:?not set}-frontend.middlewares=test-compress
- traefik.http.middlewares.test-compress.compress=true
- traefik.http.routers.${PROJECT_PREFIX:?not set}-${APP_ENV:?not set}-frontend.entrypoints=websecure
- traefik.http.routers.${PROJECT_PREFIX:?not set}-${APP_ENV:?not set}-frontend.tls=true
- traefik.http.services.${PROJECT_PREFIX:?not set}-${APP_ENV:?not set}-frontend.loadbalancer.server.port=${FRONTEND_PORT:?not set}
logging: *default-logging
celery_worker:
image: ${PROJECT_PREFIX:?not set}-${APP_ENV:?not set}-backend:latest
container_name: celery_worker_1_${PROJECT_PREFIX:?not set}_${APP_ENV:?not set}
build:
context: ./backend
dockerfile: Dockerfile.${APP_ENV:?not set}
args:
- "CONTAINER_USER=${CONTAINER_USER:?not set}"
command: celery -A app.celery.worker:celery_app worker --loglevel INFO --logfile=./celery-${APP_ENV:?not set}.log --hostname=worker_1_${APP_ENV:?not set}@%h -Q myapp_queue_${APP_ENV:?not set} --task-events # -Q queue1,queue2 (although should work by default on all configured queues without this flag)
# --without-heartbeat --without-gossip --without-mingle (flower maybe wont work with these on?)
volumes:
- /backend/.pytest_cache/
- /backend/__pycache__/
- /backend/.mypy_cache/
- /backend/.venv/
- ./backend/.env.${APP_ENV:?not set}:/backend/.env.${APP_ENV:?not set}
- ./backend/:/backend/
networks:
- traefik-net
env_file:
- ./backend/.env.${APP_ENV:?not set}
environment:
APP_ENV: ${APP_ENV:?not set}
restart: always
logging: *default-logging
networks:
traefik-net:
name: traefik-net
external: true