Update Dockerfile
Browse files- Dockerfile +20 -27
Dockerfile
CHANGED
@@ -1,38 +1,31 @@
|
|
1 |
-
# Use
|
2 |
FROM python:3.9-slim
|
3 |
|
4 |
-
# Set
|
5 |
WORKDIR /app
|
6 |
|
7 |
-
#
|
8 |
-
# Set the STREAMLIT_HOME environment variable to a writable directory.
|
9 |
-
ENV STREAMLIT_HOME=/app/.streamlit
|
10 |
-
|
11 |
-
# Explicitly create the directory.
|
12 |
-
RUN mkdir -p $STREAMLIT_HOME
|
13 |
-
|
14 |
-
# Copy the requirements file and application code first
|
15 |
-
COPY requirements.txt ./requirements.txt
|
16 |
-
COPY . .
|
17 |
-
|
18 |
-
# Change ownership of the app directory to the default non-root user (often 'appuser' or uid 1000)
|
19 |
-
# This is the key fix for permission errors on platforms like Hugging Face Spaces.
|
20 |
-
RUN chown -R 1000:1000 /app
|
21 |
-
|
22 |
-
# Install system dependencies that may be needed by the Python libraries
|
23 |
RUN apt-get update && apt-get install -y \
|
24 |
build-essential \
|
25 |
-
|
26 |
-
|
|
|
27 |
&& rm -rf /var/lib/apt/lists/*
|
28 |
|
29 |
-
#
|
30 |
-
|
31 |
-
pip install --no-cache-dir -r requirements.txt
|
32 |
|
33 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
EXPOSE 7860
|
35 |
|
36 |
-
#
|
37 |
-
|
38 |
-
|
|
|
|
|
|
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 |
+
# Install system dependencies
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
RUN apt-get update && apt-get install -y \
|
9 |
build-essential \
|
10 |
+
curl \
|
11 |
+
software-properties-common \
|
12 |
+
git \
|
13 |
&& rm -rf /var/lib/apt/lists/*
|
14 |
|
15 |
+
# Copy requirements first to leverage Docker cache
|
16 |
+
COPY requirements.txt .
|
|
|
17 |
|
18 |
+
# Install Python dependencies
|
19 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
20 |
+
|
21 |
+
# Copy the application code
|
22 |
+
COPY . .
|
23 |
+
|
24 |
+
# Expose the port that Streamlit runs on
|
25 |
EXPOSE 7860
|
26 |
|
27 |
+
# Add healthcheck
|
28 |
+
HEALTHCHECK CMD curl --fail http://localhost:7860/_stcore/health
|
29 |
+
|
30 |
+
# Run the Streamlit app
|
31 |
+
CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
|