-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
50 lines (39 loc) · 1.1 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
# syntax=docker/dockerfile:1
# Use a specific Python version
ARG PYTHON_VERSION=3.12.3
FROM python:${PYTHON_VERSION}-slim as base
# Prevents Python from writing pyc files
ENV PYTHONDONTWRITEBYTECODE=1
# Keeps Python from buffering stdout and stderr
ENV PYTHONUNBUFFERED=1
# Set the working directory
WORKDIR /app
# Create a non-privileged user
ARG UID=10001
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
appuser
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
ffmpeg \
libpq-dev \
git \
&& rm -rf /var/lib/apt/lists/*
# Install Python dependencies
COPY requirements.txt .
RUN --mount=type=cache,target=/root/.cache/pip \
python -m pip install --no-cache-dir -r requirements.txt
# Switch to the non-privileged user
USER appuser
# Copy the source code into the container
COPY . .
# Expose the port that the application listens on
EXPOSE 8000
# Run the application
CMD ["gunicorn", "website.wsgi:application", "--bind", "0.0.0.0:8000"]