Spaces:
Sleeping
Sleeping
FROM python:3.12-slim | |
# Set environment variables | |
ENV HOME=/home/user \ | |
PATH=/home/user/.local/bin:$PATH \ | |
WDM_LOCAL=1 \ | |
WDM_PATH=/tmp/.wdm \ | |
GRADIO_SERVER_NAME="0.0.0.0" \ | |
GRADIO_SERVER_PORT=7860 | |
# Install Chrome and dependencies (as root) | |
RUN apt-get update && apt-get install -y \ | |
wget \ | |
gnupg \ | |
unzip \ | |
xvfb \ | |
libxi6 \ | |
libgconf-2-4 \ | |
default-jdk \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Install Chrome (as root) | |
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \ | |
&& echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list \ | |
&& apt-get update \ | |
&& apt-get install -y google-chrome-stable \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Create a user with UID 1000 (as root) | |
RUN useradd -m -u 1000 user | |
# Set working directory | |
WORKDIR $HOME/app | |
# Copy application files (as root) | |
COPY --chown=user . $HOME/app | |
# Switch to non-root user | |
USER user | |
# Create ChromeDriver directory in app directory (as user) | |
RUN mkdir -p /tmp/.wdm && \ | |
chmod -R 777 /tmp/.wdm | |
# Install dependencies (as user) | |
RUN pip install --no-cache-dir -r requirements.txt | |
# Expose the port | |
EXPOSE 7860 | |
# Run the application (as user) | |
CMD ["python", "app.py"] |