refactor(docker): optimize Dockerfile for size and caching

This commit is contained in:
Mohamed Kara 2025-09-02 10:45:41 +01:00
parent 0cb79779b3
commit bd788aa6e8
1 changed files with 16 additions and 5 deletions

View File

@ -1,9 +1,20 @@
FROM python:3.8.12-buster # much smaller image than debian based python images
FROM python:3.12-slim
LABEL maintainer="0xkatana"
WORKDIR /app WORKDIR /app
COPY ./ ./
COPY files files
RUN pip3 install -r requirements.txt # Install git
RUN apt-get update && apt-get install -y git && apt-get clean
ENTRYPOINT ["python3", "/app/start.py"] # copy requirements.txt for better caching
COPY requirements.txt .
# Install py dependencies (may migrate to uv later)
RUN pip install --no-cache-dir -r requirements.txt
# Copy all code at once instead of copy code then files
COPY . .
ENTRYPOINT ["python", "start.py"]