Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +29 -13
Dockerfile
CHANGED
|
@@ -1,26 +1,42 @@
|
|
|
|
|
| 1 |
FROM python:3.10-slim
|
| 2 |
|
|
|
|
| 3 |
RUN apt-get update && apt-get install -y \
|
| 4 |
build-essential \
|
| 5 |
curl \
|
| 6 |
-
software-properties-common \
|
| 7 |
git \
|
| 8 |
&& rm -rf /var/lib/apt/lists/*
|
| 9 |
|
| 10 |
-
#
|
| 11 |
-
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
|
| 15 |
|
| 16 |
-
#
|
| 17 |
-
|
|
|
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
|
| 21 |
-
RUN pip install -r requirements.txt
|
| 22 |
|
| 23 |
-
#
|
| 24 |
-
|
| 25 |
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use the official Python image as the base image
|
| 2 |
FROM python:3.10-slim
|
| 3 |
|
| 4 |
+
# Install essential build tools
|
| 5 |
RUN apt-get update && apt-get install -y \
|
| 6 |
build-essential \
|
| 7 |
curl \
|
|
|
|
| 8 |
git \
|
| 9 |
&& rm -rf /var/lib/apt/lists/*
|
| 10 |
|
| 11 |
+
# Set up a new user named "user" with user ID 1000
|
| 12 |
+
RUN useradd -m -u 1000 user
|
| 13 |
|
| 14 |
+
# Switch to the "user" user
|
| 15 |
+
USER user
|
| 16 |
|
| 17 |
+
# Set home to the user's home directory and update PATH
|
| 18 |
+
ENV HOME=/home/user \
|
| 19 |
+
PATH=/home/user/.local/bin:$PATH
|
| 20 |
|
| 21 |
+
# Set the working directory to the user's home directory/app
|
| 22 |
+
WORKDIR $HOME/app
|
|
|
|
| 23 |
|
| 24 |
+
# Upgrade pip and install dependencies from requirements.txt
|
| 25 |
+
RUN pip install --no-cache-dir --upgrade pip
|
| 26 |
|
| 27 |
+
# Copy the requirements.txt and app.py into the container at $HOME/app
|
| 28 |
+
# Use the --chown flag to ensure the copied files are owned by the user
|
| 29 |
+
COPY --chown=user requirements.txt $HOME/app/
|
| 30 |
+
COPY --chown=user app.py $HOME/app/
|
| 31 |
+
COPY --chown=user ./src/ $HOME/app/
|
| 32 |
+
|
| 33 |
+
# Install Python dependencies
|
| 34 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 35 |
+
|
| 36 |
+
RUN mkdir $HOME/app/github_repo
|
| 37 |
+
|
| 38 |
+
# Use the user's home directory as the working directory
|
| 39 |
+
WORKDIR $HOME/app
|
| 40 |
+
|
| 41 |
+
# Run your app. Adjust the command if your app starts differently.
|
| 42 |
+
CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
|