Hello! I have a working containerized web solution (JS), which I wanted to test if I could deploy on HF spaces.
To run the container locally, you can simply do:
docker run -p 3000:80 ohif4hf
Problem is that HF spaces does not seem to support setting app_port=3000:80 in the README, only ints, e.g., app_port=3000. In that case I do not get the appropriate port redirect (proxy). It deploys just fine locally. What is the easiest way to get this working? Quick note, I’m not an experiences web developer.
The project is located at (although it is not working currently and is prone to changes):
Hmm, I tried rewriting the Dockerfile and config, but when running the final container, the final website does not show.
I believe it might have to do with how the original project setup their nginx config and that they used the nginxinc/nginx-unprivileged:1.25-alpine image, which was different from the one you used (see here for original Dockerfile).
Swapping this with your solution did not even work locally, so I guess something is not compatible. Maybe the config is just wrong (see here for original config).
Basically, whatever I do, I am unable to access the website with only a single port ID. It does not redirect as it should. So I cannot deploy it on HF spaces. Even though the original 3000:80 worked fine.
I had a quick look at the OHIF documentation and it appears that you can have a PORT environment variable to configure a different Nginx port. So I created a simple Dockerfile and set the PORT environment variable to 7860, which is the default port on Spaces, and it works.
FROM ohif/app:latest
However, I noticed that you would need a custom Nginx configuration file to properly configure cross-origin isolation. So, I modified the Dockerfile from the original repository appropriately and also added this extra configuration to our Spaces README. md to enable custom headers.
Just tried incorporating your ideas and it works wonders! Thank you so much! This was a nice thing to wake up to :]
I never would have thought about modifying the app-config.js. I also noticed that you no longer set the app_port in the README. But how does this affect local deployment? I just tried running the built container locally, but it does not show in localhost. Is there a default port I’m not setting or similar?