-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.yml
130 lines (118 loc) · 4.18 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
129
version: "3.8"
x-python-service:
&python-service
build:
context: ./setup/python-service
args:
- PROJECT_PATH=$PROJECT_PATH
volumes:
- shared_venv:$PROJECT_PATH/.venv
- ./src:$PROJECT_PATH/src
- ./pyproject.toml:$PROJECT_PATH/pyproject.toml
- ./.env:$PROJECT_PATH/.env
- ./setup/python-service/alembic.ini:$PROJECT_PATH/setup/python-service/alembic.ini
- ./setup/tools:$PROJECT_PATH/setup/tools
- ./data/celery-beat:$PROJECT_PATH/data/celery-beat
restart: always
working_dir: $PROJECT_PATH
env_file: .env
services:
cli:
<<: *python-service
tty: true
build:
context: ./setup/cli
args:
- PROJECT_PATH=$PROJECT_PATH
command:
- /bin/bash
- -c
- sleep infinity
env-up:
<<: *python-service
restart: no
hostname: $ENV_UP_HOST
depends_on:
- postgres
- rabbitmq
command:
- /bin/bash
- -c
- |
source ./.venv/bin/activate &&
poetry install --no-root &&
cd src &&
alembic upgrade head &&
nc -k -l -p $ENV_UP_CONTAINER_PORT
# netcat keep (-k) listen (-l) port (-p)
dashboard-uvicorn:
<<: *python-service
depends_on:
- env-up
hostname: $DASHBOARD_HOST
ports:
- ${DASHBOARD_PORT}:${DASHBOARD_CONTAINER_PORT}
command:
- /bin/bash
- -c
- |
source ./.venv/bin/activate &&
source ./setup/tools/wait-for-socket.sh "$ENV_UP_HOST" "$ENV_UP_CONTAINER_PORT" &&
source ./setup/tools/wait-for-socket.sh "$POSTGRES_HOST" "$POSTGRES_CONTAINER_PORT" &&
source ./setup/tools/wait-for-command.sh uvicorn &&
cd src &&
uvicorn main:app --host 0.0.0.0 --port $DASHBOARD_CONTAINER_PORT
celery-beat:
<< : *python-service
depends_on:
- env-up
- celery-worker
command:
- /bin/bash
- -c
- |
source ./.venv/bin/activate &&
source ./setup/tools/wait-for-socket.sh "$ENV_UP_HOST" "$ENV_UP_CONTAINER_PORT" &&
source ./setup/tools/wait-for-socket.sh "$POSTGRES_HOST" "$POSTGRES_CONTAINER_PORT" &&
source ./setup/tools/wait-for-socket.sh "$RABBITMQ_HOST" "$RABBITMQ_CONTAINER_PORT" &&
source ./setup/tools/wait-for-command.sh celery &&
cd src &&
celery -A tasks beat --schedule $PROJECT_PATH/data/celery-beat/celerybeat-schedule.db
celery-worker:
<< : *python-service
depends_on:
- env-up
command:
- /bin/bash
- -c
- |
source ./.venv/bin/activate &&
source ./setup/tools/wait-for-socket.sh "$ENV_UP_HOST" "$ENV_UP_CONTAINER_PORT" &&
source ./setup/tools/wait-for-socket.sh "$POSTGRES_HOST" "$POSTGRES_CONTAINER_PORT" &&
source ./setup/tools/wait-for-socket.sh "$RABBITMQ_HOST" "$RABBITMQ_CONTAINER_PORT" &&
source ./setup/tools/wait-for-command.sh celery &&
cd src &&
celery -A tasks worker -O fair
rabbitmq:
image: rabbitmq:3.12.9-alpine
restart: always
hostname: $RABBITMQ_HOST
ports:
- ${RABBITMQ_PORT}:${RABBITMQ_CONTAINER_PORT}
volumes:
- ./data/rabbitmq:/var/lib/rabbitmq
- ./setup/rabbitmq/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf
env_file: .env
postgres:
image: postgres:16.1-alpine3.18
restart: always
hostname: $POSTGRES_HOST
ports:
- ${POSTGRES_PORT}:${POSTGRES_CONTAINER_PORT}
volumes:
- ./data/postgres:/var/lib/postgresql/data
- ./setup/postgres/postgresql.conf:/etc/postgresql/postgresql.conf
- ./setup/postgres/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
env_file: .env
volumes:
shared_venv: