Hi guys, I have successfully deployed hamitlon ui...
# hamilton-help
v
Hi guys, I have successfully deployed hamitlon ui using docker-compose some time ago. I saw in the docs, that hosting hamilton ui under a subpath is possible now, by using the env variable
REACT_APP_HAMILTON_SUB_PATH
. https://hamilton.dagworks.io/en/latest/hamilton-ui/ui/#self-hosting I wonder what my nginx conf should look like for the subpath
/hamilton
. IΒ΄ve tried:
Copy code
...
        location /hamilton/ {
            proxy_pass <http://frontend:8242>;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
        }
...
But this does not work. It failes, because https://domain.com/static/js/main.77c4424c.js is not found. Note: I have also asked for help here, as this might be of interested for others: https://github.com/DAGWorks-Inc/hamilton/pull/1284#issuecomment-2749049751
s
Did you try with and without the trailing
/
? (just a quick thought)
v
You mean
location /hamilton
and
location /hamilton/
?
s
sorry let me back up. What was your original nginx config? This is an addition you want to add? How were you exposing the Hamilton UI before?
v
Before using a subpath, I have exposed the app via domain:port (https://my-domain.com:8242) (Note: this is still part of my nginx.conf and i can access hamilton ui via this domain:port thing). Thats basically what my nginx.conf looks like.
Copy code
# Top-level context
worker_processes auto;
events {
    worker_connections 1024;
}

http {

  server {
		listen 8242 ssl;
		server_name my-domain.com;

		ssl_certificate /etc/ssl/my-domain.cer;
        ssl_certificate_key /etc/ssl/my-domain.key;

		location / {
			proxy_pass <http://frontend:8242>;
			proxy_set_header Host $host;
			proxy_set_header X-Real-IP $remote_addr;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_set_header X-Forwarded-Proto $scheme;
		}
	}

    server {
        listen 443 ssl;
        server_name my-domain.com;

        ssl_certificate /etc/ssl/my-domain.cer;
        ssl_certificate_key /etc/ssl/my-domain.key;


        # Hamilton
        location /hamilton/ {
            proxy_pass <http://frontend:8242>;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;

            #error_page 401 /custom401.html;
        }

    }

}
And this are the environment variables from my docker-compose.yml
Copy code
environment:
  - NGINX_PORT=8242
  - NODE_ENV=development
  - REACT_APP_AUTH_MODE=local
  - REACT_APP_USE_POSTHOG=false
  - REACT_APP_API_URL=<http://backend:8241>
  - REACT_APP_HAMILTON_SUB_PATH=/hamilton
s
what's the error you get? from your error my guess is that
<https://domain.com/hamilton/static/js/main.77c4424c.js>
would work, right?
my gut says:
Copy code
location /hamilton/ {
            proxy_pass <http://frontend:8242>;
should be:
Copy code
location /hamilton/ {
            proxy_pass <http://frontend:8242/hamilton/>;
but I don't recall nginx config details -- and it might be that nginx is removing the
/hamilton/
from the URL?
v
No, https://domain.com/hamilton/static/js/main.77c4424c.js is also not found. Does that mean, that
REACT_APP_HAMILTON_SUB_PATH
is not used by hamilton frontend? That would also explain, why I can still access hamilton frontend via https://domain.com:8242
s
yeah - did you update your docker container? or try to rebuild? πŸ€”
v
I did a
docker-compose pull; docker-compose down; docker-compose up -d
s
πŸ€” yeah need to verify I actually built the containers properly when I pushed them
v
Ok. Btw, does hamilton ui has its own nginx "build in"? I have my own nginx (which uses the posted config) running.
s
do you have time to try rebuilding the UI container?
Btw, does hamilton ui has its own nginx β€œbuild in”? I have my own nginx (which uses the posted config) running.
yes it does
it could be I missed a config 😬
πŸ˜† 1
v
Ok. Does this conflict with my own nginx? Should I use the build in nginx? How can I adjust the build in nginx.conf?
s
well it appears that you run your nginx outside of the container? or?
@Volker Lorrmann I wont have time tomorrow, but will double check the docker containers I built are behaving as expected later in the week if you can wait.
v
Just saw your question about rebuilding the containers on my own. I will give it a try. An yes, I am running nginx in a separate container.
j
When I implemented the flag, I tested by building locally and it worked. Using the updated docker containers I couldn't get it to work either. Let me try locally building again :)
πŸ™ 1
So i composed up the docker-compose.yml found in the ui folder using the - REACT_APP_HAMILTON_SUB_PATH=/hamilton This worked and the ui is served on http://localhost:8242/hamilton I may have missed something in the ui/frontend/Dockerfile.frontend since there are some env settings there:
Copy code
ENV REACT_APP_AUTH_MODE=${REACT_APP_AUTH_MODE}
ENV REACT_APP_USE_POSTHOG=${REACT_APP_USE_POSTHOG}
ENV REACT_APP_API_URL=${REACT_APP_API_URL}
ENV NODE_OPTIONS="--max-old-space-size=8192"
I'm not the biggest expert on docker, but any envs passed through docker compose should just be picked up by the individual containers right? If required I can make a fix to add REACT_APP_HAMILTON_SUB_PATH there as well though.
v
Does that mean, you rebuild the images locally?
j
Correct
v
Ok thanks. The VM i am running hamilton ui only has 8GB of ram, so I am not able to build the images locally.
@Stefan Krawczyk Any updates yet? :-)
s
No sorry. I'll put it in my queue for tonight/tomorrow.
πŸ™ 1
πŸ™ 1
@Volker Lorrmann just pushed new docker containers -- try it now. You'll need to pass in
REACT_APP_HAMILTON_SUB_PATH
appropriately -- see the PR.
πŸ‘ 1
j
Cheers! Sorry for missing this, have been a bit busy...
πŸ‘ 1
s
@Jonas Meyer-Ohle all good - I missed it πŸ™‚
v
Stil can not get it to work I have setup
REACT_APP_HAMILTON_SUB_PATH=/hamilton
And this in my nginx.conf:
Copy code
...

    upstream frontend {
		server frontend:8242 fail_timeout=0;
		keepalive 20;
	}

   # Hamilton
   location /hamilton/ {
	    proxy_pass <http://frontend/hamilton/>;
		proxy_set_header Host $host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header X-Forwarded-Proto $scheme;
		}

...
s
proxy_pass http://frontend/hamilton/;
I assume that resolves correctly, right?
@Volker Lorrmann what I did to make it work: 1. check out hamilton repo 2. cd hamilton/ui 3. open up docker-compose-prod.yml 4. update env var to:
REACT_APP_HAMILTON_SUB_PATH=/hamilton
5. start things up using ./run.sh 6. then navigate to
<http://localhost:8242/hamilton/dashboard/projects>
v
I have already tested this. Works for me. Seems that nginx is doing something unexpected.
πŸ€” 1
s
Ask chatGPT / Gemini? πŸ€”