26 lines
666 B
Docker
26 lines
666 B
Docker
# Stage 1: Build
|
|
FROM python:3.12-slim-bookworm as builder
|
|
|
|
WORKDIR /app
|
|
COPY requirements.txt .
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Stage 2: Runtime
|
|
FROM python:3.12-slim-bookworm
|
|
|
|
# Install system dependencies (if any are needed)
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
&& apt-get clean \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Set the working directory
|
|
WORKDIR /app
|
|
|
|
# Copy installed Python packages from the builder stage
|
|
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
|
|
|
|
# Copy the application code
|
|
COPY . .
|
|
|
|
# Run the application
|
|
CMD ["python", "-u", "main.py"] |