Spaces:
Build error
Build error
Muhammad Ridzki Nugraha commited on
Upload Dockerfile with huggingface_hub
Browse files- Dockerfile +40 -0
Dockerfile
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Dockerfile untuk deployment AI Model ke Google Cloud Run
|
| 2 |
+
FROM python:3.11-slim
|
| 3 |
+
|
| 4 |
+
ENV PYTHONDONTWRITEBYTECODE=1
|
| 5 |
+
ENV PYTHONUNBUFFERED=1
|
| 6 |
+
ENV PORT=7860
|
| 7 |
+
|
| 8 |
+
RUN apt-get update && apt-get install -y \
|
| 9 |
+
gcc \
|
| 10 |
+
g++ \
|
| 11 |
+
libgomp1 \
|
| 12 |
+
curl \
|
| 13 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 14 |
+
|
| 15 |
+
WORKDIR /app
|
| 16 |
+
|
| 17 |
+
COPY requirements.txt .
|
| 18 |
+
|
| 19 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 20 |
+
|
| 21 |
+
COPY api/ ./api/
|
| 22 |
+
COPY data/ ./data/
|
| 23 |
+
COPY models/ ./models/
|
| 24 |
+
COPY training/ ./training/
|
| 25 |
+
COPY scripts/ ./scripts/
|
| 26 |
+
COPY tests/ ./tests/
|
| 27 |
+
|
| 28 |
+
# Create necessary directories with permissions
|
| 29 |
+
RUN mkdir -p /app/data /app/models /app/logs && \
|
| 30 |
+
useradd -m -u 1000 appuser && \
|
| 31 |
+
chown -R appuser:appuser /app
|
| 32 |
+
|
| 33 |
+
USER appuser
|
| 34 |
+
|
| 35 |
+
EXPOSE 7860
|
| 36 |
+
|
| 37 |
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
| 38 |
+
CMD sh -lc 'curl -f http://localhost:${PORT}/health || exit 1'
|
| 39 |
+
|
| 40 |
+
CMD ["sh", "-lc", "uvicorn api.main:app --host 0.0.0.0 --port ${PORT:-7860} --workers 2"]
|