-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile
47 lines (33 loc) · 1.15 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
FROM python:3.9.4-slim-buster
LABEL maintainer="Vladyslav Krylasov <[email protected]>"
# Install security upgrades
# See: https://pythonspeed.com/articles/security-updates-in-docker/
RUN apt-get update && apt-get -y upgrade
# Install supervisord required by daphne
RUN apt-get install -y supervisor
# create the app user
RUN groupadd --system user && \
useradd -g user --create-home --shell /bin/bash user
# Linux envs
ENV APP="/app"
ENV HOME="/home/user"
ENV PATH="${PATH}:${HOME}/.local/bin"
# Python envs
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONOPTIMIZE=1
ENV PYTHONUNBUFFERED=1
# https://pythonspeed.com/articles/python-c-extension-crashes/
ENV PYTHONFAULTHANDLER=1
WORKDIR ${APP}
COPY ./conf/requirements.txt ./conf/
# Create a dir for daphne sockets
RUN mkdir -p /run/daphne && chown -R user:user /run/daphne && chmod -R 755 /run/daphne
# Pick a not root user
RUN chown -R user:user ${APP} && chmod -R 744 ${APP}
USER user
# Upgrade pip and install packages
RUN python3 -m pip install --no-cache-dir --upgrade pip && \
python3 -m pip install --no-cache-dir -r ./conf/requirements.txt
COPY . .
EXPOSE 8000
CMD ["/bin/sh", "./conf/start-cmd.sh"]