You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

46 lines
1.3 KiB

# =======================================================
# Optimized Production Dockerfile for Django Backend
# Using Debian-slim for instant pre-compiled binary wheels
# (scikit-image, numpy, scipy install in seconds vs 10m on Alpine)
# =======================================================
FROM python:3.10-slim
# Set work directory
WORKDIR /usr/src/app
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1
# 1. System Dependencies (Cached permanently unless system packages change)
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
g++ \
curl \
git \
libpq-dev \
libjpeg62-turbo-dev \
zlib1g-dev \
libfreetype6-dev \
gettext \
ffmpeg \
&& rm -rf /var/lib/apt/lists/*
# 2. Python Dependencies (Cached unless requirements.txt changes)
COPY ./requirements.txt .
RUN pip install --upgrade pip && \
pip install -r requirements.txt
# 3. Entrypoint script (Cached)
COPY ./entrypoint.sh .
RUN sed -i 's/\r$//g' /usr/src/app/entrypoint.sh && \
chmod +x /usr/src/app/entrypoint.sh
# 4. Application Source Code (Changes frequently on git push)
COPY . .
# Run entrypoint
ENTRYPOINT ["/usr/src/app/entrypoint.sh"]