Skip to content

Commit

Permalink
feat: add docker compose with reverse proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
maffettone committed Apr 9, 2024
1 parent f19fa53 commit 65e7b6e
Show file tree
Hide file tree
Showing 5 changed files with 191 additions and 0 deletions.
56 changes: 56 additions & 0 deletions containers/mmm5-tax-day-compose.yaml
Original file line number Diff line number Diff line change
@@ -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





79 changes: 79 additions & 0 deletions containers/nginx/html/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Landing Page for Agent Services</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
text-align: center;
}

.container {
background-color: #ffffff;
padding: 20px;
border-radius: 5px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

h1 {
color: #333333;
}

p,
a {
color: #666666;
}

ul {
list-style-type: none;
padding: 0;
}

li {
margin: 10px 0;
}

/* Add styles for your links here. For example, color, decoration, etc. */
a {
text-decoration: none;
color: #007BFF;
}

a:hover {
text-decoration: underline;
}
</style>
</head>

<body>
<div class="container">
<h1>Welcome!</h1>
<p>This is the default landing page for our service. Please check back soon for updates.</p>

<!-- Links to your services -->
<h2>Our Services</h2>
<ul>
<!-- Link to the GSAS service -->
<li><a href="/gsas/">GSAS Service</a></li>
<!-- Link to the KMeans-GSAS service -->
<li><a href="/kmeans-gsas/">KMeans-GSAS Service</a></li>
<!-- Add more services here -->
<!-- Example: <li><a href="/your-service/">Your Service Name</a></li> -->
</ul>

<!-- Instructions or additional information can go here -->
<p>Click on the links above to access our services.</p>
</div>
</body>

</html>
7 changes: 7 additions & 0 deletions containers/nginx/locs.d/gsas.conf
Original file line number Diff line number Diff line change
@@ -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;
}
7 changes: 7 additions & 0 deletions containers/nginx/locs.d/kmeans-gsas.conf
Original file line number Diff line number Diff line change
@@ -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;
}
42 changes: 42 additions & 0 deletions containers/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -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;
}
}
}

0 comments on commit 65e7b6e

Please sign in to comment.