30 lines
898 B
Docker
30 lines
898 B
Docker
FROM python:3.12-slim
|
||
|
||
WORKDIR /app
|
||
|
||
ENV PYTHONDONTWRITEBYTECODE=1
|
||
ENV PYTHONUNBUFFERED=1
|
||
# 默认直连外网 API,避免宿主机/Docker Desktop 传入的 *_PROXY 影响 httpx(需代理时在 compose 中覆盖)
|
||
ENV HTTPX_TRUST_ENV=0
|
||
ENV HTTP_PROXY=
|
||
ENV HTTPS_PROXY=
|
||
ENV ALL_PROXY=
|
||
ENV http_proxy=
|
||
ENV https_proxy=
|
||
ENV all_proxy=
|
||
ENV NO_PROXY="*"
|
||
|
||
ARG PIP_INDEX_URL=https://mirrors.aliyun.com/pypi/simple/
|
||
ARG PIP_TRUSTED_HOST=mirrors.aliyun.com
|
||
ARG DEBIAN_MIRROR_HOST=mirrors.aliyun.com
|
||
RUN sed -i "s/deb.debian.org/${DEBIAN_MIRROR_HOST}/g; s/security.debian.org/${DEBIAN_MIRROR_HOST}/g" /etc/apt/sources.list.d/debian.sources
|
||
|
||
COPY requirements.txt /app/requirements.txt
|
||
RUN pip install --no-cache-dir -i "${PIP_INDEX_URL}" --trusted-host "${PIP_TRUSTED_HOST}" -r /app/requirements.txt
|
||
|
||
COPY app /app/app
|
||
|
||
EXPOSE 8000
|
||
|
||
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
|