Skip to content

Commit a382e20

Browse files
committed
containerized
1 parent 457ecec commit a382e20

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM ubuntu:20.04
2+
3+
WORKDIR /app
4+
5+
RUN apt-get update \
6+
&& apt-get -y install \
7+
python3 python3-pip \
8+
&& apt-get clean
9+
10+
RUN python3 -m pip install --upgrade pip setuptools wheel
11+
12+
COPY setup.py .
13+
COPY gunicorn_conf.py .
14+
COPY lissamp/ lissamp/
15+
16+
RUN python3 -m pip install .
17+
18+
CMD gunicorn -k uvicorn.workers.UvicornWorker -c gunicorn_conf.py lissamp.web.router:app

gunicorn_conf.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# https://github.com/tiangolo/uvicorn-gunicorn-docker/blob/master/docker-images/gunicorn_conf.py
2+
import json
3+
import os
4+
5+
accesslog_var = os.getenv("ACCESS_LOG", "-")
6+
use_accesslog = accesslog_var or None
7+
errorlog_var = os.getenv("ERROR_LOG", "-")
8+
use_errorlog = errorlog_var or None
9+
graceful_timeout_str = os.getenv("GRACEFUL_TIMEOUT", "120")
10+
timeout_str = os.getenv("TIMEOUT", "120")
11+
keepalive_str = os.getenv("KEEP_ALIVE", "5")
12+
13+
# Gunicorn config variables
14+
loglevel = os.getenv("LOG_LEVEL", "info")
15+
workers = 1
16+
bind = os.getenv("BIND", "0.0.0.0:5678")
17+
errorlog = use_errorlog
18+
worker_tmp_dir = "/dev/shm"
19+
accesslog = use_accesslog
20+
graceful_timeout = int(graceful_timeout_str)
21+
timeout = int(timeout_str)
22+
keepalive = int(keepalive_str)
23+
forwarded_allow_ips = '*'
24+
25+
# For debugging and testing
26+
log_data = {
27+
"loglevel": loglevel,
28+
"workers": workers,
29+
"bind": bind,
30+
"graceful_timeout": graceful_timeout,
31+
"timeout": timeout,
32+
"keepalive": keepalive,
33+
"errorlog": errorlog,
34+
"accesslog": accesslog,
35+
"forwarded_allow_ips": forwarded_allow_ips,
36+
}
37+
print(json.dumps(log_data))

0 commit comments

Comments
 (0)