Files
stock-info-crawler/Dockerfile
2025-09-03 16:47:02 +08:00

36 lines
689 B
Docker
Raw 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.

# Dockerfile
FROM python:3.11-slim
# 設定工作目錄
WORKDIR /app
# 安裝系統依賴
RUN apt-get update && apt-get install -y \
curl \
&& rm -rf /var/lib/apt/lists/*
# 複製需求檔案
COPY requirements.txt .
# 安裝 Python 依賴
RUN pip install --no-cache-dir -r requirements.txt
# 複製應用程式檔案
COPY . .
# 創建資料目錄
RUN mkdir -p /app/data /app/logs
# 設定環境變數
ENV PYTHONPATH=/app
ENV PYTHONUNBUFFERED=1
# 健康檢查
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python health_check.py || exit 1
# 暴露端口(用於健康檢查 API
EXPOSE 8080
# 執行爬蟲
CMD ["python", "crawler.py"]