refactor: use multi-stage Dockerfile for smaller runtime image
This commit is contained in:
parent
6ee948a3a0
commit
6e191441da
14
Dockerfile
14
Dockerfile
|
|
@ -1,13 +1,21 @@
|
|||
FROM python:3.12-slim
|
||||
FROM python:3.12-slim AS builder
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y postgresql-client gcc libpq-dev gzip && \
|
||||
apt-get install -y gcc libpq-dev && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN pip install --upgrade pip setuptools wheel
|
||||
|
||||
COPY requirements.txt /app/requirements.txt
|
||||
RUN pip install --no-cache-dir -r /app/requirements.txt
|
||||
RUN pip install --prefix=/install -r /app/requirements.txt
|
||||
|
||||
FROM python:3.12-slim
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y postgresql-client gzip && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY --from=builder /install /usr/local
|
||||
|
||||
COPY main.py /app/main.py
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue