-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
41 lines (29 loc) · 941 Bytes
/
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
FROM python:3.9-slim-bullseye
# set environment variables.
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# user uid and gid
ARG UID=999
ARG GID=999
# creating and changing to non-root user. (-mr: creating a HOME directory)
RUN groupadd -g $GID -o app && \
useradd -g $GID -u $UID -mr -d /home/app -o -s /bin/bash app && \
mkdir /home/app/staticfiles && \
chown -R app:app /home/app/staticfiles
# changing user to "app"
USER app
# set work directory.
WORKDIR /home/app
# add /home/app/.local/bin to PATH
ENV PATH "$PATH:/home/app/.local/bin"
# upgrading pip and installing dependencies.
RUN pip install --upgrade pip
COPY --chown=app:app app/requirements.txt .
RUN pip install -r /home/app/requirements.txt
# copy project
COPY --chown=app:app app/ /home/app/
# application port
EXPOSE 8000
# adding exec permission to entypoint.sh
RUN chmod +x /home/app/entrypoint.sh
ENTRYPOINT ["/home/app/entrypoint.sh"]