-
Notifications
You must be signed in to change notification settings - Fork 7
/
Dockerfile
51 lines (40 loc) · 1.46 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
ARG PYTHON_BUILD_VERSION=3.11
FROM python:$PYTHON_BUILD_VERSION-slim AS BASE
WORKDIR /app
ENV PIP_DEFAULT_TIMEOUT=100 \
# Allow statements and log messages to immediately appear
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
# disable a pip version check to reduce run-time & log-spam
PIP_DISABLE_PIP_VERSION_CHECK=1 \
# cache is useless in docker image, so disable it to reduce image size
PIP_NO_CACHE_DIR=1
# Update and install dependencies
RUN apt-get update && \
apt-get -y upgrade && \
apt-get -y install --no-install-recommends python3-dev gcc libc-dev vim curl postgresql-client && \
# Clean up
apt-get autoremove -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
# Add a non-root user
groupadd -g 999 python && \
useradd -r -u 999 -g python python
WORKDIR /app
# Python Dependencies
COPY --chown=python:python ./requirements.txt /app/
RUN pip install --upgrade pip \
&& pip install -r requirements.txt --no-cache-dir --compile
# Clean up
RUN apt-get -y purge gcc libc-dev python3-dev
# Add all application code from this folder, including deployment entrypoints
COPY --chown=python:python ./ /app
# Create staticfiles folder
RUN mkdir -p staticfiles && \
chown -R python:python staticfiles
# Make entrypoints executable
RUN chmod +x /app/deployment/server-entrypoint.sh && \
chmod +x /app/deployment/worker-entrypoint.sh
USER 999
EXPOSE 8000
CMD [ "/app/deployment/server-entrypoint.sh" ]