Update Dockerfile
Browse files- Dockerfile +9 -4
Dockerfile
CHANGED
|
@@ -7,21 +7,26 @@ RUN apt-get update && apt-get install -y \
|
|
| 7 |
build-essential \
|
| 8 |
&& rm -rf /var/lib/apt/lists/*
|
| 9 |
|
| 10 |
-
# Copy requirements
|
| 11 |
COPY requirements.txt .
|
| 12 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 13 |
|
| 14 |
-
# Copy application
|
| 15 |
COPY app.py .
|
| 16 |
|
| 17 |
-
# Create data directory
|
| 18 |
RUN mkdir -p ./data
|
| 19 |
|
| 20 |
# Expose port
|
| 21 |
EXPOSE 7860
|
| 22 |
|
| 23 |
-
# Set environment
|
|
|
|
| 24 |
ENV PYTHONUNBUFFERED=1
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
# Run the application
|
| 27 |
CMD ["python", "app.py"]
|
|
|
|
| 7 |
build-essential \
|
| 8 |
&& rm -rf /var/lib/apt/lists/*
|
| 9 |
|
| 10 |
+
# Copy requirements first for better caching
|
| 11 |
COPY requirements.txt .
|
| 12 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 13 |
|
| 14 |
+
# Copy application
|
| 15 |
COPY app.py .
|
| 16 |
|
| 17 |
+
# Create data directory
|
| 18 |
RUN mkdir -p ./data
|
| 19 |
|
| 20 |
# Expose port
|
| 21 |
EXPOSE 7860
|
| 22 |
|
| 23 |
+
# Set environment variables
|
| 24 |
+
ENV PORT=7860
|
| 25 |
ENV PYTHONUNBUFFERED=1
|
| 26 |
|
| 27 |
+
# Health check
|
| 28 |
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
| 29 |
+
CMD python -c "import requests; requests.get('http://localhost:7860/health')" || exit 1
|
| 30 |
+
|
| 31 |
# Run the application
|
| 32 |
CMD ["python", "app.py"]
|