Initial commit: SMS Forwarder project with Docker support
This commit is contained in:
37
Dockerfile
Normal file
37
Dockerfile
Normal file
@ -0,0 +1,37 @@
|
||||
FROM python:3.10-slim
|
||||
|
||||
# 设置工作目录
|
||||
WORKDIR /app
|
||||
|
||||
# 安装系统依赖
|
||||
RUN apt-get update && apt-get install -y \
|
||||
curl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 安装 uv
|
||||
RUN pip install uv
|
||||
|
||||
# 复制项目文件
|
||||
COPY pyproject.toml .
|
||||
COPY sms_forwarder/ ./sms_forwarder/
|
||||
|
||||
# 安装 Python 依赖
|
||||
RUN uv sync --frozen
|
||||
|
||||
# 创建必要目录
|
||||
RUN mkdir -p logs data
|
||||
|
||||
# 创建非 root 用户
|
||||
RUN useradd --create-home --shell /bin/bash app
|
||||
RUN chown -R app:app /app
|
||||
USER app
|
||||
|
||||
# 暴露端口(使用配置文件中的端口)
|
||||
EXPOSE 12152
|
||||
|
||||
# 健康检查
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||
CMD curl -f http://localhost:12152/health || exit 1
|
||||
|
||||
# 启动命令
|
||||
CMD ["uv", "run", "python", "-m", "sms_forwarder.main"]
|
Reference in New Issue
Block a user