ScanServer / Dockerfile
AbelGAlem
chore(server): update Dockerfile to bind to dynamic PORT and adjust CMD for FastAPI application
60a83aa
raw
history blame contribute delete
977 Bytes
# apps/server/Dockerfile
FROM python:3.11-slim AS base
ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
FROM base AS builder
COPY requirements.txt /app/requirements.txt
RUN pip install --upgrade pip && \
pip wheel --no-cache-dir --wheel-dir /app/wheels -r /app/requirements.txt
FROM python:3.11-slim AS runtime
ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
# add runtime libs you actually need; xgboost often needs libgomp1
RUN apt-get update && apt-get install -y --no-install-recommends \
libgomp1 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# deps
COPY --from=builder /app/wheels /wheels
RUN pip install --no-cache-dir /wheels/* && rm -rf /wheels
# app source
COPY . /app
# non-root
RUN useradd -m appuser
USER appuser
ENV PORT=7860
EXPOSE 7860
CMD ["sh", "-c", "uvicorn main:app --host 0.0.0.0 --port ${PORT}"]