-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
57 lines (43 loc) · 1.68 KB
/
Dockerfile
File metadata and controls
57 lines (43 loc) · 1.68 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# =============================================================================
# Simprint Extension Sync Server Dockerfile
# =============================================================================
# 构建: docker build -t simprint-extension-sync .
# 运行: docker run -d -p 8080:8080 -v "$(pwd)/configs:/app/configs:ro" simprint-extension-sync
# =============================================================================
FROM python:3.12-slim AS runtime
# 设置环境变量
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
TZ=Asia/Shanghai
# 安装运行时依赖
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
&& rm -rf /var/lib/apt/lists/* \
&& ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
&& echo $TZ > /etc/timezone
# 创建非 root 用户
RUN useradd --create-home --shell /bin/bash appuser
WORKDIR /app
# 创建虚拟环境
RUN python -m venv /app/.venv
ENV PATH="/app/.venv/bin:$PATH"
# 安装 wheel 构建产物
COPY dist/*.whl /tmp/dist/
RUN pip install --no-cache-dir /tmp/dist/*.whl \
&& rm -rf /tmp/dist
# 复制运行时配置与入口
COPY --chown=appuser:appuser configs/ ./configs/
COPY --chown=appuser:appuser docker-entrypoint.sh ./docker-entrypoint.sh
# 创建存储目录
RUN mkdir -p /app/storage \
&& chmod +x /app/docker-entrypoint.sh \
&& chown -R appuser:appuser /app
# 切换到非 root 用户
USER appuser
# 暴露端口
EXPOSE 8080
# 健康检查
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import httpx; httpx.get('http://localhost:8080/health')" || exit 1
# 启动命令
ENTRYPOINT ["./docker-entrypoint.sh"]