Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +13 -29
Dockerfile
CHANGED
|
@@ -1,39 +1,23 @@
|
|
| 1 |
-
# Use
|
| 2 |
FROM python:3.9-slim
|
| 3 |
|
| 4 |
# Set the working directory in the container
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
RUN apt-get update && apt-get install -y \
|
| 9 |
-
gcc \
|
| 10 |
-
g++ \
|
| 11 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
-
|
| 13 |
-
# Copy the requirements file into the container at /app
|
| 14 |
COPY requirements.txt .
|
| 15 |
|
| 16 |
-
# Install
|
| 17 |
-
# Using --no-cache-dir to
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
COPY . .
|
| 22 |
-
|
| 23 |
-
# Create a non-root user for security
|
| 24 |
-
RUN useradd --create-home --shell /bin/bash streamlit
|
| 25 |
-
RUN chown -R streamlit:streamlit /app
|
| 26 |
-
USER streamlit
|
| 27 |
|
| 28 |
-
#
|
| 29 |
-
|
| 30 |
|
| 31 |
-
#
|
| 32 |
-
|
| 33 |
-
ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0
|
| 34 |
-
ENV STREAMLIT_SERVER_HEADLESS=true
|
| 35 |
-
ENV STREAMLIT_SERVER_ENABLE_CORS=false
|
| 36 |
-
ENV STREAMLIT_SERVER_ENABLE_XSRF_PROTECTION=false
|
| 37 |
|
| 38 |
-
#
|
| 39 |
-
CMD ["streamlit", "run", "app.py"]
|
|
|
|
| 1 |
+
# Use a slim Python base image
|
| 2 |
FROM python:3.9-slim
|
| 3 |
|
| 4 |
# Set the working directory in the container
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# Copy the requirements file into the container
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
COPY requirements.txt .
|
| 9 |
|
| 10 |
+
# Install the Python dependencies
|
| 11 |
+
# Using --no-cache-dir to save space
|
| 12 |
+
# Using find . -type d -name "__pycache__" -exec rm -rf {} +; to clean up __pycache__
|
| 13 |
+
RUN pip install --no-cache-dir -r requirements.txt && \
|
| 14 |
+
find . -type d -name "__pycache__" -exec rm -rf {} +;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
+
# Copy the Streamlit application file into the container
|
| 17 |
+
COPY app.py .
|
| 18 |
|
| 19 |
+
# Expose the port Streamlit runs on (default for Hugging Face Spaces is 7860)
|
| 20 |
+
EXPOSE 7860
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
+
# Define the command to run the Streamlit application
|
| 23 |
+
CMD ["streamlit", "run", "app.py", "--server.port", "7860", "--server.enableCORS", "false", "--server.enableXsrfProtection", "false"]
|