-
Notifications
You must be signed in to change notification settings - Fork 8
/
Dockerfile
55 lines (40 loc) 路 1.82 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
44
45
46
47
48
49
50
51
52
53
54
55
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.9
WORKDIR /app/
ENV TZ=Europe/Amsterdam \
PYTHONUNBUFFERED='1' \
APP_MODULE=api.main:app \
MAX_WORKERS='16'
## Check here for more details on how the image is built and which env variables are available
# https://github.com/tiangolo/uvicorn-gunicorn-docker/tree/master/docker-images
# WORKER_CLASS=uvicorn.workers.UvicornWorker \
# WORKERS_PER_CORE='1' \
# LOG_LEVEL=info
RUN apt-get update && \
apt-get install -y wget tzdata && \
pip install --upgrade pip
# Download kubectl and oc CLI
RUN cd /tmp && \
wget -q https://mirror.openshift.com/pub/openshift-v4/clients/oc/latest/linux/oc.tar.gz && \
tar xvf oc.tar.gz && \
mv oc kubectl /usr/local/bin/
# Other option: https://github.com/openshift/okd/releases/download/4.9.0-0.okd-2022-01-14-230113/openshift-client-linux-4.9.0-0.okd-2022-01-14-230113.tar.gz
# curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
COPY requirements.txt /app/
RUN pip install -r requirements.txt
COPY . /app
RUN python setup.py install
# By default this image entrypoint will use gunicorn to start multiple uvicorn workers
## Running as non-root dont work, the API crashes directly at start without notice
# ## Create non root user "app" in group "app"
# RUN addgroup --system app && adduser --system --group app
# ## Make sure all files belongs to the app user
# RUN chown -R app:app /app && \
# chown -R app:app $HOME && \
# chown -R app:app /usr/local
# ## Switch to app user to install the python app
# USER app
## If you want to use crontab: copy cron file to the cron.d directory
# COPY cron/gpu-notification-cron /etc/cron.d/gpu-notification-cron
# RUN chmod 0644 /etc/cron.d/gpu-notification-cron && \
# crontab /etc/cron.d/gpu-notification-cron
# touch /var/log/cron.log