diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7e0d66c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +# 使用 Python 3.12 官方镜像 +FROM python:3.12-slim + +# 设置工作目录 +WORKDIR /app + +# 设置环境变量 +ENV PYTHONPATH=/app +ENV PYTHONDONTWRITEBYTECODE=1 +ENV PYTHONUNBUFFERED=1 + +# 安装系统依赖(如果需要连接 PostgreSQL) +RUN apt-get update && apt-get install -y \ + gcc \ + postgresql-dev \ + && rm -rf /var/lib/apt/lists/* + +# 复制 requirements.txt 并安装 Python 依赖 +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +# 复制项目文件 +COPY . . + +# 设置启动命令 +CMD ["python", "main.py"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..4eb2286 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +services: + factorsimulator: + build: + context: . + dockerfile: Dockerfile + container_name: factor-simulator + environment: + - PYTHONPATH=/app + restart: unless-stopped \ No newline at end of file