Update Dockerfile
Browse files- Dockerfile +10 -32
Dockerfile
CHANGED
|
@@ -1,48 +1,26 @@
|
|
| 1 |
-
# Use Python
|
| 2 |
FROM python:3.12
|
| 3 |
|
| 4 |
-
# Set working directory
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
-
curl \
|
| 10 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 11 |
|
| 12 |
-
#
|
| 13 |
-
|
| 14 |
-
RUN pip install --no-cache-dir -r requirements.txt
|
| 15 |
|
| 16 |
-
# Create non-root user
|
| 17 |
RUN useradd -m -u 1000 user
|
|
|
|
| 18 |
|
| 19 |
# Set user environment variables
|
| 20 |
ENV HOME=/home/user \
|
| 21 |
PATH=/home/user/.local/bin:$PATH
|
| 22 |
|
| 23 |
-
# Set working directory to user's app directory
|
| 24 |
WORKDIR $HOME/app
|
| 25 |
|
| 26 |
-
# Copy application files with correct ownership
|
| 27 |
COPY --chown=user . $HOME/app
|
| 28 |
|
| 29 |
-
#
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
# Expose Hugging Face Spaces standard port
|
| 33 |
-
EXPOSE 7860
|
| 34 |
-
|
| 35 |
-
# Health check for container monitoring
|
| 36 |
-
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
|
| 37 |
-
CMD curl --fail http://localhost:7860/_stcore/health || exit 1
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
# Run Streamlit on port 7860 with production settings
|
| 41 |
-
CMD ["streamlit", "run", "app.py", \
|
| 42 |
-
"--server.port=7860", \
|
| 43 |
-
"--server.address=0.0.0.0", \
|
| 44 |
-
"--server.headless=true", \
|
| 45 |
-
"--server.fileWatcherType=none", \
|
| 46 |
-
"--browser.gatherUsageStats=false", \
|
| 47 |
-
"--server.enableCORS=false", \
|
| 48 |
-
"--server.enableXsrfProtection=false"]
|
|
|
|
| 1 |
+
# Use Python 3.12
|
| 2 |
FROM python:3.12
|
| 3 |
|
| 4 |
+
# Set the working directory inside the container to /app
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# Copy all files from the current directory on the host to the container's /app directory
|
| 8 |
+
COPY . .
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
# Install Python dependencies listed in requirements.txt
|
| 11 |
+
RUN pip3 install -r requirements.txt
|
|
|
|
| 12 |
|
| 13 |
+
# Create non-root user
|
| 14 |
RUN useradd -m -u 1000 user
|
| 15 |
+
USER user
|
| 16 |
|
| 17 |
# Set user environment variables
|
| 18 |
ENV HOME=/home/user \
|
| 19 |
PATH=/home/user/.local/bin:$PATH
|
| 20 |
|
|
|
|
| 21 |
WORKDIR $HOME/app
|
| 22 |
|
|
|
|
| 23 |
COPY --chown=user . $HOME/app
|
| 24 |
|
| 25 |
+
# Run Streamlit on port 7860 (HF Spaces default, not 8501)
|
| 26 |
+
CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0", "--server.enableXsrfProtection=false"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|