Spaces:
Sleeping
Sleeping
# Use Python 3.11 as base image | |
FROM python:3.11 | |
# Install sudo and other required packages first (as root) | |
RUN apt-get update && \ | |
apt-get install -y sudo && \ | |
apt-get install -y \ | |
apt-transport-https \ | |
ca-certificates \ | |
curl \ | |
gnupg \ | |
lsb-release && \ | |
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg && \ | |
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null && \ | |
apt-get update && \ | |
apt-get install -y docker-ce docker-ce-cli containerd.io | |
# Set up a new user named "user" with user ID 1000 (as recommended by HF) | |
RUN useradd -m -u 1000 user && \ | |
echo "user ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers | |
# Switch to the "user" user | |
USER user | |
# Set home to the user's home directory | |
ENV HOME=/home/user \ | |
PATH=/home/user/.local/bin:$PATH | |
# Set the working directory to the user's home directory | |
WORKDIR $HOME/app | |
# Install Python dependencies | |
COPY --chown=user requirements.txt . | |
RUN pip install --no-cache-dir --upgrade pip && \ | |
pip install --no-cache-dir -r requirements.txt | |
# Copy the application files | |
COPY --chown=user . . | |
# Expose the port that Gradio will run on | |
EXPOSE 7860 | |
# Run the application | |
CMD ["python", "app.py"] |