-
Notifications
You must be signed in to change notification settings - Fork 4
/
docker-compose.testing.yaml
87 lines (87 loc) · 2.73 KB
/
docker-compose.testing.yaml
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
# Standalone docker-compose file for backend testing.
# Only spins up backend and database, not frontend.
# If the appropriate environment variables are set,
# it will create a worker and task broker. These aren't
# currently used, but they could be in the future.
version: "3.6"
x-backend:
&x-backend
image: ${SPARROW_BACKEND_IMAGE:-ghcr.io/earthcubegeochron/sparrow/backend}
# Make sure we get colorized terminal output
depends_on:
- db
- pg_api
environment:
- SPARROW_SECRET_KEY=test_secret_must_be_at_least_32_characters
- SPARROW_CACHE_DATABASE_MODELS
# Whether we should enable a worker pool for running tasks.
# If we don't, tasks must be run via the command line.
- SPARROW_TASK_WORKER=0
- SPARROW_TASK_BROKER=redis://broker:6379/0
- SPARROW_POSTGREST_URL=http://pg_api:3000
services:
backend:
<<: *x-backend
# We place the build context here rather than in the shared section
# so we don't build the backend image twice before starting tests.
build:
context: backend
cache_from:
- ${SPARROW_BACKEND_IMAGE:-ghcr.io/earthcubegeochron/sparrow/backend}
command: pytest /app/sparrow_tests --teardown
tty: true
volumes:
- pytest_cache:/run/.pytest_cache
profiles:
- main
db:
image: ghcr.io/earthcubegeochron/sparrow/database:2.0
ports:
# We could change this to port 54321 if we were cool with
# it conflicting with our default for Sparrow itself. This
# might make it harder to run tests, though.
- "${SPARROW_TEST_DATABASE_PORT:-54322}:5432"
expose:
- 5432
environment:
- POSTGRES_DB=sparrow_test
- PGUSER=postgres
- POSTGRES_HOST_AUTH_METHOD=trust
healthcheck:
test: ["CMD", "pg_isready", "-U", "postgres"]
interval: 10s
timeout: 5s
retries: 3
pg_api:
image: postgrest/postgrest:v11.2.0
environment:
- PGRST_DB_URI=postgresql://authenticator:@db:5432/sparrow_test
- PGRST_DB_SCHEMAS=sparrow_api
- PGRST_DB_ANON_ROLE=view_public
- PGRST_JWT_SECRET=test_secret_must_be_at_least_32_characters
- PGRST_DB_MAX_ROWS=100
- PGRST_SERVER_PORT=3000
expose:
- 3000
depends_on:
- db
ports:
- "${SPARROW_TEST_POSTGREST_PORT:-3001}:3000"
# Additional testing of broker-based functionality.
# Broker and worker are for testing task-based functionality
# We disable this for minimal tests, but we can test with the brokers
# with --profile=task-worker and the SPARROW_TASK_BROKER environment
# variable set.
broker:
image: redis:latest
profiles:
- task-worker
expose:
- 6379
worker:
<<: *x-backend
profiles:
- task-worker
command: /bin/run-worker
volumes:
pytest_cache: