Skip to content

Commit f67be54

Browse files
cmdoretalmutlue
andauthored
feat(deploy): caddy with https support (#160)
* refactor(deploy): nginx -> caddy * refactor(deploy): list endpoints from modos-server instead of nginx * doc(deploy): show example domain value * fix(deploy): fallback value for DOMAIN * fix(deploy): wilcard paths in caddy * chore: update env example * fix(server): htsget env var Co-authored-by: almutlue <[email protected]> * fix(deploy): drop NET_ADMIN cap from caddy --------- Co-authored-by: almutlue <[email protected]>
1 parent a6e7a00 commit f67be54

File tree

5 files changed

+78
-76
lines changed

5 files changed

+78
-76
lines changed

tools/deploy/.example.env

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ S3_ADDRESSING_STYLE="auto" # one of auto, path, virtual
1313
HTSGET_DATA_DIR="/data"
1414

1515
# PUBLIC
16-
# URL_PREFIX="https://modos.example.org"
17-
# S3_PUBLIC_URL="${URL_PREFIX}/s3"
18-
# FUZON_PUBLIC_URL="${URL_PREFIX}/fuzon"
19-
# HTSGET_PUBLIC_URL="${URL_PREFIX}/htsget"
20-
# REFGET_PUBLIC_URL="${URL_PREFIX}/refget"
16+
#DOMAIN="http://localhost"
17+
#S3_PUBLIC_URL="${DOMAIN}:9000"
18+
#FUZON_PUBLIC_URL="${DOMAIN}/fuzon"
19+
#HTSGET_PUBLIC_URL="${DOMAIN}/htsget"
20+
#REFGET_PUBLIC_URL="${DOMAIN}/refget"

tools/deploy/caddy/Caddyfile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
admin off
3+
default_bind 0.0.0.0
4+
http_port 80
5+
}
6+
7+
http:// {
8+
9+
encode
10+
request_body {
11+
max_size 5TB
12+
}
13+
14+
# object storage service
15+
handle_path /s3/* {
16+
reverse_proxy {$S3_LOCAL_URL}
17+
}
18+
19+
# genomics streaming service
20+
handle_path /htsget/* {
21+
reverse_proxy {$HTSGET_LOCAL_URL}
22+
}
23+
24+
# terminology code matching service
25+
handle_path /fuzon/* {
26+
reverse_proxy {$FUZON_LOCAL_URL}
27+
}
28+
29+
# reference sequence server
30+
handle_path /refget/* {
31+
reverse_proxy {$REFGET_LOCAL_URL}
32+
33+
}
34+
35+
handle /* {
36+
reverse_proxy {$MODOS_LOCAL_URL}
37+
}
38+
}

tools/deploy/compose.yaml

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
volumes:
2+
caddy-data:
3+
caddy-config:
24
minio-data:
35
driver: local
46

@@ -8,24 +10,27 @@ networks:
810

911
services:
1012

11-
nginx:
12-
image: nginx:1.23
13+
caddy:
14+
image: docker.io/caddy:2
15+
restart: always
1316
depends_on:
1417
- htsget
18+
ports:
19+
- "80:80"
20+
- "80:80/udp"
21+
- "443:443"
22+
- "443:443/udp"
1523
volumes:
16-
- ./nginx/default.conf.template:/etc/nginx/templates/default.conf.template:ro
24+
- ./caddy/Caddyfile:/etc/caddy/Caddyfile
25+
- caddy-data:/data
26+
- caddy-config:/config
1727
environment:
18-
- REFGET_PUBLIC_URL=${REFGET_PUBLIC_URL:-http://localhost/refget}
19-
- FUZON_PUBLIC_URL=${FUZON_PUBLIC_URL:-http://localhost/fuzon}
20-
- HTSGET_PUBLIC_URL=${HTSGET_PUBLIC_URL:-http://localhost/htsget}
21-
- S3_PUBLIC_URL=${S3_PUBLIC_URL:-http://localhost/s3}
28+
- DOMAIN=${DOMAIN:-http://localhost}
2229
- FUZON_LOCAL_URL=${FUZON_LOCAL_URL:-http://fuzon:9090}
2330
- REFGET_LOCAL_URL=${REFGET_LOCAL_URL:-http://refget:8080}
2431
- HTSGET_LOCAL_URL=${HTSGET_LOCAL_URL:-http://htsget:8080}
2532
- MODOS_LOCAL_URL=${MODOS_LOCAL_URL:-http://modos-server:8000}
2633
- S3_LOCAL_URL=${S3_LOCAL_URL:-http://minio:9000}
27-
ports:
28-
- "80:80"
2934
networks:
3035
- modos-network
3136

@@ -93,16 +98,20 @@ services:
9398
- ENDPOINT=${S3_PUBLIC_URL:-http://localhost/s3}
9499
- BUCKET=${REFERENCE_BUCKET:-reference-genomes}
95100

101+
96102
modos-server:
97103
build: ./modos-server
98104
expose:
99105
- "8000"
100106
networks:
101107
- modos-network
102108
environment:
103-
- S3_LOCAL_URL=${S3_LOCAL_URL:-http://minio:9000}
104-
- S3_PUBLIC_URL=${S3_PUBLIC_URL:-http://localhost/s3}
109+
- FUZON_PUBLIC_URL=${FUZON_PUBLIC_URL:-http://localhost/fuzon}
105110
- HTSGET_LOCAL_URL=${HTSGET_LOCAL_URL:-http://htsget:8080}
106-
- S3_BUCKET=${S3_BUCKET:-modos-demo}
111+
- HTSGET_PUBLIC_URL=${HTSGET_PUBLIC_URL:-http://localhost/htsget}
112+
- REFGET_PUBLIC_URL=${REFGET_PUBLIC_URL:-http://localhost/refget}
107113
- S3_ADDRESSING_STYLE=${S3_ADDRESSING_STYLE:-auto}
114+
- S3_BUCKET=${S3_BUCKET:-modos-demo}
115+
- S3_LOCAL_URL=${S3_LOCAL_URL:-http://minio:9000}
116+
- S3_PUBLIC_URL=${S3_PUBLIC_URL:-http://localhost/s3}
108117
command: uv run uvicorn --host 0.0.0.0 --port 8000 --reload server:app

tools/deploy/modos-server/server.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@
1515
from modos.logging import setup_logging
1616
from modos.storage import connect_s3
1717

18-
18+
FUZON_PUBLIC_URL = os.environ["FUZON_PUBLIC_URL"]
1919
S3_LOCAL_URL = os.environ["S3_LOCAL_URL"]
2020
S3_PUBLIC_URL = os.environ["S3_PUBLIC_URL"]
2121
BUCKET = os.environ["S3_BUCKET"]
2222
HTSGET_LOCAL_URL = os.environ["HTSGET_LOCAL_URL"]
23+
HTSGET_PUBLIC_URL = os.environ["HTSGET_PUBLIC_URL"]
24+
REFGET_PUBLIC_URL = os.environ["REFGET_PUBLIC_URL"]
2325
SERVICES = {
2426
"s3": S3_LOCAL_URL,
2527
"htsget": HTSGET_LOCAL_URL,
@@ -80,3 +82,14 @@ def get_s3_path(query: str, exact_match: bool = False):
8082
}
8183
for modo in res
8284
]
85+
86+
87+
@app.get("/")
88+
def get_endpoints():
89+
return {
90+
"status": "success",
91+
"s3": S3_PUBLIC_URL,
92+
"htsget": HTSGET_PUBLIC_URL,
93+
"fuzon": FUZON_PUBLIC_URL,
94+
"refget": REFGET_PUBLIC_URL,
95+
}

tools/deploy/nginx/default.conf.template

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)