[UPDT] Using docker multi-stage builds to reduce docker image's size (#925)

* [UPDT] Using docker multi-stage builds to reduce docker image's size

* [FIX] Updating WORKDIR for consistency
This commit is contained in:
Nguyen Quang
2025-10-01 17:39:12 +08:00
committed by GitHub
parent 2d70a660f1
commit 056e5f2ac7

View File

@@ -1,17 +1,26 @@
FROM python:3.10-slim-bullseye
FROM python:3.10-slim-bullseye AS builder
ENV PYTHONUNBUFFERED=1
RUN apt-get update && apt-get install -y libcairo2-dev gcc
RUN apt-get update && apt-get install -y --no-install-recommends libcairo2-dev gcc && rm -rf /var/lib/apt/lists/*
WORKDIR /app/
COPY requirements.txt .
RUN pip install --no-cache-dir --prefix=/install -r requirements.txt
FROM python:3.10-slim-bullseye AS runtime
ENV PYTHONUNBUFFERED=1
WORKDIR /app/
COPY --from=builder /install /usr/local
COPY . .
RUN chmod +x /app/entrypoint.sh
RUN pip install -r requirements.txt
EXPOSE 8000
CMD ["python3", "manage.py", "runserver"]