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

Merged
merged 42 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
2c69f1b
Updates orthanc-raw postgres config
tomaroberts Jan 13, 2025
8521c34
define ORTHANC_RAW_DB_ vars
p-j-smith Jan 14, 2025
65142aa
pass orthanc-raw-db vars to orthanc-raw
p-j-smith Jan 14, 2025
4c0849c
Separate POSTGRES_PORT into PIXL_DB_ and ORTHANC_RAW_DB_
tomaroberts Jan 14, 2025
1dc0640
Adds PIXL DB service to system-test
tomaroberts Jan 14, 2025
eaf193d
Unique PIXL_DB and ORTHANC_RAW_DB .env values
tomaroberts Jan 14, 2025
1d1bb24
Merge branch 'main' into tom/517-separate-dbs
tomaroberts Jan 14, 2025
502f27e
Removes env_file: - already inherited from root docker-compose.yml
tomaroberts Jan 20, 2025
3d4ad07
Moves POSTGRES_PIXL_DB_HOST var to more logical location
tomaroberts Jan 27, 2025
2307d94
Fixes port numbering so 7001 always used for Orthanc Raw
tomaroberts Jan 27, 2025
9ce2348
Update .sample.env (so aligns with test/.env)
tomaroberts Jan 27, 2025
2d30097
Update service name to more explicitly reflect external db
tomaroberts Jan 27, 2025
b8d5ec3
Adds comment about postgres ports
tomaroberts Jan 27, 2025
f50d431
Revert "Update service name to more explicitly reflect external db"
tomaroberts Jan 27, 2025
9611dec
Updates system-test conftest external PIXL DB port
tomaroberts Jan 27, 2025
2feae68
Merge branch 'main' into tom/517-separate-dbs
tomaroberts Jan 27, 2025
6139c2b
Adds missing env variable
tomaroberts Jan 27, 2025
e1380ec
Minor README tweak for clarity
tomaroberts Jan 27, 2025
325d938
Updates README with newly introduced env variables
tomaroberts Jan 27, 2025
91456c7
Introduces env var CLI_PIXL_DB_PORT
tomaroberts Jan 29, 2025
b07d4ed
Updates variable naming
tomaroberts Jan 29, 2025
661b614
Creates postgres / postgres-exposed services and assigns profiles
tomaroberts Jan 29, 2025
eb38215
Adds service depends_on logic
tomaroberts Jan 29, 2025
a846438
Adds --profile option to run system tests
tomaroberts Jan 29, 2025
4cb9ebd
Update .env.sample
tomaroberts Jan 29, 2025
ca6c1fc
Fixes system test PIXL DB port number
tomaroberts Jan 29, 2025
6e0dd33
Adds default `--profile postgres-exposed` option to pixl dc up
tomaroberts Jan 29, 2025
3b63662
Adds pixl dc up start-up explanation
tomaroberts Jan 29, 2025
06d8a13
Update .env.sample
tomaroberts Jan 29, 2025
25eeef6
linting bugfix: extra whitespace
tomaroberts Jan 30, 2025
0c6e356
Updates export-api depends_on interaction with postgres dbs
tomaroberts Jan 30, 2025
30a3e7f
Amends order of pixl dc up args so docker compose command works
tomaroberts Jan 30, 2025
d05829d
Resolve linting error
tomaroberts Jan 30, 2025
fe6ba69
Amends location of "up" in args_list
tomaroberts Feb 3, 2025
49388be
Linting fix
tomaroberts Feb 3, 2025
ba3f495
Removes old env vars
tomaroberts Feb 3, 2025
e193d47
Update README.md
tomaroberts Feb 3, 2025
93a7cde
Removes orthanc-anon postgres dependency
tomaroberts Feb 3, 2025
0f6a5dc
Set --profile in pixl dc up using env var
tomaroberts Feb 5, 2025
3d7a8f3
Update README.md
tomaroberts Feb 5, 2025
e1c6d7b
Amend env var parsing to use decouple
tomaroberts Feb 5, 2025
5dfad17
Merge branch 'main' into tom/517-separate-dbs
tomaroberts Feb 6, 2025
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: 2 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ 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 `postgres` if PIXL DB is external postgres instance
ORTHANC_RAW_DB_HOST=postgres-exposed # change to correct host if PIXL DB is external postgres instance
ORTHANC_RAW_DB_PORT=5432
ORTHANC_RAW_DB_NAME=pixl
ORTHANC_RAW_DB_USER=pixl
Expand Down
15 changes: 10 additions & 5 deletions cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,27 @@ For convenience, we provide the `pixl dc` command, which acts as a wrapper for `
but takes care of some of the configuration for you.

**1) Default Start-up**

```bash
pixl dc up
```
By default, `pixl dc up` runs with the option: `--profile postgres-exposed`. You should use this option if PIXL DB and Orthanc Raw
will share the same postgres instance. The `ORTHANC_RAW_DB_*` and `PIXL_DB_*` variables should have the same values, as seen in the
[default .env.sample](../.env.sample).

**2) Start-up with External PIXL DB**
Set the port number environment variable of your 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 --profile postgres
pixl dc up
```

### Configuration
Expand Down
15 changes: 11 additions & 4 deletions cli/src/pixl_cli/_docker_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import shutil
import subprocess
from pathlib import Path
Expand Down Expand Up @@ -42,11 +43,17 @@ def dc(args: tuple[str]) -> None:


def _parse_up_args(args: tuple[str, ...]) -> list:
"""Check up args and define default profile if not set"""
"""Check up args and set docker compose profile"""
args_list = list(args)
if "--profile" not in args:
up_index = args.index("up")
args_list[up_index:up_index] = ["--profile", "postgres-exposed"]

up_index = args.index("up")
external_pixl_db_env = os.environ.get("EXTERNAL_PIXL_DB", "false").lower()
tomaroberts marked this conversation as resolved.
Show resolved Hide resolved
args_list[up_index:up_index] = (
["--profile", "postgres"]
if external_pixl_db_env == "true"
else ["--profile", "postgres-exposed"]
)

args_list.extend(["--wait", "--build", "--remove-orphans"])
return args_list

Expand Down
1 change: 1 addition & 0 deletions test/.env
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ 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
Expand Down