diff --git a/origin_ui/src/README.md b/origin_ui/src/README.md index 924c0f424..d3f24dd71 100644 --- a/origin_ui/src/README.md +++ b/origin_ui/src/README.md @@ -4,6 +4,40 @@ This ui is generated with Next.js. ## Development +### Local + +In production builds the website is compiled and included with the code. This step +takes a couple minutes and is not well suited for development. Since the website +sits on top of the api the best way to develop just the website is to run the api +and the website separately and then use nginx to make them come from the same host +as they would in production. + +#### To run the api: + +```shell +# From repo root +goreleaser --clean --snapshot +docker run --rm -it -p 8444:8444 -w /app -v $PWD/dist/pelican_linux_arm64/:/app pelican-dev /bin/bash +``` + +```shell +# Inside the container +cp pelican osdf +./osdf origin serve -f https://osg-htc.org -v /tmp/stash/:/test +``` + +#### To run the website and the reverse proxy: + +First make sure that the ports are correct in `dev/nginx.conf` so that they point to +the website and the api as expected. Then run the following command. + +```shell +sh dev/run.sh +npm run dev +``` + +### Docker + ```shell docker build -t origin-ui . ``` diff --git a/origin_ui/src/dev/nginx.conf b/origin_ui/src/dev/nginx.conf new file mode 100644 index 000000000..97d4139fe --- /dev/null +++ b/origin_ui/src/dev/nginx.conf @@ -0,0 +1,38 @@ +user nginx; +worker_processes auto; ## Default: 1 +worker_rlimit_nofile 8192; + +error_log /var/log/nginx/error.log notice; +pid /var/run/nginx.pid; + +events { + worker_connections 4096; ## Default: 1024 +} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + index index.html index.htm index.php; + + server { + listen 8443; + + location /api { + proxy_read_timeout 300s; + proxy_connect_timeout 10s; + proxy_set_header X-Real-IP $remote_addr; + proxy_pass https://host.docker.internal:8444; + } + + location /view { + proxy_read_timeout 300s; + proxy_connect_timeout 10s; + proxy_set_header X-Real-IP $remote_addr; + proxy_pass http://host.docker.internal:3001; + } + + gzip on; + gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; + } +} diff --git a/origin_ui/src/dev/run.sh b/origin_ui/src/dev/run.sh new file mode 100644 index 000000000..8806c3253 --- /dev/null +++ b/origin_ui/src/dev/run.sh @@ -0,0 +1,2 @@ +docker restart pelican-dev-proxy +docker run --name pelican-dev-proxy -it -p 8443:8443 -v $0/../nginx.conf:/etc/nginx/nginx.conf:ro -d nginx