-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
134 lines (123 loc) · 3.36 KB
/
Copy pathdocker-compose.yml
File metadata and controls
134 lines (123 loc) · 3.36 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
volumes:
pg-db-data:
driver: local
pg-admin-data:
driver: local
networks:
pg-network:
driver: bridge
services:
# Production build base
base: &base
hostname: app
image: python-template:production
build:
context: .
dockerfile: Dockerfile
environment: &env
ENV: "dev"
LOG_LEVEL: "DEBUG"
DB_URL: "postgresql+asyncpg://postgres:passwd@pg-db:5432/app_dev"
PYTHONDONTWRITEBYTECODE: 1
depends_on:
pg-db:
condition: service_healthy
# Development build base (with dev dependencies and hot reload)
dev-base: &dev-base
hostname: app-dev
image: python-template:development
build:
context: .
dockerfile: Dockerfile.dev
working_dir: /app
volumes:
- ./:/app
environment: *env
depends_on:
pg-db:
condition: service_healthy
# Production app (optimized image)
app:
<<: *base
command: /bin/sh -c "alembic upgrade head && python -m app"
ports:
- "8080:8080"
networks:
- pg-network
# Development app (with hot reload)
app-dev:
<<: *dev-base
command: /bin/sh -c "alembic upgrade head && python -m app"
ports:
- "8080:8080"
networks:
- pg-network
# Testing services (use dev image with all dependencies)
tests:
<<: *dev-base
command: /bin/sh -c "pytest tests/"
environment:
<<: *env
ENV: "test"
DB_URL: "postgresql+asyncpg://postgres:passwd@pg-db:5432/app_test"
networks:
- pg-network
# Watch mode services (use dev image for fast feedback)
watch:
<<: *dev-base
command: /bin/sh -c "ptw -w -c tests/"
environment:
<<: *env
ENV: "test"
DB_URL: "postgresql+asyncpg://postgres:passwd@pg-db:5432/app_test"
networks:
- pg-network
watch-unit:
<<: *dev-base
command: /bin/sh -c "ptw -w -c tests/unit/"
environment:
<<: *env
ENV: "test"
DB_URL: "postgresql+asyncpg://postgres:passwd@pg-db:5432/app_test"
networks:
- pg-network
watch-integration:
<<: *dev-base
command: /bin/sh -c "ptw -w -c tests/integration/"
environment:
<<: *env
ENV: "test"
DB_URL: "postgresql+asyncpg://postgres:passwd@pg-db:5432/app_test"
networks:
- pg-network
pg-db:
hostname: pg-db
image: postgres:15.2-alpine
environment:
POSTGRES_PASSWORD: "passwd"
ports:
- "5432:5432"
volumes:
- ./scripts/pg:/docker-entrypoint-initdb.d
- pg-db-data:/var/lib/postgresql/data
networks:
- pg-network
healthcheck:
test: ["CMD-SHELL", "pg_isready"]
interval: 5s
timeout: 3s
retries: 5
pg-admin:
hostname: pg-admin
image: dpage/pgadmin4
environment:
PGADMIN_DEFAULT_EMAIL: "local@dev.com"
PGADMIN_DEFAULT_PASSWORD: "passwd"
ports:
- "6001:80"
volumes:
- pg-admin-data:/var/lib/pgadmin
depends_on:
- pg-db
networks:
- pg-network