Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker Compose profile for external PIXL DB #595

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cli/src/pixl_cli/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
},
} # type: dict

if config("POSTGRES_EXTERNAL_PORT"):
SERVICE_SETTINGS["postgres"]["port"] = int(config("POSTGRES_EXTERNAL_PORT"))


class APIConfig:
"""API Configuration"""
Expand Down
30 changes: 30 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ volumes:
orthanc-anon-data:
orthanc-raw-data:
postgres-data:
external-pixl-db-data:
exports:
rabbitmq:

Expand Down Expand Up @@ -380,3 +381,32 @@ services:
restart: always
networks:
- pixl-net
postgres-external:
profiles: [external-pixl-db]
build:
context: .
dockerfile: ./docker/postgres/Dockerfile
args:
<<: *build-args-common
environment:
POSTGRES_USER: ${PIXL_DB_USER}
POSTGRES_PASSWORD: ${PIXL_DB_PASSWORD}
POSTGRES_DB: ${PIXL_DB_NAME}
PGTZ: ${TZ:-Europe/London}
env_file:
- ./docker/common.env
command: postgres -c 'config_file=/etc/postgresql/postgresql.conf'
volumes:
- type: volume
source: external-pixl-db-data
target: /var/lib/postgresql/data
ports:
- "${POSTGRES_EXTERNAL_PORT}:5432"
healthcheck:
test: ["CMD", "pg_isready", "-U", "${PIXL_DB_USER}", "--dbname", "${PIXL_DB_NAME}"]
interval: 10s
timeout: 30s
retries: 5
restart: always
networks:
- pixl-net
3 changes: 3 additions & 0 deletions test/.env
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ PIXL_DB_USER=pixl_db_username
PIXL_DB_PASSWORD=pixl_db_password
SKIP_ALEMBIC=false

# External postgres
POSTGRES_EXTERNAL_PORT=7011

# Exposed ports
HASHER_API_PORT=7010
POSTGRES_PORT=7001
Expand Down
4 changes: 2 additions & 2 deletions test/run-system-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ setup() {
# Warning: Requires to be run from the project root
(
cd "${PACKAGE_DIR}"
docker compose --env-file test/.env --env-file test/.secrets.env -p system-test up --wait -d --build
docker compose --env-file test/.env --env-file test/.secrets.env --profile external-pixl-db -p system-test up --wait -d --build
)
}

teardown() {
(
cd "${PACKAGE_DIR}"
docker compose -f docker-compose.yml -f test/docker-compose.yml -p system-test down --volumes
docker compose -f docker-compose.yml -f test/docker-compose.yml --profile external-pixl-db -p system-test down --volumes
)
}

Expand Down