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

Fixing broken OpenResty / Orthanc recipes and updating doc #2652

Merged
merged 5 commits into from
Jan 31, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
32 changes: 16 additions & 16 deletions docs/latest/deployment/recipes/nginx--image-archive.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ OHIF Viewer and its medical imaging data. This post covers one of many potential
setups that accomplish that. Please note, noticably absent is user account
control.

Do not use this recipe to host sensitive medical data on the open web. Depending
> **Do not use this recipe to host sensitive medical data on the open web!**

Depending
on your company's policies, this may be an appropriate setup on an internal
network when protected with a server's basic authentication. For a more robust
setup, check out our [user account control recipe](./user-account-control.md)
Expand All @@ -23,13 +25,13 @@ Our two biggest hurdles when hosting our image archive and web client are:

### Handling Web Requests

We mittigate our first issue by allowing [Nginx][nginx] to handle incoming web
We mitigate our first issue by allowing [Nginx][nginx] to handle incoming web
requests. Nginx is open source software for web serving, reverse proxying,
caching, and more. It's designed for maximum performance and stability --
allowing us to more reliably serve content than Orthanc's built-in server can.

More specifically, we accomplish this by using a
[`reverse proxy`](https://en.wikipedia.org/wiki/Reverse_proxy) to retrieve
[`reverse proxy`](https://en.wikipedia.org/wiki/Reverse_proxy) to retrieve
resources from our image archive (Orthanc), and when accessing its web admin.

> A reverse proxy is a type of proxy server that retrieves resources on behalf
Expand All @@ -38,7 +40,7 @@ resources from our image archive (Orthanc), and when accessing its web admin.

### CORS Issues

Cross-Origin Resource Sharing (CORS) is a mechanism that uses HTTP headers to
[Cross-Origin Resource Sharing][understanding-cors] (CORS) is a mechanism that uses HTTP headers to
tell a browser which web applications have permission to access selected
resources from a server at a different origin (domain, protocol, port). IE. By
default, a Web App located at `http://my-website.com` can't access resources
Expand All @@ -51,9 +53,6 @@ We can solve this one of two ways:

**This solution uses the first approach.**

You can read more about CORS in this Medium article: [Understanding
CORS][understanding-cors]

### Diagram

This setup allows us to create a setup similar to the one pictured below:
Expand All @@ -73,6 +72,8 @@ This setup allows us to create a setup similar to the one pictured below:
- Docker
- [Docker for Mac](https://docs.docker.com/docker-for-mac/)
- [Docker for Windows](https://docs.docker.com/docker-for-windows/)
- Node 16.x with optional Python and Visual Studio Build Tools ([webpack 4 has an issue](https://github.com/webpack/webpack/issues/14532) with Node 17.x)
- [Node.js](https://nodejs.org/en/download/)

_Not sure if you have `docker` installed already? Try running `docker --version`
in command prompt or terminal_
Expand All @@ -81,7 +82,7 @@ in command prompt or terminal_

_Spin Things Up_

- Navigate to `<project-root>/docker/OpenResty-Orthanc` in your shell
- Navigate to `./platform/viewer/.recipes/OpenResty-Orthanc` in your shell
- Run `docker-compose up`

_Upload Your First Study_
Expand All @@ -94,16 +95,16 @@ _Upload Your First Study_

### Troubleshooting

_Exit code 137_
#### Exit code 137

This means Docker ran out of memory. Open Docker Desktop, go to the `advanced`
tab, and increase the amount of Memory available.

_Cannot create container for service X_
#### Cannot create container for service X

Use this one with caution: `docker system prune`

_X is already running_
#### X is already running

Stop running all containers:

Expand All @@ -120,15 +121,12 @@ likely want to update:
#### OHIF Viewer

The OHIF Viewer's configuration is imported from a static `.js` file. The
configuration we use is set to a specific file when we build the viewer, and
configuration we use is set to [a specific file][config-ohif] when we build the viewer, and
determined by the env variable: `APP_CONFIG`. You can see where we set its value
in the `dockerfile` for this solution:

`ENV APP_CONFIG=config/docker_openresty-orthanc.js`

You can find the configuration we're using here:
`/public/config/docker_openresty-orthanc.js`

To rebuild the `webapp` image created by our `dockerfile` after updating the
Viewer's configuration, you can run:

Expand All @@ -137,7 +135,7 @@ Viewer's configuration, you can run:

#### Other

All other files are found in: `/docker/OpenResty-Orthanc/`
All other files in this directory include

| Service | Configuration | Docs |
| ----------------- | --------------------------------- | ------------------------------------------- |
Expand Down Expand Up @@ -236,6 +234,8 @@ members put together:
[orthanc-docs]: http://book.orthanc-server.com/users/configuration.html#configuration
[lua-resty-openidc-docs]: https://github.com/zmartzone/lua-resty-openidc
<!-- SRC -->

[config-ohif]: https://github.com/OHIF/Viewers/blob/master/platform/viewer/public/config/docker_openresty-orthanc.js
[dockerfile]: https://github.com/OHIF/Viewers/blob/master/platform/viewer/.recipes/OpenResty-Orthanc/dockerfile
[config-nginx]: https://github.com/OHIF/Viewers/blob/master/platform/viewer/.recipes/OpenResty-Orthanc/config/nginx.conf
[config-orthanc]: https://github.com/OHIF/Viewers/blob/master/platform/viewer/.recipes/OpenResty-Orthanc/config/orthanc.json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ services:
ohif_viewer:
build:
# Project root
context: ./../../
context: ./../../../../
# Relative to context
dockerfile: ./docker/OpenResty-Orthanc-Keycloak/dockerfile
dockerfile: ./platform/viewer/.recipes/OpenResty-Orthanc-Keycloak/dockerfile
image: webapp:latest
container_name: webapp
volumes:
Expand All @@ -35,7 +35,7 @@ services:
# TODO: Update to use Postgres
# https://github.com/mrts/docker-postgresql-multiple-databases
orthanc:
image: jodogne/orthanc-plugins:1.5.6
image: jodogne/orthanc-plugins:1.9.7
hostname: orthanc
container_name: orthanc
volumes:
Expand All @@ -47,7 +47,7 @@ services:

# LINK: https://hub.docker.com/r/jboss/keycloak
keycloak:
image: jboss/keycloak:6.0.1
image: jboss/keycloak:16.1.0
hostname: keycloak
container_name: keycloak
volumes:
Expand Down
10 changes: 6 additions & 4 deletions platform/viewer/.recipes/OpenResty-Orthanc-Keycloak/dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@


# Stage 1: Build the application
FROM node:11.2.0-slim as builder

# Needs to be pinned at 16.x for now because of https://github.com/webpack/webpack/issues/14532
FROM node:lts-slim as builder

RUN mkdir /usr/src/app
WORKDIR /usr/src/app
Expand All @@ -36,12 +38,12 @@ COPY yarn.lock /usr/src/app/yarn.lock

ADD . /usr/src/app/
RUN yarn install
RUN yarn run build:web
RUN yarn run build

# Stage 2: Bundle the built application into a Docker container
# which runs openresty (nginx) using Alpine Linux
# LINK: https://hub.docker.com/r/openresty/openresty
FROM openresty/openresty:1.15.8.1rc1-0-alpine-fat
FROM openresty/openresty:1.19.9.1-4-alpine-fat

RUN mkdir /var/log/nginx
RUN apk add --no-cache openssl
Expand All @@ -60,6 +62,6 @@ RUN luarocks install lua-resty-openidc
RUN luarocks install luacrypto

# Copy build output to image
COPY --from=builder /usr/src/app/build /var/www/html
COPY --from=builder /usr/src/app/platform/viewer/dist /var/www/html

ENTRYPOINT ["/usr/local/openresty/nginx/sbin/nginx", "-g", "daemon off;"]
6 changes: 3 additions & 3 deletions platform/viewer/.recipes/OpenResty-Orthanc/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ services:
ohif_viewer:
build:
# Project root
context: ./../../
context: ./../../../../
# Relative to context
dockerfile: ./docker/OpenResty-Orthanc/dockerfile
dockerfile: ./platform/viewer/.recipes/OpenResty-Orthanc/dockerfile
image: webapp:latest
container_name: webapp
volumes:
Expand All @@ -34,7 +34,7 @@ services:
# TODO: Update to use Postgres
# https://github.com/mrts/docker-postgresql-multiple-databases
orthanc:
image: jodogne/orthanc-plugins:1.5.6
image: jodogne/orthanc-plugins:1.9.7
hostname: orthanc
container_name: orthanc
volumes:
Expand Down
10 changes: 6 additions & 4 deletions platform/viewer/.recipes/OpenResty-Orthanc/dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@


# Stage 1: Build the application
FROM node:11.2.0-slim as builder

# Needs to be pinned at 16.x for now because of https://github.com/webpack/webpack/issues/14532
FROM node:lts-slim as builder

RUN mkdir /usr/src/app
WORKDIR /usr/src/app
Expand All @@ -36,12 +38,12 @@ COPY yarn.lock /usr/src/app/yarn.lock

ADD . /usr/src/app/
RUN yarn install
RUN yarn run build:web
RUN yarn run build

# Stage 2: Bundle the built application into a Docker container
# which runs openresty (nginx) using Alpine Linux
# LINK: https://hub.docker.com/r/openresty/openresty
FROM openresty/openresty:1.15.8.1rc1-0-alpine-fat
FROM openresty/openresty:1.19.9.1-4-alpine-fat

RUN mkdir /var/log/nginx
RUN apk add --no-cache openssl
Expand All @@ -60,6 +62,6 @@ RUN luarocks install lua-resty-openidc
RUN luarocks install luacrypto

# Copy build output to image
COPY --from=builder /usr/src/app/build /var/www/html
COPY --from=builder /usr/src/app/platform/viewer/dist /var/www/html

ENTRYPOINT ["/usr/local/openresty/nginx/sbin/nginx", "-g", "daemon off;"]