This commit is contained in:
jouel88 2026-05-04 22:33:52 +07:00
commit 1741696a08
2 changed files with 51 additions and 0 deletions

31
Dockerfile Normal file
View File

@ -0,0 +1,31 @@
FROM python:3.10-slim
# Set working directory
WORKDIR /app
# Install dependencies sistem untuk OpenCV & Build tools
RUN apt-get update && apt-get install -y \
build-essential \
libgl1 \
libglib2.0-0 \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements
COPY requirements.txt .
# Install python libraries
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt \
&& pip install --no-cache-dir gunicorn # Tambahkan gunicorn
# Copy seluruh file project
COPY . .
# Pastikan folder storage tersedia dengan permission yang benar
RUN mkdir -p storage/face_datasets storage/face_models storage/temp
# Buka port (di Flask script kamu pakai 5000, tapi di docker kita arahkan ke 8000 agar konsisten dengan compose)
EXPOSE 8000
# Jalankan menggunakan Gunicorn (4 worker biasanya cukup untuk Ryzen 5600G)
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "--workers", "4", "app:app"]

20
docker-compose.yml Normal file
View File

@ -0,0 +1,20 @@
services:
api-hrismp-ml:
build: .
container_name: api_hrismp_face
restart: unless-stopped
ports:
- "8002:8000"
environment:
- FLASK_ML_API_KEY=dev-api-key-mpg-hris
volumes:
- .:/app
- hrismp_storage:/app/storage
networks:
- hrismp-network
volumes:
hrismp_storage:
networks:
hrismp-network:
driver: bridge