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

69 lines
1.7 KiB
Desktop File
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合规性测试工具 - 服务运行镜像
FROM python:3.9-slim
# 设置维护者信息
LABEL maintainer="DMS Team"
LABEL description="DMS Compliance Testing Tool"
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 \
#
supervisor \
#
&& 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 . .
# 创建必要的目录并设置权限
RUN mkdir -p /app/test_reports \
&& mkdir -p /app/uploads \
&& mkdir -p /app/assets/fonts \
&& mkdir -p /app/logs \
&& mkdir -p /etc/supervisor/conf.d \
&& mkdir -p /var/log/supervisor \
&& chown -R dms:dms /app \
&& chmod +x /app/*.py
# 复制supervisor配置
COPY docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# 切换到非root用户
USER dms
# 暴露端口(两个服务的端口)
EXPOSE 5050 5051
# 健康检查(检查主服务)
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:5050/ || exit 1
# 启动命令使用supervisor管理多个进程
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]