Files
model-platform/backend/Dockerfile
T
2026-08-05 16:34:35 +08:00

38 lines
1.2 KiB
Docker

FROM python:3.12-slim-bookworm
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONPATH=/app \
PATH="/app/.venv/bin:${PATH}" \
TZ=Asia/Shanghai
WORKDIR /app
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
RUN ( \
sed -i 's/deb.debian.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list.d/debian.sources 2>/dev/null || \
sed -i 's/deb.debian.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list 2>/dev/null \
) || true
RUN apt-get -o Acquire::Retries=5 update && apt-get install -y --no-install-recommends \
curl \
ca-certificates \
gcc \
g++ \
python3-dev \
build-essential \
tzdata \
&& ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
&& echo $TZ > /etc/timezone \
&& dpkg-reconfigure --frontend noninteractive tzdata \
&& rm -rf /var/lib/apt/lists/*
COPY common ./common
COPY backend ./backend
COPY alembic.ini ./
COPY migrations ./migrations
COPY pyproject.toml uv.lock ./
RUN UV_DEFAULT_INDEX="https://pypi.tuna.tsinghua.edu.cn/simple/" uv sync --frozen --no-dev --no-editable --package backend
EXPOSE 8000
CMD ["gunicorn", "--config", "backend/gunicorn.conf.py", "backend.main:app"]