Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +36 -11
Dockerfile
CHANGED
|
@@ -1,23 +1,48 @@
|
|
| 1 |
-
# Use
|
| 2 |
-
FROM python:3.9
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
-
# Set the working directory inside the container to /app
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
# Install Python
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
RUN useradd -m -u 1000 user
|
| 14 |
USER user
|
| 15 |
ENV HOME=/home/user \
|
| 16 |
-
|
| 17 |
|
|
|
|
| 18 |
WORKDIR $HOME/app
|
| 19 |
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
-
#
|
| 23 |
CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0", "--server.enableXsrfProtection=false"]
|
|
|
|
| 1 |
+
# Use minimal Python 3.9 base (keeps with your requirement)
|
| 2 |
+
FROM python:3.9-slim
|
| 3 |
+
|
| 4 |
+
# set a consistent locale (optional but sometimes avoids warnings)
|
| 5 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 6 |
|
|
|
|
| 7 |
WORKDIR /app
|
| 8 |
|
| 9 |
+
# Install minimal system deps needed for building some packages (xgboost sometimes needs libgomp)
|
| 10 |
+
# If you know you don't need build tools, you can remove build-essential.
|
| 11 |
+
RUN apt-get update && \
|
| 12 |
+
apt-get install -y --no-install-recommends \
|
| 13 |
+
build-essential \
|
| 14 |
+
libgomp1 \
|
| 15 |
+
ca-certificates \
|
| 16 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 17 |
+
|
| 18 |
+
# Copy project files first to leverage Docker cache for pip installs when requirements don't change
|
| 19 |
+
COPY . /app
|
| 20 |
+
|
| 21 |
+
# Upgrade pip & setuptools first (important for picking up newer wheels)
|
| 22 |
+
RUN python -m pip install --upgrade pip setuptools wheel
|
| 23 |
|
| 24 |
+
# Install Python deps (use the Python 3.9 compatible requirements file)
|
| 25 |
+
# Use --no-cache-dir to keep image small
|
| 26 |
+
RUN pip install --no-cache-dir -r requirements-py39.txt
|
| 27 |
+
|
| 28 |
+
# Create an unprivileged user and move app into their home with ownership
|
| 29 |
+
RUN useradd -m -u 1000 user \
|
| 30 |
+
&& mkdir -p /home/user/app \
|
| 31 |
+
&& chown -R user:user /home/user/app /app
|
| 32 |
|
|
|
|
| 33 |
USER user
|
| 34 |
ENV HOME=/home/user \
|
| 35 |
+
PATH=/home/user/.local/bin:$PATH
|
| 36 |
|
| 37 |
+
# Use the home app directory for runtime; copy project into it using appropriate ownership already set
|
| 38 |
WORKDIR $HOME/app
|
| 39 |
|
| 40 |
+
# Ensure the app files are available in the user's app dir (you may already have them in /app)
|
| 41 |
+
# If your COPY above already put files into /app and you want them in /home/user/app:
|
| 42 |
+
RUN cp -r /app/* $HOME/app/ || true
|
| 43 |
+
|
| 44 |
+
# Expose Streamlit port (optional metadata)
|
| 45 |
+
EXPOSE 8501
|
| 46 |
|
| 47 |
+
# Run streamlit (disable XSRF if you intentionally want that; be cautious in production)
|
| 48 |
CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0", "--server.enableXsrfProtection=false"]
|