/
Dockerfile
43 lines (33 loc) · 1.16 KB
/
Dockerfile
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
FROM python:3.8-slim-buster
RUN useradd --create-home user
WORKDIR /home/user
# env variable
ENV OBSEI_NUM_OF_WORKERS 1
ENV OBSEI_WORKER_TIMEOUT 180
ENV OBSEI_SERVER_PORT 9898
ENV OBSEI_WORKER_TYPE uvicorn.workers.UvicornWorker
# Hack to install jre on debian
RUN mkdir -p /usr/share/man/man1
# install few required tools
RUN apt-get update && apt-get upgrade -y && apt-get install -y curl git pkg-config cmake default-jre
RUN apt-get clean autoclean && apt-get autoremove -y
RUN rm -rf /var/lib/{apt,dpkg,cache,log}/
# install as a package
COPY setup.py requirements.txt README.md /home/user/
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt
# copy README and config
COPY README.md /home/user/
# hack to fix CI builds
RUN true
COPY config /home/user/config
# hack to fix CI builds
RUN true
# Copy REST API code
COPY rest_api /home/user/rest_api
# copy code
COPY obsei /home/user/obsei
RUN pip install -e .
USER user
# cmd for running the API
CMD ["gunicorn", "rest_api.application:app", "-b", "0.0.0.0:${OBSEI_SERVER_PORT}", "-k", "${OBSEI_GUNVICORN_WORKER_TYPE}", "--workers", "${OBSEI_NUM_OF_WORKERS}", "--timeout", "${OBSEI_WORKER_TIMEOUT}"]