-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile.alpine
More file actions
44 lines (34 loc) · 1000 Bytes
/
Dockerfile.alpine
File metadata and controls
44 lines (34 loc) · 1000 Bytes
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
34
35
36
37
38
39
40
41
42
43
44
# 使用 Alpine Linux 基础镜像(更小的镜像大小)
FROM python:3.10-alpine
# 设置工作目录
WORKDIR /app
# 设置环境变量
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
STREAMLIT_SERVER_PORT=8501 \
STREAMLIT_SERVER_ADDRESS=0.0.0.0 \
STREAMLIT_LOGGER_LEVEL=info
# 安装系统依赖
# Alpine 使用 apk 包管理器
RUN apk add --no-cache \
wget \
bash \
fontconfig \
ttf-liberation \
noto-cjk-fonts \
wqy-zenhei
# 复制依赖文件
COPY requirements.txt .
# 安装 Python 依赖
RUN pip install --no-cache-dir -r requirements.txt
# 复制应用代码
COPY . .
# 创建输出目录
RUN mkdir -p /app/output
# 暴露 Streamlit 端口
EXPOSE 8501
# 健康检查
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:8501/_stcore/health || exit 1
# 运行应用
CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]