2024-07-31 21:48:39 +00:00
|
|
|
FROM python:3.12-slim-bookworm
|
2021-02-09 21:04:02 +00:00
|
|
|
|
2024-07-23 22:48:24 +00:00
|
|
|
# PYTHONFAULTHANDLER: Propagate tracebacks from all threads.
|
|
|
|
# PYTHONUNBUFFERED: Write terminal output straight to docker (to not confuse Docker Compose).
|
|
|
|
# PYTHONDONTWRITEBYTECODE: Dont write *pyc files at all, making it possible for a 100% read-only container.
|
|
|
|
# PIP_NO_CACHE_DIR: Disable PIP cache, we don't need pip's cache after building the image.
|
|
|
|
# PIP_DISABLE_PIP_VERSION_CHECK: Build the image with the available pip, do not check for updates (faster!)
|
|
|
|
# PIP_DEFAULT_TIMEOUT: Allow for longer timeouts.
|
2021-02-09 21:04:02 +00:00
|
|
|
ENV PYTHONFAULTHANDLER=1 \
|
|
|
|
PYTHONUNBUFFERED=1 \
|
|
|
|
PYTHONDONTWRITEBYTECODE=1 \
|
2024-07-23 22:48:24 +00:00
|
|
|
PIP_NO_CACHE_DIR=1 \
|
2021-02-09 21:04:02 +00:00
|
|
|
PIP_DISABLE_PIP_VERSION_CHECK=on \
|
2022-11-21 19:51:09 +00:00
|
|
|
PIP_DEFAULT_TIMEOUT=100
|
|
|
|
ARG BUILD
|
2024-07-31 21:48:39 +00:00
|
|
|
ENV BUILD=${BUILD}
|
2024-07-14 21:14:07 +00:00
|
|
|
ARG REQUIREMENTS_FILE=requirements.txt
|
2021-02-09 21:04:02 +00:00
|
|
|
|
2024-03-03 10:05:08 +00:00
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
RUN groupadd -g 1000 www && useradd -u 1000 -ms /bin/bash -g www www
|
2024-07-31 21:48:39 +00:00
|
|
|
|
|
|
|
# Only copy the requirements file first to leverage Docker cache
|
2024-08-14 09:17:29 +00:00
|
|
|
RUN mkdir requirements/
|
2024-08-09 06:33:14 +00:00
|
|
|
COPY $REQUIREMENTS_FILE $REQUIREMENTS_FILE
|
2024-07-31 21:48:39 +00:00
|
|
|
|
|
|
|
RUN mkdir -p /app/src/static && \
|
2024-07-14 21:14:07 +00:00
|
|
|
chown www:www /app/src/static && \
|
|
|
|
apt-get update && \
|
|
|
|
apt-get install -y \
|
2021-02-09 21:04:02 +00:00
|
|
|
binutils \
|
|
|
|
libpq-dev \
|
|
|
|
build-essential \
|
|
|
|
netcat-openbsd \
|
|
|
|
libcairo2 \
|
|
|
|
libpango-1.0-0 \
|
|
|
|
libpangocairo-1.0-0 \
|
|
|
|
libgdk-pixbuf2.0-0 \
|
|
|
|
libffi-dev \
|
|
|
|
shared-mime-info \
|
2024-07-14 21:14:07 +00:00
|
|
|
gettext && \
|
2024-07-31 21:48:39 +00:00
|
|
|
pip install --no-cache-dir -r $REQUIREMENTS_FILE
|
|
|
|
|
|
|
|
# Copy the rest of the application
|
|
|
|
COPY . .
|
|
|
|
|
|
|
|
RUN django-admin compilemessages
|
2021-02-09 21:04:02 +00:00
|
|
|
|
2021-02-09 21:48:53 +00:00
|
|
|
ENTRYPOINT ["./entrypoint.sh"]
|
2021-03-01 16:49:37 +00:00
|
|
|
|
2021-03-01 20:44:57 +00:00
|
|
|
EXPOSE 8000
|
|
|
|
|
2021-03-01 16:49:37 +00:00
|
|
|
CMD ["uvicorn", "project.asgi:application", "--host", "0.0.0.0", "--port", "8000", "--workers", "3", "--lifespan", "off", "--app-dir", "/app/src"]
|