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

Enables PIXL DB to operate as a service separate from Orthanc Raw #593

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 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
10 changes: 9 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,17 @@ PIXL_DB_USER=pixl
PIXL_DB_PASSWORD=
SKIP_ALEMBIC=false

# Orthanc Raw PostgreSQL instance
ORTHANC_RAW_DB_HOST=postgres
ORTHANC_RAW_DB_PORT=5432
ORTHANC_RAW_DB_NAME=pixl
ORTHANC_RAW_DB_USER=pixl
ORTHANC_RAW_DB_PASSWORD=

# Exposed ports
HASHER_API_PORT=
POSTGRES_PORT=
POSTGRES_PIXL_DB_PORT=
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably worth moving this elsewhere in the file as this port isn't necessarily what we're exposing it to (we can override this in the system test files, where we are exposing it).

POSTGRES_ORTHANC_RAW_DB_PORT=
ORTHANC_ANON_DICOM_PORT=
ORTHANC_ANON_WEB_PORT=
ORTHANC_RAW_DICOM_PORT=
Expand Down
4 changes: 2 additions & 2 deletions cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ RABBITMQ_PORT=7008
RABBITMQ_USERNAME=rabbitmq_username
RABBITMQ_PASSWORD=rabbitmq_password

POSTGRES_HOST=localhost
POSTGRES_PORT=7001
POSTGRES_PIXL_DB_HOST=localhost
POSTGRES_PIXL_DB_PORT=7001
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about EXTERNAL_PIXL_DB_HOST or CLI_PIXL_DB_HOST etc?

PIXL_DB_USER=pixl_db_username
PIXL_DB_PASSWORD=pixl_db_password
PIXL_DB_NAME=pixl
Expand Down
4 changes: 2 additions & 2 deletions cli/src/pixl_cli/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"password": config("RABBITMQ_PASSWORD"),
},
"postgres": {
"host": config("POSTGRES_HOST"),
"port": int(config("POSTGRES_PORT")),
"host": config("POSTGRES_PIXL_DB_HOST"),
"port": int(config("POSTGRES_PIXL_DB_PORT")),
"username": config("PIXL_DB_USER"),
"password": config("PIXL_DB_PASSWORD"),
"database": config("PIXL_DB_NAME"),
Expand Down
19 changes: 13 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ x-pixl-db: &pixl-db
PIXL_DB_PASSWORD: ${PIXL_DB_PASSWORD}
PIXL_DB_NAME: ${PIXL_DB_NAME}

x-orthanc-raw-db: &orthanc-raw-db
ORTHANC_RAW_DB_HOST: ${ORTHANC_RAW_DB_HOST}
ORTHANC_RAW_DB_PORT: ${ORTHANC_RAW_DB_PORT}
ORTHANC_RAW_DB_USER: ${ORTHANC_RAW_DB_USER}
ORTHANC_RAW_DB_PASSWORD: ${ORTHANC_RAW_DB_PASSWORD}
ORTHANC_RAW_DB_NAME: ${ORTHANC_RAW_DB_NAME}

x-azure-keyvault: &azure-keyvault
AZURE_CLIENT_ID: ${EXPORT_AZ_CLIENT_ID}
AZURE_CLIENT_SECRET: ${EXPORT_AZ_CLIENT_PASSWORD}
Expand Down Expand Up @@ -186,7 +193,7 @@ services:
platform: linux/amd64
command: /run/secrets
environment:
<<: [*pixl-db, *proxy-common, *pixl-common-env]
<<: [*orthanc-raw-db, *proxy-common, *pixl-common-env]
ORTHANC_NAME: "PIXL: Raw"
ORTHANC_USERNAME: ${ORTHANC_RAW_USERNAME}
ORTHANC_PASSWORD: ${ORTHANC_RAW_PASSWORD}
Expand Down Expand Up @@ -359,9 +366,9 @@ services:
args:
<<: *build-args-common
environment:
POSTGRES_USER: ${PIXL_DB_USER}
POSTGRES_PASSWORD: ${PIXL_DB_PASSWORD}
POSTGRES_DB: ${PIXL_DB_NAME}
POSTGRES_USER: ${ORTHANC_RAW_DB_USER}
POSTGRES_PASSWORD: ${ORTHANC_RAW_DB_PASSWORD}
POSTGRES_DB: ${ORTHANC_RAW_DB_NAME}
PGTZ: ${TZ:-Europe/London}
env_file:
- ./docker/common.env
Expand All @@ -371,9 +378,9 @@ services:
source: postgres-data
target: /var/lib/postgresql/data
ports:
- "${POSTGRES_PORT}:5432"
- "${POSTGRES_ORTHANC_RAW_DB_PORT}:5432"
healthcheck:
test: ["CMD", "pg_isready", "-U", "${PIXL_DB_USER}", "--dbname", "${PIXL_DB_NAME}"]
test: ["CMD", "pg_isready", "-U", "${ORTHANC_RAW_DB_USER}", "--dbname", "${ORTHANC_RAW_DB_NAME}"]
interval: 10s
timeout: 30s
retries: 5
Expand Down
2 changes: 1 addition & 1 deletion orthanc/orthanc-raw/config/postgres.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"PostgreSQL" : {
"EnableIndex" : true,
"EnableStorage" : false,
"ConnectionUri" : "postgresql://${PIXL_DB_USER}:${PIXL_DB_PASSWORD}@${PIXL_DB_HOST}:${PIXL_DB_PORT}/${PIXL_DB_NAME}",
"ConnectionUri" : "postgresql://${ORTHANC_RAW_DB_USER}:${ORTHANC_RAW_DB_PASSWORD}@${ORTHANC_RAW_DB_HOST}:${ORTHANC_RAW_DB_PORT}/${ORTHANC_RAW_DB_NAME}",
"Lock" : true
}
}
14 changes: 11 additions & 3 deletions test/.env
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,24 @@ PIXL_MAX_MESSAGES_IN_FLIGHT=5
TZ=Europe/London

# PIXL PostgreSQL instance
PIXL_DB_HOST=postgres
PIXL_DB_HOST=postgres-pixl-db
PIXL_DB_PORT=5432
PIXL_DB_NAME=pixl
PIXL_DB_USER=pixl_db_username
PIXL_DB_PASSWORD=pixl_db_password
SKIP_ALEMBIC=false

# Orthanc Raw PostgreSQL instance
ORTHANC_RAW_DB_HOST=postgres
ORTHANC_RAW_DB_PORT=5432
ORTHANC_RAW_DB_NAME=pixl
ORTHANC_RAW_DB_USER=orthanc_raw_db_username
ORTHANC_RAW_DB_PASSWORD=orthanc_raw_db_password

# Exposed ports
HASHER_API_PORT=7010
POSTGRES_PORT=7001
POSTGRES_PIXL_DB_PORT=7001
POSTGRES_ORTHANC_RAW_DB_PORT=7011
ORTHANC_ANON_DICOM_PORT=7002
ORTHANC_ANON_WEB_PORT=7003
ORTHANC_RAW_DICOM_PORT=7004
Expand All @@ -29,7 +37,7 @@ RABBITMQ_ADMIN_PORT=7009
FTP_PORT=20021

# PIXL Export API
POSTGRES_HOST=localhost
POSTGRES_PIXL_DB_HOST=localhost
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it wasn't you but should this move? Feels like its not to do with the export api

PIXL_EXPORT_API_HOST=localhost

# PIXL Imaging API
Expand Down
27 changes: 27 additions & 0 deletions test/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.
volumes:
vna-qr-data:
postgres-pixl-db-data:

networks:
pixl-net:
Expand Down Expand Up @@ -73,3 +74,29 @@ services:
retries: 2
interval: 3s
timeout: 2s
postgres-pixl-db:
build:
context: ../
dockerfile: ./docker/postgres/Dockerfile
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
Copy link
Contributor

@stefpiatek stefpiatek Jan 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imagine you've seen but from CI: /home/runner/work/PIXL/docker/common.env: no such file or directory. I'm guessing because we've set the context to be ../ then it can just be ./docker...

command: postgres -c 'config_file=/etc/postgresql/postgresql.conf'
volumes:
- type: volume
source: postgres-pixl-db-data
target: /var/lib/postgresql/data
ports:
- "${POSTGRES_PIXL_DB_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
Loading