-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
33 lines (25 loc) · 1.19 KB
/
Dockerfile
File metadata and controls
33 lines (25 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
FROM python:3.11-slim
# Build arguments: 默认使用清华镜像站点作为加速源,可在构建时覆盖
ARG APT_MIRROR=mirrors.tuna.tsinghua.edu.cn
ARG PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
ENV PIP_INDEX_URL=${PIP_INDEX_URL}
ENV PIP_NO_CACHE_DIR=1
WORKDIR /app
# Use faster domestic apt and pip mirrors during build to accelerate installs.
# Replace debian apt sources (deb.debian.org / security.debian.org) with chosen mirror.
RUN set -eux; \
if [ -f /etc/apt/sources.list ]; then \
sed -i 's|http://deb.debian.org/debian|http://${APT_MIRROR}|g' /etc/apt/sources.list || true; \
sed -i 's|http://security.debian.org/debian-security|http://${APT_MIRROR}|g' /etc/apt/sources.list || true; \
fi; \
apt-get update -y && apt-get install -y --no-install-recommends \
build-essential ca-certificates curl && \
rm -rf /var/lib/apt/lists/*
# Copy requirements and install using the specified PyPI mirror
COPY requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir -r /app/requirements.txt -i ${PIP_INDEX_URL}
# Copy application source
COPY app /app
EXPOSE 8000
# Use uvicorn to serve the FastAPI app
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]