-
Notifications
You must be signed in to change notification settings - Fork 46
/
Dockerfile-server
74 lines (59 loc) · 2.16 KB
/
Dockerfile-server
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
###########
# BUILDER #
###########
FROM clinicalgenomics/python3.11-venv:1.0 AS python-builder
ENV PATH="/venv/bin:$PATH"
WORKDIR /app
# Install Scout dependencies
COPY requirements.txt .
# No wheel for indirect pycairo dependency so need build env for it to install
RUN apt-get update && \
apt-get -y upgrade && \
apt-get -y install --no-install-recommends gcc libcairo2-dev pkg-config python3-dev
RUN pip install --no-cache-dir -r requirements.txt gunicorn
#########
# FINAL #
#########
FROM python:3.11-slim-bullseye
LABEL about.home="https://github.com/Clinical-Genomics/scout"
LABEL about.documentation="https://clinical-genomics.github.io/scout"
LABEL about.tags="WGS,WES,Rare diseases,VCF,variants,SNP,Next generation sequencing"
LABEL about.license="MIT License (MIT)"
# Install base dependencies
RUN apt-get update && \
apt-get -y upgrade && \
apt-get -y install -y --no-install-recommends wkhtmltopdf libpango-1.0-0 libpangocairo-1.0-0 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Do not upgrade to the latest pip version to ensure more reproducible builds
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
ENV PATH="/venv/bin:$PATH"
RUN echo export PATH="/venv/bin:\$PATH" > /etc/profile.d/venv.sh
# Create a non-root user to run commands
RUN groupadd --gid 1000 worker && useradd -g worker --uid 1000 --shell /usr/sbin/nologin --create-home worker
# Copy virtual environment from builder
COPY --chown=worker:worker --from=python-builder /venv /venv
WORKDIR /home/worker/app
COPY --chown=worker:worker . /home/worker/app
# Install only Scout app
RUN pip install --no-cache-dir --editable .[coverage]
# Run the app as non-root user
USER worker
ENV GUNICORN_WORKERS=1
ENV GUNICORN_THREADS=1
ENV GUNICORN_BIND="0.0.0.0:8000"
ENV GUNICORN_TIMEOUT=400
ENV GUNICORN_MAXREQUESTS=1200
CMD gunicorn \
--workers=$GUNICORN_WORKERS \
--bind=$GUNICORN_BIND \
--threads=$GUNICORN_THREADS \
--timeout=$GUNICORN_TIMEOUT \
--max-requests=$GUNICORN_MAXREQUESTS \
--proxy-protocol \
--forwarded-allow-ips="10.0.2.100,127.0.0.1" \
--log-syslog \
--access-logfile - \
--error-logfile - \
--log-level="debug" \
scout.server.auto:app