Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +29 -12
Dockerfile
CHANGED
|
@@ -1,22 +1,39 @@
|
|
| 1 |
-
# Use
|
| 2 |
FROM python:3.9-slim
|
| 3 |
|
| 4 |
-
# Set
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
COPY requirements.txt .
|
| 9 |
|
| 10 |
-
# Install
|
| 11 |
-
RUN pip install --no-cache-dir -r requirements.txt
|
| 12 |
-
find . -type d -name "__pycache__" -exec rm -rf {} +;
|
| 13 |
|
| 14 |
-
# Copy the
|
| 15 |
-
COPY
|
| 16 |
|
| 17 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
EXPOSE 7860
|
| 19 |
|
| 20 |
-
#
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use Python 3.9 slim image as base
|
| 2 |
FROM python:3.9-slim
|
| 3 |
|
| 4 |
+
# Set working directory
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# Set environment variables
|
| 8 |
+
ENV PYTHONUNBUFFERED=1
|
| 9 |
+
ENV PYTHONDONTWRITEBYTECODE=1
|
| 10 |
+
|
| 11 |
+
# Install system dependencies
|
| 12 |
+
RUN apt-get update && apt-get install -y \
|
| 13 |
+
build-essential \
|
| 14 |
+
curl \
|
| 15 |
+
software-properties-common \
|
| 16 |
+
git \
|
| 17 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 18 |
+
|
| 19 |
+
# Copy requirements first for better Docker layer caching
|
| 20 |
COPY requirements.txt .
|
| 21 |
|
| 22 |
+
# Install Python dependencies
|
| 23 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
| 24 |
|
| 25 |
+
# Copy the application code
|
| 26 |
+
COPY . .
|
| 27 |
|
| 28 |
+
# Create a non-root user for security
|
| 29 |
+
RUN useradd -m -u 1000 user
|
| 30 |
+
USER user
|
| 31 |
+
|
| 32 |
+
# Expose the port that Streamlit runs on
|
| 33 |
EXPOSE 7860
|
| 34 |
|
| 35 |
+
# Health check
|
| 36 |
+
HEALTHCHECK CMD curl --fail http://localhost:7860/_stcore/health
|
| 37 |
+
|
| 38 |
+
# Command to run the application
|
| 39 |
+
CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
|