Spaces:
Sleeping
Sleeping
Upload Dockerfile with huggingface_hub
Browse files- Dockerfile +38 -21
Dockerfile
CHANGED
|
@@ -1,21 +1,38 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use a minimal base image with Python 3.9 installed
|
| 2 |
+
FROM python:3.9-slim
|
| 3 |
+
|
| 4 |
+
# Set the working directory inside the container to /app
|
| 5 |
+
WORKDIR /app
|
| 6 |
+
|
| 7 |
+
# Create a non-root user for security and permissions
|
| 8 |
+
RUN useradd --create-home --shell /bin/bash app_user
|
| 9 |
+
|
| 10 |
+
# Create .streamlit directory with proper permissions
|
| 11 |
+
RUN mkdir -p /home/app_user/.streamlit && \
|
| 12 |
+
chown -R app_user:app_user /home/app_user/.streamlit
|
| 13 |
+
|
| 14 |
+
# Copy all files from the current directory on the host to the container's /app directory
|
| 15 |
+
COPY . .
|
| 16 |
+
|
| 17 |
+
# Install Python dependencies listed in requirements.txt
|
| 18 |
+
RUN pip3 install -r requirements.txt
|
| 19 |
+
|
| 20 |
+
# Change ownership of app directory to app_user
|
| 21 |
+
RUN chown -R app_user:app_user /app
|
| 22 |
+
|
| 23 |
+
# Switch to non-root user
|
| 24 |
+
USER app_user
|
| 25 |
+
|
| 26 |
+
# Set HOME environment variable
|
| 27 |
+
ENV HOME=/home/app_user
|
| 28 |
+
|
| 29 |
+
# Create Streamlit config to disable usage stats and set proper permissions
|
| 30 |
+
RUN mkdir -p $HOME/.streamlit && \
|
| 31 |
+
echo "[browser]" > $HOME/.streamlit/config.toml && \
|
| 32 |
+
echo "gatherUsageStats = false" >> $HOME/.streamlit/config.toml && \
|
| 33 |
+
echo "[server]" >> $HOME/.streamlit/config.toml && \
|
| 34 |
+
echo "enableXsrfProtection = false" >> $HOME/.streamlit/config.toml && \
|
| 35 |
+
echo "enableCORS = false" >> $HOME/.streamlit/config.toml
|
| 36 |
+
|
| 37 |
+
# Define the command to run the Streamlit app on port 8501 and make it accessible externally
|
| 38 |
+
CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|