Last active
December 7, 2024 12:34
-
-
Save alecordev/0cae762488a4b9d625dcd6db985106fc to your computer and use it in GitHub Desktop.
Python Dockerfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM python:3.12 as builder | |
ENV PYTHONDONTWRITEBYTECODE=1 | |
ENV PYTHONUNBUFFERED=1 | |
RUN apt-get update && \ | |
apt-get install -y --no-install-recommends gcc \ | |
libpq-dev | |
RUN python -m venv /opt/venv | |
ENV PATH="/opt/venv/bin:$PATH" | |
COPY requirements.txt . | |
RUN pip install --upgrade pip && \ | |
pip install --no-cache-dir -r requirements.txt | |
FROM python:3.12-slim | |
ENV PYTHONDONTWRITEBYTECODE=1 | |
ENV PYTHONUNBUFFERED=1 | |
COPY --from=builder /opt/venv /opt/venv | |
COPY . /app | |
WORKDIR /app/src | |
ENV PATH="/opt/venv/bin:$PATH" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment