compliance/docker/Dockerfile.simple
gongwenxin fa343eb111 .
2025-08-07 15:07:38 +08:00

66 lines
1.7 KiB
Docker
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# DMS合规性测试工具 - 简单多服务镜像不使用supervisor
FROM python:3.9-slim
# 设置维护者信息
LABEL maintainer="DMS Team"
LABEL description="DMS Compliance Testing Tool - Multi Service"
LABEL version="1.0.0"
# 设置工作目录
WORKDIR /app
# 设置环境变量
ENV PYTHONPATH=/app
ENV PYTHONUNBUFFERED=1
ENV FLASK_ENV=production
# 安装系统依赖
RUN apt-get update && apt-get install -y \
# 字体支持
fonts-dejavu-core \
fonts-liberation \
fonts-wqy-zenhei \
fontconfig \
# 网络工具(用于健康检查)
curl \
# 清理缓存
&& rm -rf /var/lib/apt/lists/* \
&& fc-cache -fv
# 创建非root用户
RUN useradd --create-home --shell /bin/bash dms && \
chown -R dms:dms /app
# 复制requirements文件并安装Python依赖
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# 复制应用代码
COPY --chown=dms:dms . .
# 复制启动脚本
COPY --chown=dms:dms docker/start_services.sh /app/start_services.sh
# 创建必要的目录并设置权限
RUN mkdir -p /app/test_reports \
&& mkdir -p /app/uploads \
&& mkdir -p /app/assets/fonts \
&& mkdir -p /app/logs \
&& chown -R dms:dms /app \
&& chmod +x /app/*.py \
&& chmod +x /app/start_services.sh
# 切换到非root用户
USER dms
# 暴露端口(两个服务的端口)
EXPOSE 5050 5051
# 健康检查(检查主服务)
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
CMD curl -f http://localhost:5050/ && curl -f http://localhost:5051/ || exit 1
# 启动命令(使用自定义脚本管理多个进程)
CMD ["/app/start_services.sh"]