Update Dockerfile
Browse files- Dockerfile +14 -10
Dockerfile
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
|
|
| 1 |
FROM python:3.9-slim
|
| 2 |
|
| 3 |
-
#
|
|
|
|
|
|
|
|
|
|
| 4 |
WORKDIR /app
|
| 5 |
|
| 6 |
-
# Install system dependencies
|
| 7 |
RUN apt-get update && apt-get install -y \
|
| 8 |
ffmpeg \
|
| 9 |
libgl1 \
|
|
@@ -13,22 +17,22 @@ RUN apt-get update && apt-get install -y \
|
|
| 13 |
libxext6 \
|
| 14 |
&& rm -rf /var/lib/apt/lists/*
|
| 15 |
|
| 16 |
-
# Copy
|
| 17 |
COPY requirements.txt .
|
| 18 |
COPY packages.txt .
|
| 19 |
|
| 20 |
# Install Python dependencies
|
| 21 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 22 |
|
| 23 |
-
# Copy application
|
| 24 |
COPY . .
|
| 25 |
|
| 26 |
-
#
|
| 27 |
-
EXPOSE
|
| 28 |
|
| 29 |
-
#
|
| 30 |
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
| 31 |
-
CMD curl -f http://localhost
|
| 32 |
|
| 33 |
-
# Run the application
|
| 34 |
-
CMD ["streamlit", "run", "app.py", "--server.port
|
|
|
|
| 1 |
+
# Use a lightweight Python base image
|
| 2 |
FROM python:3.9-slim
|
| 3 |
|
| 4 |
+
# Optionally allow overriding port at build time
|
| 5 |
+
ARG PORT=7860
|
| 6 |
+
ENV PORT=${PORT}
|
| 7 |
+
|
| 8 |
WORKDIR /app
|
| 9 |
|
| 10 |
+
# Install system dependencies needed by many ML/AI and media libraries
|
| 11 |
RUN apt-get update && apt-get install -y \
|
| 12 |
ffmpeg \
|
| 13 |
libgl1 \
|
|
|
|
| 17 |
libxext6 \
|
| 18 |
&& rm -rf /var/lib/apt/lists/*
|
| 19 |
|
| 20 |
+
# Copy dependency files first to leverage Docker cache
|
| 21 |
COPY requirements.txt .
|
| 22 |
COPY packages.txt .
|
| 23 |
|
| 24 |
# Install Python dependencies
|
| 25 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 26 |
|
| 27 |
+
# Copy application code
|
| 28 |
COPY . .
|
| 29 |
|
| 30 |
+
# Ensure your app uses the PORT environment variable
|
| 31 |
+
EXPOSE ${PORT}
|
| 32 |
|
| 33 |
+
# Healthcheck (adjust the path if your app uses a different one)
|
| 34 |
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
| 35 |
+
CMD curl -f http://localhost:${PORT}/_stcore/health || exit 1
|
| 36 |
|
| 37 |
+
# Run the application — make sure your app or command respects $PORT
|
| 38 |
+
CMD ["streamlit", "run", "app.py", "--server.port=${PORT}", "--server.address=0.0.0.0"]
|