-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
like:
- docker-compose.yml
version: '3.8'
services:
tickeye:
build: .
container_name: tickeye-fund-monitor
restart: unless-stopped
environment:
# 飞书配置(通过环境变量或配置文件)
- FEISHU_WEBHOOK_URL=${FEISHU_WEBHOOK_URL}
- FEISHU_ENABLED=${FEISHU_ENABLED:-true}
# 基金配置文件路径
- FUNDS_CONFIG_PATH=/app/funds_config.json
- INDICES_CONFIG_PATH=/app/indices_config.json
# 日志级别
- LOG_LEVEL=${LOG_LEVEL:-INFO}
volumes:
# 挂载配置文件(可选)
- ./config:/app/config:ro
# 挂载日志目录(可选)
- ./logs:/app/logs
# 定时任务配置
# 使用cron或外部调度器来运行定时任务
# 示例:每天早上9点运行
# command: >
# sh -c "echo '0 9 * * * python main.py' | crontab - &&
# crond -f -l 8"
# 或者手动运行
# command: python main.py
healthcheck:
test: ["CMD", "python", "-c", "import sys; sys.exit(0)"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# 网络配置
networks:
- tickeye-network
# 可选:添加Redis用于缓存(如果需要)
# redis:
# image: redis:7-alpine
# container_name: tickeye-redis
# restart: unless-stopped
# volumes:
# - redis_data:/data
# command: redis-server --appendonly yes
# networks:
# - tickeye-network
# 网络配置
networks:
tickeye-network:
driver: bridge
# 数据卷(如果启用Redis)
# volumes:
# redis_data:
# driver: local
- Dockerfile
# 使用官方Python 3.9镜像作为基础镜像
FROM python:3.9-slim
# 设置工作目录
WORKDIR /app
# 设置环境变量
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH=/app
# 安装系统依赖
RUN apt-get update && apt-get install -y \
gcc \
g++ \
&& rm -rf /var/lib/apt/lists/*
# 复制requirements文件并安装Python依赖
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# 复制应用代码
COPY . .
# 创建非root用户
RUN useradd --create-home --shell /bin/bash app && \
chown -R app:app /app
USER app
# 暴露端口(如果需要添加web界面)
EXPOSE 8000
# 健康检查
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import sys; sys.exit(0)" || exit 1
# 默认命令(使用绝对路径,避免在某些平台上工作目录被忽略导致找不到文件)
CMD ["python", "/app/main.py"]
🐳 Docker Deployment
Quick Start with Docker
# Clone the repository
git clone https://github.com/yourusername/tickeye.git
cd tickeye
# Build and run with Docker Compose
docker-compose up -d
# Run manually
docker build -t tickeye .
docker run -d --name tickeye-fund-monitor tickeyeEnvironment Variables
Create a .env file for configuration:
# Feishu notification configuration
FEISHU_WEBHOOK_URL=your_webhook_url_here
FEISHU_ENABLED=true
# Log level
LOG_LEVEL=INFODocker Configuration
The Docker setup includes:
- Multi-stage build for smaller image size
- Non-root user for security
- Health checks
- Environment variable support
- Volume mounting for configuration files
# View logs
docker-compose logs -f tickeye
# Stop the service
docker-compose down
# Rebuild and restart
docker-compose up -d --buildMetadata
Metadata
Assignees
Labels
No labels