Spaces:
Running
Running
# Use the official Python image as the base image | |
FROM python:3.10-slim | |
# Install essential build tools | |
RUN apt-get update && apt-get install -y \ | |
build-essential \ | |
curl \ | |
git \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Set up a new user named "user" with user ID 1000 | |
RUN useradd -m -u 1000 user | |
# Switch to the "user" user | |
USER user | |
# Set home to the user's home directory and update PATH | |
ENV HOME=/home/user \ | |
PATH=/home/user/.local/bin:$PATH | |
# Set the working directory to the user's home directory/app | |
WORKDIR $HOME/app | |
# Upgrade pip and install dependencies from requirements.txt | |
RUN pip install --no-cache-dir --upgrade pip | |
# Copy the requirements.txt and app.py into the container at $HOME/app | |
# Use the --chown flag to ensure the copied files are owned by the user | |
COPY --chown=user requirements.txt $HOME/app/ | |
COPY --chown=user app.py $HOME/app/ | |
COPY --chown=user ./src/ $HOME/app/ | |
# Install Python dependencies | |
RUN pip install --no-cache-dir -r requirements.txt | |
RUN mkdir $HOME/app/github_repo | |
# Use the user's home directory as the working directory | |
WORKDIR $HOME/app | |
# Run your app. Adjust the command if your app starts differently. | |
CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"] |