diff --git a/.env.sample b/.env.sample index dd2fc867..41f9b317 100644 --- a/.env.sample +++ b/.env.sample @@ -4,19 +4,18 @@ PIXL_QUERY_TIMEOUT=10 CLI_RETRY_SECONDS=300 # PIXL PostgreSQL instance -PIXL_DB_HOST=postgres-exposed +PIXL_DB_HOST=postgres PIXL_DB_PORT=5432 PIXL_DB_NAME=pixl PIXL_DB_USER=pixl PIXL_DB_PASSWORD= SKIP_ALEMBIC=false -EXTERNAL_PIXL_DB=false # PIXL DB Postgres host CLI_PIXL_DB_HOST=localhost # Orthanc Raw PostgreSQL instance -ORTHANC_RAW_DB_HOST=postgres-exposed # change to correct host if PIXL DB is external postgres instance +ORTHANC_RAW_DB_HOST=postgres ORTHANC_RAW_DB_PORT=5432 ORTHANC_RAW_DB_NAME=pixl ORTHANC_RAW_DB_USER=pixl diff --git a/cli/README.md b/cli/README.md index de753ac1..f2002f13 100644 --- a/cli/README.md +++ b/cli/README.md @@ -29,34 +29,17 @@ See general pixl commands and subcommands with: pixl --help ``` -### Starting PIXL - For convenience, we provide the `pixl dc` command, which acts as a wrapper for `docker compose`, but takes care of some of the configuration for you. -**1) Default Start-up** +For example, ```bash pixl dc up ``` -**2) Start-up with External PIXL DB** - -PIXL can be set up so that the PIXL DB uses a separate postgres instance to Orthanc Raw, e.g. for production environment configurations. -Edit the .env file to enable this: - -```bash -EXTERNAL_PIXL_DB=true - -CLI_PIXL_DB_PORT=7001 - -ORTHANC_RAW_DB_HOST=postgres -``` - -Start-up PIXL: -```bash -pixl dc up -``` +will run `docker compose --project pixl_{pixl_env} up --wait --build --remove-orphans`, where `pixl_env` +is determined by the `ENV` environment variable. ### Configuration diff --git a/cli/src/pixl_cli/_docker_commands.py b/cli/src/pixl_cli/_docker_commands.py index 592606b8..ba9406be 100644 --- a/cli/src/pixl_cli/_docker_commands.py +++ b/cli/src/pixl_cli/_docker_commands.py @@ -34,27 +34,13 @@ def dc(args: tuple[str]) -> None: docker_args = list(args) if "up" in args: - docker_args = _parse_up_args(args) + docker_args = [*args, "--wait", "--build", "--remove-orphans"] if "down" in args: docker_args = _check_down_args(args) run_docker_compose(docker_args, working_dir=PIXL_ROOT) -def _parse_up_args(args: tuple[str, ...]) -> list: - """Check up args and set docker compose profile""" - args_list = list(args) - - up_index = args.index("up") - external_pixl_db_env = config("EXTERNAL_PIXL_DB", cast=bool) - args_list[up_index:up_index] = ( - ["--profile", "postgres"] if external_pixl_db_env else ["--profile", "postgres-exposed"] - ) - - args_list.extend(["--wait", "--build", "--remove-orphans"]) - return args_list - - def _check_down_args(args: tuple[str, ...]) -> list: """Stop all the PIXL services""" if config("ENV") == "prod" and "--volumes" in args: diff --git a/docker-compose.yml b/docker-compose.yml index 78c18de4..df27cf19 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -165,9 +165,8 @@ services: extra_hosts: - "host.docker.internal:host-gateway" depends_on: - postgres-exposed: + postgres: condition: service_healthy - required: false healthcheck: test: [ @@ -224,10 +223,6 @@ services: depends_on: postgres: condition: service_healthy - required: false - postgres-exposed: - condition: service_healthy - required: false orthanc-anon: condition: service_started healthcheck: @@ -295,10 +290,6 @@ services: condition: service_healthy postgres: condition: service_healthy - required: false - postgres-exposed: - condition: service_healthy - required: false hasher-api: condition: service_healthy ports: @@ -368,8 +359,7 @@ services: ################################################################################ # Data Stores - postgres-exposed: - profiles: [postgres-exposed] + postgres: build: context: . dockerfile: ./docker/postgres/Dockerfile @@ -397,30 +387,3 @@ services: restart: always networks: - pixl-net - postgres: - profiles: [postgres] - build: - context: . - dockerfile: ./docker/postgres/Dockerfile - args: - <<: *build-args-common - environment: - 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 - command: postgres -c 'config_file=/etc/postgresql/postgresql.conf' - volumes: - - type: volume - source: postgres-data - target: /var/lib/postgresql/data - healthcheck: - test: ["CMD", "pg_isready", "-U", "${ORTHANC_RAW_DB_USER}", "--dbname", "${ORTHANC_RAW_DB_NAME}"] - interval: 10s - timeout: 30s - retries: 5 - restart: always - networks: - - pixl-net diff --git a/test/.env b/test/.env index ba159a70..a8565840 100644 --- a/test/.env +++ b/test/.env @@ -8,13 +8,12 @@ PIXL_MAX_MESSAGES_IN_FLIGHT=5 TZ=Europe/London # PIXL PostgreSQL instance -PIXL_DB_HOST=postgres-pixl-db +PIXL_DB_HOST=postgres PIXL_DB_PORT=5432 PIXL_DB_NAME=pixl PIXL_DB_USER=pixl_db_username PIXL_DB_PASSWORD=pixl_db_password SKIP_ALEMBIC=false -EXTERNAL_PIXL_DB=true # PIXL DB Postgres host CLI_PIXL_DB_HOST=localhost @@ -23,8 +22,8 @@ CLI_PIXL_DB_HOST=localhost 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 +ORTHANC_RAW_DB_USER=pixl_db_username +ORTHANC_RAW_DB_PASSWORD=pixl_db_password # Exposed ports HASHER_API_PORT=7010 diff --git a/test/docker-compose.yml b/test/docker-compose.yml index 33078f49..f123709f 100644 --- a/test/docker-compose.yml +++ b/test/docker-compose.yml @@ -13,7 +13,6 @@ # limitations under the License. volumes: vna-qr-data: - postgres-pixl-db-data: networks: pixl-net: @@ -74,27 +73,3 @@ 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} - command: postgres -c 'config_file=/etc/postgresql/postgresql.conf' - volumes: - - type: volume - source: postgres-pixl-db-data - target: /var/lib/postgresql/data - ports: - - "${CLI_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 diff --git a/test/run-system-test.sh b/test/run-system-test.sh index 4e3cccd7..da7c71fd 100755 --- a/test/run-system-test.sh +++ b/test/run-system-test.sh @@ -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 --profile postgres -p system-test up --wait -d --build + docker compose --env-file test/.env --env-file test/.secrets.env -p system-test up --wait -d --build ) } teardown() { ( cd "${PACKAGE_DIR}" - docker compose -f docker-compose.yml -f test/docker-compose.yml --profile postgres -p system-test down --volumes + docker compose -f docker-compose.yml -f test/docker-compose.yml -p system-test down --volumes ) }