2026-01-28 06:16:04 +00:00

35 lines
762 B
Docker

FROM python:3.9-slim
WORKDIR /app
# 安裝系統依賴
RUN apt-get update && apt-get install -y \
build-essential \
curl \
&& rm -rf /var/lib/apt/lists/*
# 複製requirements文件並安裝Python依賴
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# 複製應用代碼
COPY . .
# 創建必要的目錄
RUN mkdir -p /app/uploads /app/outputs
# 設置環境變量
ENV ONNX_UPLOAD_FOLDER=/app/uploads
ENV ONNX_OUTPUT_FOLDER=/app/outputs
ENV ONNX_API_KEY=onnx-secret-key
# 暴露端口
EXPOSE 5001
# 健康檢查
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:5001/health || exit 1
# 啟動命令
CMD ["python", "main.py"]