-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
134 lines (123 loc) · 3.14 KB
/
docker-compose.yml
File metadata and controls
134 lines (123 loc) · 3.14 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
# YAML anchors for common service configurations
x-app-base: &app-base
build:
context: .
dockerfile: Dockerfile
volumes:
- ./app:/app/app
- ./tests:/app/tests
- ./.env:/app/.env
x-db-environment: &db-environment
DATABASE_URL: postgresql+asyncpg://captain:defiant@db:5432/captains_log
services:
db:
image: pgvector/pgvector:pg16
environment:
POSTGRES_USER: captain
POSTGRES_PASSWORD: defiant
POSTGRES_DB: captains_log
volumes:
- ./.data/pg_data:/var/lib/postgresql/data
ports:
- "${PORT_OFFSET:-0}5433:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U captain -d captains_log"]
interval: 5s
timeout: 5s
retries: 5
migrate:
<<: *app-base
volumes:
- ./app:/app/app
- ./alembic:/app/alembic
- ./alembic.ini:/app/alembic.ini
- ./.env:/app/.env
environment:
<<: *db-environment
depends_on:
db:
condition: service_healthy
command: alembic upgrade head
make_migrations:
<<: *app-base
volumes:
- ./app:/app/app
- ./alembic:/app/alembic
- ./alembic.ini:/app/alembic.ini
- ./.env:/app/.env
environment:
<<: *db-environment
depends_on:
db:
condition: service_healthy
command: alembic revision --autogenerate -m "Auto-generated migration"
profiles:
- tools
app:
<<: *app-base
environment:
<<: *db-environment
# Pass AWS session credentials from host
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
AWS_SESSION_TOKEN: ${AWS_SESSION_TOKEN}
AWS_REGION: ${AWS_REGION:-us-east-2}
AWS_DEFAULT_REGION: ${AWS_DEFAULT_REGION:-us-east-2}
depends_on:
migrate:
condition: service_completed_successfully
command: uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
ports:
- "${PORT_OFFSET:-0}8082:8000"
test:
<<: *app-base
environment:
<<: *db-environment
depends_on:
- db
command: bash -c "cd /app && PYTHONPATH=/app python -m pytest tests/ -v --tb=short --asyncio-mode=auto"
profiles:
- test
lint:
<<: *app-base
volumes:
- ./app:/app/app
- ./tests:/app/tests
- ./.prospector.yaml:/app/.prospector.yaml
command: prospector --profile .prospector.yaml
profiles:
- lint
format:
<<: *app-base
volumes:
- ./app:/app/app
- ./tests:/app/tests
- ./pyproject.toml:/app/pyproject.toml
command: black app/ tests/
profiles:
- format
nginx:
image: nginx:alpine
ports:
- "${PORT_OFFSET:-0}81:80"
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf
depends_on:
- app
playwright:
build:
context: .
dockerfile: Dockerfile.playwright
volumes:
- ./app:/app/app
- ./tests:/app/tests
- ./.env:/app/.env
environment:
DATABASE_URL: postgresql+asyncpg://captain:defiant@db:5432/captains_log
BASE_URL: http://nginx
depends_on:
- nginx
- db
command: pytest tests/e2e/ -v --browser chromium --base-url http://nginx
profiles:
- e2e