Viewers icon indicating copy to clipboard operation
Viewers copied to clipboard

PUBLIC_URL env variable does not seem to work using the published docker

Open HowardLander opened this issue 5 years ago • 4 comments

Hi all

We are attempting to use the published OHIF docker image in a system that requires the URL to be set at run time. We looked through the documents and found the PUBLIC_URL environment variable but it doesn't seem to be working as expected. For example we thought we could add something like

  • PUBLIC_URL=/private/some-user-name/some-app-name/some-random-unique-id/

to our docker compose file and find the app at the URL but it doesn't seem to be working. Any advice or ideas would be most appreciated.

Thanks Howard Lander

HowardLander avatar Jan 04 '21 20:01 HowardLander

I think that it's the same problem I am facing. Here is the relevant Compose section:

ohif:
    image: ohif/viewer
    environment:
    - PUBLIC_URL=/ohif/
    ports:
      - 19861:80
    volumes:
      - ./ohif/app-config.js:/usr/share/nginx/html/app-config.js
      # - ./ohif/nginx.conf:/etc/nginx/nginx.conf:ro

But OHIF doesn't look for assets and scripts starting from /ohif/. However, routerBasename works as expected and i can serve the application at localhost:19861/ohif/

Diegovictorbr avatar Jan 12 '21 17:01 Diegovictorbr

Hi @HowardLander and @Diegovictorbr Perhaps you can use Docker variables to specify URL at run time. Below are excerpts from working docker-compose.yml:

viewer: image: ohif/viewer:v1.x container_name: viewer depends_on: - mongo - orthanc restart: always networks: - frontend - backend volumes: # OHIF Viewer configuration to reach Orthanc DICOMWeb - ${VIEWER_CONFIG:-./config/viewer.js}:/app/app.json:ro environment: - MONGO_URL=${MONGO_URL:-mongodb://mongo:27017/ohif}

nginx: image: nginx container_name: nginx restart: always networks: - frontend ports: - 80:80 - 443:443 volumes: # Nginx as reverse proxy for orthanc and viewer - ${NGINX_DEFAULT_CONF:-./nginx/default.conf}:/etc/nginx/conf.d/default.conf - certbot-etc:/etc/letsencrypt - certbot-var:/var/lib/letsencrypt - web-root:/var/www/html - dhparam:/etc/ssl/certs

certbot: image: certbot/certbot container_name: certbot volumes: - certbot-etc:/etc/letsencrypt - certbot-var:/var/lib/letsencrypt - web-root:/var/www/html depends_on: - viewer command: certonly --webroot --webroot-path=/var/www/html --email [emailaddress] --text --agree-tos --no-eff-email --force-renewal -d [URL]

networks: frontend: backend:

volumes: certbot-etc: certbot-var: web-root: driver: local driver_opts: type: none device: [host filesystem location] o: bind dhparam: driver: local driver_opts: type: none device: [host filesystem location] o: bind

olivert1969 avatar Feb 15 '21 20:02 olivert1969

Hey! Take a look at my solution here

Diegovictorbr avatar Apr 24 '21 02:04 Diegovictorbr

has anyone found a way to do this without needing to build the docker? to update this value in an existing image?

maya-harel avatar Jul 13 '22 13:07 maya-harel

Pretty sure we fixed it recently

https://docs.ohif.org/deployment/docker

sedghi avatar Oct 13 '23 18:10 sedghi

Hi @sedghi - are PUBLIC_URL and routerBasename for non-root path still needed when OHIF is a docker container behind a reverse proxy?

olivert1969 avatar Jan 12 '24 01:01 olivert1969