Skip to content

Commit 8d9b00b

Browse files
committed
Add docker-compose to basic app
1 parent e40f0ba commit 8d9b00b

File tree

5 files changed

+81
-0
lines changed

5 files changed

+81
-0
lines changed

basic-app/app-core.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
import os
2+
13
from shiny import App, render, ui
24

35
app_ui = ui.page_fluid(
46
ui.panel_title("Hello Shiny!"),
57
ui.input_slider("n", "N", 0, 100, 20),
68
ui.output_text_verbatim("txt"),
9+
ui.output_text_verbatim("hostname"),
710
)
811

912

@@ -12,5 +15,9 @@ def server(input, output, session):
1215
def txt():
1316
return f"n*2 is {input.n() * 2}"
1417

18+
@render.text
19+
def hostname():
20+
return "hostname: " + os.getenv("HOSTNAME", "env var $HOSTNAME not set")
21+
1522

1623
app = App(app_ui, server)

basic-app/app.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import os
2+
3+
from shiny import App, render, ui
4+
5+
app_ui = ui.page_fluid(
6+
ui.panel_title("Hello Shiny!"),
7+
ui.input_slider("n", "N", 0, 100, 20),
8+
ui.output_text_verbatim("txt"),
9+
ui.output_text_verbatim("hostname"),
10+
)
11+
12+
13+
def server(input, output, session):
14+
@render.text
15+
def txt():
16+
return f"n*2 is {input.n() * 2}"
17+
18+
@render.text
19+
def hostname():
20+
return "hostname: " + os.getenv("HOSTNAME", "env var $HOSTNAME not set")
21+
22+
23+
app = App(app_ui, server)

basic-app/docker-compose.lb.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
services:
2+
nginx:
3+
image: nginx:latest
4+
depends_on:
5+
- shiny_app
6+
ports:
7+
- "8080:80"
8+
volumes:
9+
- ./files/nginx.conf:/etc/nginx/nginx.conf:ro
10+
shiny_app:
11+
build:
12+
context: .
13+
image: local/eoda-dev/basic-app:latest
14+
restart: always
15+
deploy:
16+
replicas: 3

basic-app/docker-compose.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
services:
2+
shiny_app:
3+
build:
4+
context: .
5+
image: local/eoda-dev/basic-app:latest
6+
pull_policy: always
7+
ports:
8+
- "3333:3333"
9+
restart: always

basic-app/files/nginx.conf

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
events { }
2+
3+
http {
4+
map $http_upgrade $connection_upgrade {
5+
default upgrade;
6+
'' close;
7+
}
8+
9+
upstream shiny_app {
10+
server shiny_app:3333;
11+
}
12+
13+
server {
14+
listen 80;
15+
client_max_body_size 20M;
16+
17+
location / {
18+
proxy_pass http://shiny_app;
19+
proxy_set_header Host $host;
20+
proxy_set_header X-Real-IP $remote_addr;
21+
proxy_http_version 1.1;
22+
proxy_set_header Upgrade $http_upgrade;
23+
proxy_set_header Connection $connection_upgrade;
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)