Skip to content

Commit

Permalink
Add PUBLIC_URL and other build args docs
Browse files Browse the repository at this point in the history
  • Loading branch information
wayfarer3130 committed Dec 20, 2024
1 parent 8e6e505 commit 4ebb977
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions platform/docs/docs/deployment/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The machine on which to build and run the Docker container must have:
## Building the Docker Image

:::info
In this tutorial, we will build the Docker image for the OHIF Viewer and OHIF server as defined in the `default.js` config. If you need a custom build, you can modify the configuration file to include your data sources and then build the Docker image. For more information on data sources, see [here](../platform/extensions/modules/data-source.md).
In this tutorial, we will build the Docker image for the OHIF Viewer and OHIF server as defined in the `default.js` config. If you need a custom build, you can set build arguments to specify your data sources. For more information on data sources, see [here](../platform/extensions/modules/data-source.md).

Below we show how to point the Docker image to a custom configuration file.
:::
Expand All @@ -42,6 +42,16 @@ The docker image can be built from a terminal window as such:
Building a Docker image comes in handy when OHIF has been customized (e.g. with custom extensions, modes, hanging protocols, etc.). For convenience, there are basic OHIF images built in Docker Hub. Find the latest [release](https://hub.docker.com/r/ohif/app/tags?page=1&name=latest) and [dev](https://hub.docker.com/r/ohif/app/tags?page=1&name=beta) images all in Docker Hub.
:::

### Available Build Arguments
The available build arguments to set defaults are `APP_CONFIG`, `PUBLIC_URL` and `PORT`. They are set with the `--build-arg` command.

Examples:

* `docker build . --build-arg PUBLIC_URL=/ohif/`
* `docker build . --build-arg APP_CONFIG=config/kheops.js`
* `docker build . --build-arg PORT=6000`
* `docker build . --build-arg PUBLIC_URL=/ohif/ --build-arg APP_CONFIG=config/kheops.js --build-arg PORT=6000`

## Running the Docker Container
Once the Docker image has been built, it can be run as a container from the command line as in the block below. Note that the last argument to the command is the name of the Docker image and the table below describes the other arguments.

Expand Down Expand Up @@ -76,12 +86,18 @@ The Dockerfile and entry point use the `{PORT}` environment variable as the port
docker run -d -e PORT=8080 -p 3000:8080/tcp --name ohif-viewer-container ohif-viewer-image
```

The default port can also be configured during build with:
```sh
docker build . --build-arg PORT=8080
```

### Specifying the OHIF config File

There are two approaches for specifying the OHIF configuration file for a Docker container:
There are three approaches for specifying the OHIF configuration file for a Docker container:

- [Volume Mounting](#volume-mounting)
- [Environment Variable](#environment-variable)
- [Build Default](#build-default)

#### Volume Mounting

Expand Down Expand Up @@ -119,6 +135,10 @@ As an alternative to the `cat` command, convert the configuration file to a sing
If both the [volume mounting method](#volume-mounting) and the [environment variable method](#environment-variable) are used, the volume mounting method will take precedence.
:::

#### Build Default

The default OHIF configuration file can be specified during build with a `--build-arg APP_CONFIG=config/kheops` argument added to the build command.

### Embedding in an iframe

If the OHIF instance served by the Docker image is to be embedded in an `iframe`, and if [cross-origin isolation](./cors.md#cross-origin-isolation) is required, then the [Cross Origin Resource Policy (CORP) header value](https://github.com/OHIF/Viewers/blob/8a8ae237d26faf123abeb073cbf0cd426c3e9ef2/.docker/Viewer-v3.x/default.conf.template#L10) that OHIF is served with will have to be updated accordingly. More information on CORP and `iframe`s can be found [here](./cors.md#ohif-as-a-cross-origin-resource-in-an-iframe).
Expand Down

0 comments on commit 4ebb977

Please sign in to comment.