83 lines
2.4 KiB
YAML
83 lines
2.4 KiB
YAML
services:
|
|
tests:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
command: >
|
|
sh -c "set -eu; pip install -r requirements-test.txt; python scripts/setup_database.py --ensure-database --ensure-role --ensure-schema --initialize-schema --run-migrations --seed-data --dry-run -v; python scripts/setup_database.py --ensure-database --ensure-role --ensure-schema --initialize-schema --run-migrations --seed-data -v; pytest $${PYTEST_TARGET:-tests/unit}"
|
|
environment:
|
|
DATABASE_DRIVER: postgresql
|
|
DATABASE_HOST: postgres
|
|
DATABASE_PORT: 5432
|
|
DATABASE_NAME: calminer_test
|
|
DATABASE_USER: calminer_test
|
|
DATABASE_PASSWORD: calminer_test_password
|
|
DATABASE_SCHEMA: public
|
|
DATABASE_SUPERUSER: postgres
|
|
DATABASE_SUPERUSER_PASSWORD: postgres
|
|
DATABASE_SUPERUSER_DB: postgres
|
|
DATABASE_URL: postgresql+psycopg2://calminer_test:calminer_test_password@postgres:5432/calminer_test
|
|
PYTEST_TARGET: tests/unit
|
|
PYTHONPATH: /app
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
volumes:
|
|
- .:/app
|
|
- pip_cache_test:/root/.cache/pip
|
|
networks:
|
|
- calminer_test
|
|
|
|
api:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
command: uvicorn main:app --host 0.0.0.0 --port 8000 --reload
|
|
environment:
|
|
DATABASE_DRIVER: postgresql
|
|
DATABASE_HOST: postgres
|
|
DATABASE_PORT: 5432
|
|
DATABASE_NAME: calminer_test
|
|
DATABASE_USER: calminer_test
|
|
DATABASE_PASSWORD: calminer_test_password
|
|
DATABASE_SCHEMA: public
|
|
DATABASE_URL: postgresql+psycopg2://calminer_test:calminer_test_password@postgres:5432/calminer_test
|
|
PYTHONPATH: /app
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
ports:
|
|
- "8001:8000"
|
|
networks:
|
|
- calminer_test
|
|
|
|
postgres:
|
|
image: postgres:16
|
|
restart: unless-stopped
|
|
environment:
|
|
POSTGRES_DB: calminer_test
|
|
POSTGRES_USER: postgres
|
|
POSTGRES_PASSWORD: postgres
|
|
LANG: en_US.UTF-8
|
|
LC_ALL: en_US.UTF-8
|
|
POSTGRES_INITDB_ARGS: --encoding=UTF8 --locale=en_US.UTF-8
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U postgres -d calminer_test"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
ports:
|
|
- "5433:5432"
|
|
volumes:
|
|
- pg_data_test:/var/lib/postgresql/data
|
|
networks:
|
|
- calminer_test
|
|
|
|
networks:
|
|
calminer_test:
|
|
driver: bridge
|
|
|
|
volumes:
|
|
pg_data_test:
|
|
pip_cache_test:
|