... | @@ -54,7 +54,9 @@ docker-compose -f compose/sonador.yaml restart |
... | @@ -54,7 +54,9 @@ docker-compose -f compose/sonador.yaml restart |
|
#### Next Steps
|
|
#### Next Steps
|
|
The Imaging Development Environment provides a self-contained deployment of the platform with object storage, data streaming, and database systems; in addition to the Sonador Web Application and Orthanc Imaging Database services.
|
|
The Imaging Development Environment provides a self-contained deployment of the platform with object storage, data streaming, and database systems; in addition to the Sonador Web Application and Orthanc Imaging Database services.
|
|
|
|
|
|
* [Interacting With the Imaging Development Environment](dev.env-management) provides information on how to interact with and manage the environment, including details on how to initialize the database and create test users.
|
|
* **[Sonador Local Development Guide](env-local.setup-guide)**. Learn how to develop and test Sonador components using the container-based Oak-Tree Imaging Development Environment. This guide covers setting up source mounts, working with Django and Orthanc, managing migrations, handling static assets, and debugging services.
|
|
|
|
* [Interacting With the Oak-Tree Development Environment](dev.env-management) provides information on the organization of the Oak-Tree environment, how it is structured, and how to deploy components.
|
|
|
|
* **[Sonador Configuration](prod.config).** Sonador and Orthanc configuration reference.
|
|
* [Sonador Web Application Architecture](dev.archtiecture-sonador) describes the Sonador Web Application internal application, dependencies, and patterns.
|
|
* [Sonador Web Application Architecture](dev.archtiecture-sonador) describes the Sonador Web Application internal application, dependencies, and patterns.
|
|
* [Orthanc Sonador Plugin Architecture](dev.orthanc-plugin) looks at the Orthanc Sonador Cloud Plugin, how it builds on the [Orthanc Python Plugin](https://book.orthanc-server.com/plugins/python.html), extends the database schema using SQLAlchemy, and interfaces with the Sonador Web Application for [authentication, authorization, and user management](https://www.oak-tree.tech/blog/sonador-security-auth).
|
|
* [Orthanc Sonador Plugin Architecture](dev.orthanc-plugin) looks at the Orthanc Sonador Cloud Plugin, how it builds on the [Orthanc Python Plugin](https://book.orthanc-server.com/plugins/python.html), extends the database schema using SQLAlchemy, and interfaces with the Sonador Web Application for [authentication, authorization, and user management](https://www.oak-tree.tech/blog/sonador-security-auth).
|
|
|
|
|
... | @@ -141,213 +143,3 @@ docker build -t oaktreetech/orthanc-sonador -f Dockerfile.local . --no-cache \ |
... | @@ -141,213 +143,3 @@ docker build -t oaktreetech/orthanc-sonador -f Dockerfile.local . --no-cache \ |
|
```
|
|
```
|
|
|
|
|
|
**The Orthanc Plugin and CLI share Python dependencies. For that reason, the version of the [Sonador IO Library](https://code.oak-tree.tech/oak-tree/medical-imaging/sonador-client) for both should be the same.** |
|
**The Orthanc Plugin and CLI share Python dependencies. For that reason, the version of the [Sonador IO Library](https://code.oak-tree.tech/oak-tree/medical-imaging/sonador-client) for both should be the same.** |
|
|
|
|
|
|
|
|
|
|
|
|
|
## Making Changes to Sonador and Orthanc Source Code
|
|
|
|
It is recommended that Docker containers be used for Sonador web application and Orthanc Sonador Plugin development. The container images provide all dependencies and define and provide a consistent runtime.
|
|
|
|
|
|
|
|
Using Docker to develop Sonador and Orthanc involves:
|
|
|
|
|
|
|
|
1. Creating a clone of [Orthanc Sonador Plugin](https://code.oak-tree.tech/oak-tree/medical-imaging/orthanc-sonador) or [Sonador Web Application](https://code.oak-tree.tech/oak-tree/medical-imaging/sonador) source code on the developer's local machine. _It is recommended that the sources be placed in a directory within the root of the imaging environment repository called `src`._
|
|
|
|
2. (Orthanc) Creating a clone of supporting modules that might be needed within the source folder. _Because there is a great deal of code sharing and re-use among the components of the Sonador platform, it is convenient to have a clone of common dependencies that can be modified without having to rebuild packages between every code change._
|
|
|
|
3. Modifying the Docker Compose manifests so that the local source folder will be mounted to the correct location within the container.
|
|
|
|
4. Reload source files from the local source folder by restarting the Docker containers (via the Compose manifest for the application group). _Alternatively, it is possible to update/restart services by using [Compose Watch](https://docs.docker.com/compose/file-watch/)._
|
|
|
|
|
|
|
|
##### Step 0: Create `src` folder in Imaging Environment
|
|
|
|
For local development, it is suggested that you create a folder within a clone of the Sonador Imaging Environment called `src`. _The instructions and examples on this page will reference `src` as the base folder for Orthanc and Sonador clones._
|
|
|
|
|
|
|
|
```bash
|
|
|
|
# Run commands from the root of the Sonador Imaging Environment
|
|
|
|
|
|
|
|
# Create source folder (src)
|
|
|
|
mkdir src
|
|
|
|
```
|
|
|
|
|
|
|
|
Desired Imaging Environment repository layout:
|
|
|
|
|
|
|
|
```
|
|
|
|
|- compose: Docker Compose Manifests
|
|
|
|
|- config: Reference configuration files for environment
|
|
|
|
|- data: local folder mount used to persist data
|
|
|
|
|- docker: build files (Dockerfile) for optional Sonador components
|
|
|
|
|- docs: platform documentation
|
|
|
|
|- k8s: sample Kubernetes manifests
|
|
|
|
|- local: local folder structure for JupyterLab environment
|
|
|
|
|- src: source folder created above
|
|
|
|
|- <code repositories go here>
|
|
|
|
```
|
|
|
|
|
|
|
|
_Refer to [Interacting With the Imaging Development Environment](dev.env-management) for additional detail._
|
|
|
|
|
|
|
|
|
|
|
|
#### Sonador Web Application
|
|
|
|
The Sonador Web Application is a Django app written in Python. _Refer to [Sonador Web Application Architecture](dev.architecture-sonador) for architecture and additional detail._
|
|
|
|
|
|
|
|
##### Step 1: Create clone of Orthanc Sonador Plugin
|
|
|
|
Clone [Sonador Web Application](https://code.oak-tree.tech/oak-tree/medical-imaging/sonador) sources:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
# Run commands from root of the Sonador Imaging environment
|
|
|
|
|
|
|
|
# Change to src folder
|
|
|
|
cd src
|
|
|
|
|
|
|
|
# Clone sources to src
|
|
|
|
git clone https://code.oak-tree.tech/oak-tree/medical-imaging/sonador.git
|
|
|
|
```
|
|
|
|
|
|
|
|
Imaging Environment repository layout after cloning the Sonador source code:
|
|
|
|
|
|
|
|
```text
|
|
|
|
|- compose
|
|
|
|
| |- sonador.yaml: Sonador web application manifest
|
|
|
|
| ...
|
|
|
|
|
|
|
|
|
|- src
|
|
|
|
|- sonador
|
|
|
|
|- manage.py: Django management script
|
|
|
|
|- sonador: Django application folder
|
|
|
|
|- apps: Sonador application logic
|
|
|
|
|- lib: first-party "module" dependencies
|
|
|
|
|- config: sample deployment manifests and resource files
|
|
|
|
|- ...
|
|
|
|
```
|
|
|
|
|
|
|
|
##### Step 2: Modify Sonador Compose Manifest
|
|
|
|
After cloning the Sonador Web application sources to `src/sonador`, the `compose/sonador.yaml` manifest needs to be updated to mount the local source folder to the application folder inside of the container. _The example manifest below shows the required edits._
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
imaging:
|
|
|
|
image: oaktreetech/sonador:latest
|
|
|
|
ports:
|
|
|
|
- 8070:8070
|
|
|
|
volumes:
|
|
|
|
- ../config/sonador:/srv/www/sonador/config
|
|
|
|
# Add a source folder mount to enable local development
|
|
|
|
- ../src/sonador:/srv/www/sonador/sonador
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
##### Step 3: Restart Application Group
|
|
|
|
After adding the source mount, the Sonador application group needs to be restarted so that the web server will read from the local folder. _If the Sonador group is not running, you only need to run `docker-compose ... up` component of the command._
|
|
|
|
|
|
|
|
```bash
|
|
|
|
# Stop the Sonador application group. "down" is used rather than "restart"
|
|
|
|
# because a volume was added to the manifest.
|
|
|
|
docker-compose -f compose/sonador.yaml down
|
|
|
|
|
|
|
|
# Start the Sonador application group
|
|
|
|
docker-compose -f compose/sonador.yaml up -d
|
|
|
|
```
|
|
|
|
|
|
|
|
After making code changes, they can be reloaded by running `docker-compose ... restart`:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
docker-compose -f compose/sonador.yaml restart
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
#### Orthanc Sonador Plugin
|
|
|
|
The Orthanc Sonador Plugin provides integration with the Sonador web application and extends the medical imaging database with a number of useful API extensions. _Refer to [Orthanc Sonador Plugin Architecture](dev.orthanc-plugin) for architecture and additional detail._
|
|
|
|
|
|
|
|
##### Step 1: Create clone of Orthanc Sonador Plugin
|
|
|
|
Clone [Orthanc Sonador Plugin](https://code.oak-tree.tech/oak-tree/medical-imaging/orthanc-sonador) sources:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
git clone https://code.oak-tree.tech/oak-tree/medical-imaging/orthanc-sonador.git
|
|
|
|
```
|
|
|
|
|
|
|
|
Imaging Environment repository layout after cloning the Orthanc Sonador Repository source code:
|
|
|
|
|
|
|
|
```
|
|
|
|
|- compose
|
|
|
|
| |- pacs-secure.yaml: Orthanc application manifest
|
|
|
|
| ...
|
|
|
|
|
|
|
|
|
|- src
|
|
|
|
|- orthanc-sonador: root of the Orthanc Sonador Plugin repository
|
|
|
|
|- sonador-plugin.py: Sonador plugin entry script
|
|
|
|
|- sonador_orthanc: plugin logic
|
|
|
|
|- alembic: database migrations folder
|
|
|
|
|- maintenance: CLI scripts for maintenance operations
|
|
|
|
|- lua: integration scripts required by plugin
|
|
|
|
```
|
|
|
|
|
|
|
|
##### Step 2: Clone dependency modules (optional)
|
|
|
|
The Orthanc Sonador Plugin uses a number of other Sonador libraries as dependencies including the [Guru Client](https://code.oak-tree.tech/guru-labs/guru-client), [Sonador IO Client](https://code.oak-tree.tech/oak-tree/medical-imaging/sonador-client), and [Sonador/Orthanc Common Components](https://code.oak-tree.tech/oak-tree/medical-imaging/orthanc-sonador-common). When working with the Orthanc sources, it is convenient to have a local checkout of these libraries in the root of the plugin source folder in case changes need to be made. _Because Python will preferentially use a module that appears earlier in `sys.path` and that the runtime folder appears first, the local checkout will have priority over the packages installed in the container._
|
|
|
|
|
|
|
|
```bash
|
|
|
|
# Code should be run from the root of the Sonador Imaging environment
|
|
|
|
|
|
|
|
# Change to the source folder
|
|
|
|
cd src
|
|
|
|
|
|
|
|
# Clone Guru Client
|
|
|
|
git clone https://code.oak-tree.tech/guru-labs/guru-client.git guru
|
|
|
|
|
|
|
|
# Clone Sonador IO Client
|
|
|
|
git clone https://code.oak-tree.tech/oak-tree/medical-imaging/sonador-client.git sonador
|
|
|
|
|
|
|
|
# Clone Sonador/Orthanc Common Components
|
|
|
|
git clone https://code.oak-tree.tech/oak-tree/medical-imaging/orthanc-sonador-common.git \
|
|
|
|
sonador_orthanc_common
|
|
|
|
```
|
|
|
|
|
|
|
|
Imaging Environment repository layout after cloning dependency modules:
|
|
|
|
|
|
|
|
```
|
|
|
|
|- compose
|
|
|
|
| |- pacs-secure.yaml: Orthanc application manifest
|
|
|
|
| ...
|
|
|
|
|
|
|
|
|
|- src
|
|
|
|
|- orthanc-sonador: root of the Orthanc Sonador Plugin repository
|
|
|
|
|- sonador-plugin.py: Sonador plugin entry script
|
|
|
|
| ...
|
|
|
|
|- client: clone of Guru Client
|
|
|
|
|- sonador: clone of Sonador IO Client
|
|
|
|
|- sonador_orthanc_common: clone of common components
|
|
|
|
| ...
|
|
|
|
```
|
|
|
|
|
|
|
|
##### Step 3: Modify Orthanc Compose Manifest
|
|
|
|
After cloning the Orthanc and dependency modules to `src/orthanc-sonador`, the `compose/pacs-secure.yaml` manifest needs to be updated to mount the local source folder to the application folder inside of the container. _The example manifest below shows the required edits._
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
orthanc:
|
|
|
|
image: oaktreetech/orthanc-sonador:latest
|
|
|
|
ports:
|
|
|
|
- 4242:4242
|
|
|
|
- 8042:8042
|
|
|
|
volumes:
|
|
|
|
- ../config/orthanc/config.web-auth.json:/etc/orthanc/orthanc.json:ro
|
|
|
|
- ../config/orthanc/config.python.json:/etc/orthanc/orthanc-python.json:ro
|
|
|
|
# Add a source folder mount to enable local development
|
|
|
|
- ../src/orthanc-sonador:/opt/orthanc/orthanc-sonador
|
|
|
|
environment:
|
|
|
|
POSTGRESQL_PLUGIN_ENABLED: "true"
|
|
|
|
PYTHON_PLUGIN_ENABLED: "true"
|
|
|
|
DICOM_WEB_PLUGIN_ENABLED: "true"
|
|
|
|
AUTHORIZATION_PLUGIN_ENABLED: "true"
|
|
|
|
AWS_S3_STORAGE_PLUGIN_ENABLED: "false"
|
|
|
|
OHIF_PLUGIN_ENABLED: "true"
|
|
|
|
```
|
|
|
|
|
|
|
|
##### Step 4: Restart Application Group
|
|
|
|
After adding the source mount, the Orthanc application group needs to be restarted so that the server will read from the local folder. _If the Orthanc group is not running, you only need to run the `docker-compose ... up` component of the command._
|
|
|
|
|
|
|
|
```bash
|
|
|
|
# Stop the Orthanc application group. "down" is used rather than "restart"
|
|
|
|
# because a volume was added to the manifest.
|
|
|
|
docker-compose -f compose/pacs-secure.yaml down
|
|
|
|
|
|
|
|
# Start the Orthanc application group
|
|
|
|
docker-compose -f compose/pacs-secure.yaml up -d
|
|
|
|
```
|
|
|
|
|
|
|
|
After making code changes, they can be reloaded by running `docker-compose ... restart`:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
docker-compose -f compose/pacs-secure.yaml restart
|
|
|
|
``` |
|
|