testd / Dockerfile
Ayushnangia's picture
new Dockerfile with huggingface based new user
11a1f15 verified
# Use Python 3.10 slim image based on Debian Buster as the base image
FROM python:3.10-slim-buster
# Set up system dependencies required for Chrome and general utilities
USER root
RUN apt-get update && apt-get install -y \
software-properties-common \
wget \
curl \
unzip \
xvfb \
libxi6 \
libgconf-2-4 \
fonts-liberation \
libasound2 \
libatk-bridge2.0-0 \
libatk1.0-0 \
libatspi2.0-0 \
libcairo2 \
libcups2 \
libdbus-1-3 \
libglib2.0-0 \
libgtk-3-0 \
libnspr4 \
libnss3 \
libpango-1.0-0 \
libxcomposite1 \
libxdamage1 \
libxkbcommon0 \
libvulkan1 \
libu2f-udev \
libgbm1 \
xdg-utils \
libcurl4 \
--no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Download and install Google Chrome
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
&& apt install ./google-chrome-stable_current_amd64.deb -y \
&& rm ./google-chrome-stable_current_amd64.deb
# Download and install Chromedriver
RUN LATEST=`curl -sSL https://chromedriver.storage.googleapis.com/LATEST_RELEASE` && \
wget -N http://chromedriver.storage.googleapis.com/$LATEST/chromedriver_linux64.zip -P ~/ && \
unzip ~/chromedriver_linux64.zip -d ~/ && \
rm ~/chromedriver_linux64.zip && \
mv -f ~/chromedriver /usr/local/bin/chromedriver && \
chown root:root /usr/local/bin/chromedriver && \
chmod 0755 /usr/local/bin/chromedriver
# Set up a new user named "user" with user ID 1000 and switch to it
RUN useradd -m -u 1000 user
USER user
# Set environment variables
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH \
DISPLAY=:99
# Set the working directory to the user's home directory/app
WORKDIR $HOME/app
# Copy the current directory contents into the container at $HOME/app and set the owner to the user
COPY --chown=user . $HOME/app
# Install Python dependencies with specific versions
RUN pip3 install --no-cache-dir --upgrade -r requirements.txt
# Expose port 7860 for the Gradio app
EXPOSE 7860
# Command to run the application
CMD ["python", "app.py"]