Upload Dockerfile with huggingface_hub
Browse files- Dockerfile +27 -16
Dockerfile
CHANGED
|
@@ -1,31 +1,42 @@
|
|
| 1 |
-
# Use
|
| 2 |
FROM python:3.9-slim
|
| 3 |
|
| 4 |
-
# Set
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
build-essential \
|
| 10 |
-
|
| 11 |
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
|
| 13 |
-
# Copy
|
| 14 |
COPY requirements.txt .
|
| 15 |
|
| 16 |
-
# Install
|
| 17 |
-
RUN pip install --no-cache-dir -
|
| 18 |
-
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
# Copy
|
| 21 |
COPY . .
|
| 22 |
|
| 23 |
-
# Create
|
| 24 |
-
RUN mkdir -p data
|
| 25 |
|
| 26 |
-
# Expose
|
| 27 |
EXPOSE 7860
|
| 28 |
|
| 29 |
-
#
|
| 30 |
-
|
| 31 |
-
CMD
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use Python 3.9 slim image
|
| 2 |
FROM python:3.9-slim
|
| 3 |
|
| 4 |
+
# Set working directory
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# Set environment variables
|
| 8 |
+
ENV PYTHONUNBUFFERED=1 \
|
| 9 |
+
PYTHONDONTWRITEBYTECODE=1 \
|
| 10 |
+
PIP_NO_CACHE_DIR=1 \
|
| 11 |
+
PIP_DISABLE_PIP_VERSION_CHECK=1
|
| 12 |
+
|
| 13 |
+
# Install system dependencies
|
| 14 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 15 |
build-essential \
|
| 16 |
+
libgomp1 \
|
| 17 |
&& rm -rf /var/lib/apt/lists/*
|
| 18 |
|
| 19 |
+
# Copy requirements first for better caching
|
| 20 |
COPY requirements.txt .
|
| 21 |
|
| 22 |
+
# Install Python dependencies
|
| 23 |
+
RUN pip install --no-cache-dir --upgrade pip && \
|
| 24 |
+
pip install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cpu && \
|
| 25 |
+
pip install --no-cache-dir -r requirements.txt && \
|
| 26 |
+
pip install --no-cache-dir gunicorn
|
| 27 |
|
| 28 |
+
# Copy application code
|
| 29 |
COPY . .
|
| 30 |
|
| 31 |
+
# Create necessary directories
|
| 32 |
+
RUN mkdir -p data checkpoints plots
|
| 33 |
|
| 34 |
+
# Expose port
|
| 35 |
EXPOSE 7860
|
| 36 |
|
| 37 |
+
# Health check
|
| 38 |
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
| 39 |
+
CMD python -c "import requests; requests.get('http://localhost:7860')" || exit 1
|
| 40 |
+
|
| 41 |
+
# Run the application
|
| 42 |
+
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "1", "--timeout", "120", "app:app"]
|