Merge pull request 'change dockerfile' (#2) from dev into main
Reviewed-on: #2
This commit was merged in pull request #2.
This commit is contained in:
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
|
||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
||||
# Playwright won't be installed for actual browser automation
|
||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install build deps (some packages may need them to compile wheels)
|
||||
# Install build deps required to build wheels
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends build-essential gcc \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Upgrade packaging tools
|
||||
# Upgrade packaging tools and install runtime dependencies into a separate prefix
|
||||
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/ \
|
||||
-r requirements.txt && \
|
||||
# Clean up pip cache
|
||||
rm -rf /root/.cache/pip
|
||||
# Copy application source
|
||||
-r requirements.txt \
|
||||
&& rm -rf /root/.cache/pip
|
||||
|
||||
# Copy application source (only used to include app files in final image)
|
||||
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
|
||||
|
||||
# Run using uvicorn; the app is defined in `api_service.py` as `app`
|
||||
|
||||
Reference in New Issue
Block a user