From 65e7b6ea94d5940fbfec571ea0f77763feee11fe Mon Sep 17 00:00:00 2001 From: maffettone Date: Tue, 9 Apr 2024 16:26:34 -0700 Subject: [PATCH] feat: add docker compose with reverse proxy --- containers/mmm5-tax-day-compose.yaml | 56 +++++++++++++++++ containers/nginx/html/index.html | 79 ++++++++++++++++++++++++ containers/nginx/locs.d/gsas.conf | 7 +++ containers/nginx/locs.d/kmeans-gsas.conf | 7 +++ containers/nginx/nginx.conf | 42 +++++++++++++ 5 files changed, 191 insertions(+) create mode 100644 containers/mmm5-tax-day-compose.yaml create mode 100644 containers/nginx/html/index.html create mode 100644 containers/nginx/locs.d/gsas.conf create mode 100644 containers/nginx/locs.d/kmeans-gsas.conf create mode 100644 containers/nginx/nginx.conf diff --git a/containers/mmm5-tax-day-compose.yaml b/containers/mmm5-tax-day-compose.yaml new file mode 100644 index 0000000..72fdadb --- /dev/null +++ b/containers/mmm5-tax-day-compose.yaml @@ -0,0 +1,56 @@ +--- +version: '3' + + +services: + gsas: + image: gsas:conda + build: + context: ../gsas + dockerfile: Containerfile-conda + command: conda run -n GSASII --no-capture-output uvicorn bluesky_adaptive.server:app + env: + - BS_AGENT_STARTUP_SCRIPT_PATH: /src/pdf-agents/pdf_agents/startup_scripts/mmm5-tax-day/gsas.py + volumes: + - type: ro + source: ../pdf_agents + target: /src/pdf-agents/pdf_agents + + kmeans-gsas: + image: bluesky:latest + command: uvicorn bluesky_adaptive.server:app + env: + - BS_AGENT_STARTUP_SCRIPT_PATH: /src/pdf-agents/pdf_agents/startup_scripts/mmm5-tax-day/kmeans-gsas.py + volumes: + - type: ro + source: ../pdf_agents + target: /src/pdf-agents/pdf_agents + depends_on: + gsas: + condition: service_started + + proxy: + image: docker.io/nginx + init: true + ports: + - "127.0.0.1:11973:11973" + volumes: + - type: ro + source: ../nginx/nginx.conf + target: /etc/nginx/nginx.conf + - type: ro + source: ../nginx/locs.d + target: /etc/nginx/locs.d + - type: ro + source: ../nginx/html + target: /var/www/html + depends_on: + gsas: + condition: service_started + kmeans-gsas: + condition: service_started + + + + + diff --git a/containers/nginx/html/index.html b/containers/nginx/html/index.html new file mode 100644 index 0000000..97a00fc --- /dev/null +++ b/containers/nginx/html/index.html @@ -0,0 +1,79 @@ + + + + + + + Landing Page for Agent Services + + + + +
+

Welcome!

+

This is the default landing page for our service. Please check back soon for updates.

+ + +

Our Services

+ + + +

Click on the links above to access our services.

+
+ + + diff --git a/containers/nginx/locs.d/gsas.conf b/containers/nginx/locs.d/gsas.conf new file mode 100644 index 0000000..2f577e7 --- /dev/null +++ b/containers/nginx/locs.d/gsas.conf @@ -0,0 +1,7 @@ +location /gsas/ { + proxy_pass http://gsas:8000/; + 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_read_timeout 60s; +} diff --git a/containers/nginx/locs.d/kmeans-gsas.conf b/containers/nginx/locs.d/kmeans-gsas.conf new file mode 100644 index 0000000..4d38c23 --- /dev/null +++ b/containers/nginx/locs.d/kmeans-gsas.conf @@ -0,0 +1,7 @@ +location /kmeans-gsas/ { + proxy_pass http://kmeans-gsas:8000/; + 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_read_timeout 60s; +} diff --git a/containers/nginx/nginx.conf b/containers/nginx/nginx.conf new file mode 100644 index 0000000..5b451d9 --- /dev/null +++ b/containers/nginx/nginx.conf @@ -0,0 +1,42 @@ +user nginx; +worker_processes 1; + +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + + sendfile on; + keepalive_timeout 65; + + include /etc/nginx/conf.d/*.conf; + + server { + listen 11973 default_server; + listen [::]:11973 default_server; + + root /var/www/html; + + index index.html index.htm index.nginx-debian.html; + + server_name _; + + include /etc/nginx/locs.d/*.conf; + + location / { + try_files $uri $uri/ /index.html; + } + } +}