efficientnet-b0-mlop / Dockerfile
thk354777
deploy
6bf9a0e
# Dockerfile
# ใช้ slim version เพื่อลดขนาด image พื้นฐาน
FROM python:3.10-slim
# กำหนด Working Directory
WORKDIR /app
# อัปเดตและติดตั้งระบบพื้นฐานที่จำเป็นสำหรับ ONNX/OpenCV (ถ้ามี) แบบลดขยะ
RUN apt-get update && apt-get install -y --no-install-recommends \
libglib2.0-0 \
&& rm -rf /var/lib/apt/lists/*
# ติดตั้ง Dependencies โดยบังคับใช้ PyTorch แบบ CPU-only เพื่อให้ Image มีขนาดเล็กลงมาก (ประหยัดไปได้หลาย GB)
COPY requirements.txt .
RUN pip install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cpu \
&& pip install --no-cache-dir -r requirements.txt
# คัดลอกซอร์สโค้ดและโฟลเดอร์ model มาที่ Container
COPY . .
# เปิด Port
EXPOSE 8000
# รัน FastAPI ผ่าน Uvicorn
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]