-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
36 lines (27 loc) · 954 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
# Pull base image
FROM python:slim-bullseye
# Create user
RUN addgroup --system appgroup && adduser --system --group appuser
# Set environment variables
ENV PIP_DISABLE_PIP_VERSION_CHECK 1
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# Set working directory
WORKDIR /code
# Updates and installation of requirements
RUN apt-get update \
&& apt-get install -y --no-install-recommends gcc libpq-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install dependencies
COPY --chown=appuser:appgroup requirements.txt /code/
RUN pip install --upgrade pip \
&& pip install -r requirements.txt
# Copy project
COPY --chown=appuser:appgroup . /code/
# Ensure executability of entrypoint shell script
RUN chmod +x /code/entrypoint.sh
# Switch to the app user
USER appuser
# Run entrypoint.sh (Assumes it starts gunicorn or another WSGI server)
ENTRYPOINT ["/bin/sh", "/code/entrypoint.sh"]