change dockerfile #2
31
Dockerfile
31
Dockerfile
@@ -1,29 +1,42 @@
|
|||||||
FROM python:3.13-slim
|
FROM python:3.13-slim AS builder
|
||||||
|
|
||||||
# Prevent Python from writing .pyc files and enable unbuffered stdout/stderr
|
# Prevent Python from writing .pyc files and enable unbuffered stdout/stderr
|
||||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||||
PYTHONUNBUFFERED=1 \
|
PYTHONUNBUFFERED=1 \
|
||||||
PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
||||||
# Playwright won't be installed for actual browser automation
|
|
||||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
|
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Install build deps (some packages may need them to compile wheels)
|
# Install build deps required to build wheels
|
||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
&& apt-get install -y --no-install-recommends build-essential gcc \
|
&& apt-get install -y --no-install-recommends build-essential gcc \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Upgrade packaging tools
|
# Upgrade packaging tools and install runtime dependencies into a separate prefix
|
||||||
COPY requirements.txt ./
|
COPY requirements.txt ./
|
||||||
RUN pip install --no-cache-dir \
|
RUN pip install --upgrade pip setuptools wheel \
|
||||||
|
&& pip install --prefix=/install --no-cache-dir \
|
||||||
--extra-index-url https://git.theprivateserver.de/api/packages/PHB/pypi/simple/ \
|
--extra-index-url https://git.theprivateserver.de/api/packages/PHB/pypi/simple/ \
|
||||||
-r requirements.txt && \
|
-r requirements.txt \
|
||||||
# Clean up pip cache
|
&& rm -rf /root/.cache/pip
|
||||||
rm -rf /root/.cache/pip
|
|
||||||
# Copy application source
|
# Copy application source (only used to include app files in final image)
|
||||||
COPY . /app
|
COPY . /app
|
||||||
|
|
||||||
|
FROM python:3.13-slim
|
||||||
|
|
||||||
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||||
|
PYTHONUNBUFFERED=1 \
|
||||||
|
API_PORT=8001
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy installed packages from the builder image into the final image
|
||||||
|
COPY --from=builder /install /usr/local
|
||||||
|
# Copy application sources
|
||||||
|
COPY --from=builder /app /app
|
||||||
|
|
||||||
EXPOSE 8001
|
EXPOSE 8001
|
||||||
|
|
||||||
# Run using uvicorn; the app is defined in `api_service.py` as `app`
|
# Run using uvicorn; the app is defined in `api_service.py` as `app`
|
||||||
|
|||||||
Reference in New Issue
Block a user