PIP modules ? for an osimis Docker Build and some questions about configuration.

I just started using the osmis/orthanc image after developing from compiled source initially, so please excuse my ignorance. I do have a modified .yaml file that I am using based on the … orthanc-setup-samples/docker/all-usages/docker-compose.yml. What I have so far is shown below at the bottom of the thread. It seems to be partially working, although I need to work with them a bit more. I just backed up the original and modified a copy after cloning the orthanc-setup-samples folder to my computer.

  1. First, it appears that you can use both the ENV variables and inline .json in combination if you want to and Docker creates a config file from that ?
  2. After I start up Docker, it does recognize the StorageDirectory in the home directory of my .yaml file, and it does create and delete the image files in the Storage directory in that root folder.
  3. However, the Postgres database is not mapped to my PostGresDB folder. I don’t know how to do that and if it possible or advisable, but I made an attempt in the .yaml there.
  4. When I uncomment:
    #PYTHON_PLUGIN_ENABLED: “true”
    #ORTHANC__PYTHON_SCRIPT: “/usr/share/orthanc/test.py”
    #ORTHANC__PYTHON_VERBOSE: “true”

it loads the python plug-in and then crashes, but it does read the python script located in the bound folder on my system, which is good, but it crashes because I have about 4 PIP modules that are not installed my default. I know how to do that, i.e. sudo python3 -m pip install {module}, so I think I just need a way to install the ones that I need when the container is built and before Orthanc starts up.

I did find this: https://bitbucket.org/osimis/orthanc-setup-samples/src/master/docker/python/orthanc/

which includes:

FROM osimis/orthanc
RUN pip3 install pydicom
RUN mkdir /python
COPY * /python/

and some other stuff

so it looks like I just need a way to incorporate that info my build, and if I want to do some other stuff I can just modify that Docker file.

I have been off the forum a bit, so I was hoping someone has an answer to what are probably questions really for someone facile with Docker. So,

1. How advisable is it to have the StorageDirectory outside of the Docker container ?

2. Is it possible to have the Database also stored on the host file system like for (1), and how advisable is that ?

3. I do not have much experience with Docker yet. If it is better to just keep those in the container and if it can be persistent that might be OK, but I’d still want a way to back all of that up. It seems that it might in some ways easier to them on the host.

4. How can I add PIP modules during the build so that I can use my python script? That otherwise seems to be working. It seems like if I could just have a supplemental Docker file for the things that I want to add to the base image, that would work.

Thanks.

docker-compose.yml, modified from the original

#docker-compose up --build

version: “3.3”
services:

orthanc-file-in-env-var:

image: osimis/orthanc
depends_on: [index-db]

ports: [“4242:4242”, “8042:8042”]
restart: ‘no’ # no, always, on-failure, unless-stopped
environment:

POSTGRES is in Config file

WORKLISTS is in Config file

VERBOSE_ENABLED: “true”
VERBOSE_STARTUP: “true”
#AUTHORIZATION_PLUGIN_ENABLED:: “false”
CONNECTIVITY_CHECKS_PLUGIN_ENABLED: “true”
DICOM_WEB_PLUGIN_ENABLED: “true”

GDCM_PLUGIN_ENABLED: “true” #on by default

#PYTHON_PLUGIN_ENABLED: “true”
#ORTHANC__PYTHON_SCRIPT: “/usr/share/orthanc/test.py”
#ORTHANC__PYTHON_VERBOSE: “true”
SERVE_FOLDERS_PLUGIN_ENABLED: “false”

VIEWERS

ORTHANC_WEB_VIEWER_PLUGIN_ENABLED: “false”
#OSIMIS VIEWER
OSIMIS_WEB_VIEWER1_PLUGIN_ENABLED: “true”

STONE WEB VIEWER

STONE_WEB_VIEWER_PLUGIN_ENABLED: “true”

StoneViewer configurations

ORTHANC__STONE_WEB_VIEWER__DATE_FORMAT: “DD/MM/YYYY”
OSIMIS_CLOUD_PLUGIN_ENABLED: “true”

ORTHANC_JSON: |
{
“Name”: “CAYMANMED”,
“PostgreSQL” : {
“Host”: “index-db”,
“Password”: “pg-password”
},
“RegisteredUsers”: {
“demo”: “demo”
},
“RemoteAccessAllowed”: true,
“AuthenticationEnabled” : false,

“Worklists”: {
“Enable”: true,
“Database”: “/var/lib/orthanc/worklists”
}
}
volumes:

  • type: bind
    source: ./python/test.py
    target: /usr/share/orthanc/test.py
  • type: bind
    source: ./MWLFiles
    target: /var/lib/orthanc/worklists
  • type: bind
    source: ./StorageDirectory
    target: /var/lib/orthanc/db/
  • type: bind
    source: ./PostGresDB
    target: /orthanc-index/

POSTGRES

index-db:
image: postgres
restart: unless-stopped
volumes: [“orthanc-index:/var/lib/postgresql/data:Z”]

volumes:

orthanc-index:

Hi Stephen,

The Osimis sample is the best place to see how this work. You are right, to use a PIP module, you will need a custom Dockerfile. You can tell Docker to build this custom Dockerfile by changing ‘image: osimis/orthanc’ to ‘build: path/to/dockerfile’. See https://bitbucket.org/osimis/orthanc-setup-samples/src/4ab8b608a53bbb30d8abe83bb3ea8527d95eca9f/docker/python/docker-compose.yml#lines-5 for an example. Line 5 of this docker-compose.yml file, tells docker to build the container in the ./orthanc directory. Inside this directory, there is a Dockerfile that extends the osimis/orthanc image, uses pip to install the dependancies and copies the python scripts into the container.

HTH.

James

James,

HTH → That helps. I used the tls-with-nginx example instead. That is a bit more complicated but I think I’m on my way. It is already setup to copy

PIP modules get installed. Just need to add my python scripts, which I think I can handle. Also, a few things to configure with the NGINX proxy. Looks like I can just replace the nginx-crt.pem, nginx-key.pem and ca-crt.pem files with my own “official ones”.

Step 4/10 : COPY orthanc.json /etc/orthanc/
—> Using cache
—> 1a2f9dac99e9
Step 5/10 : RUN pip3 install pydicom
—> Using cache
—> 96b3e9dccc69
Step 6/10 : RUN pip3 install pdfkit
—> Using cache
—> eb85080bb8f0
Step 7/10 : RUN pip3 install hl7
—> Using cache
—> 5a78389acdf1
Step 8/10 : RUN pip3 install wkhtmltopdf
—> Using cache
—> 333ce08ef42c
Step 9/10 : RUN mkdir /python
—> Using cache
—> 3a0c1c79c627
Step 10/10 : COPY * /python/
—> Using cache
—> c1ce42106e02

Successfully built c1ce42106e02
Successfully tagged tls-with-nginx_orthanc-a:latest
Building nginx
Step 1/2 : FROM nginx:1.11-alpine
—> bedece1f06cc
Step 2/2 : COPY default.conf /etc/nginx/conf.d/default.conf
—> Using cache
—> cf76e961282a