rcs / Dockerfile
karakara73's picture
initial
7ecf36d
Raw History Blame Contribute Delete
1.49 kB
# Use a stable Python base image
FROM python:3.11-slim-bookworm
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
DISPLAY=:99 \
HOME=/home/user
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
wget \
curl \
bzip2 \
libxt6 \
libdbus-glib-1-2 \
xvfb \
ffmpeg \
flac \
firefox-esr \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install geckodriver
RUN GECKO_VER=$(curl -s https://api.github.com/repos/mozilla/geckodriver/releases/latest | grep 'tag_name' | cut -d\" -f4) \
&& ARCH=$(uname -m) \
&& if [ "$ARCH" = "x86_64" ]; then PLATFORM="linux64"; else PLATFORM="linux-aarch64"; fi \
&& wget https://github.com/mozilla/geckodriver/releases/download/$GECKO_VER/geckodriver-$GECKO_VER-$PLATFORM.tar.gz \
&& tar -xzf geckodriver-$GECKO_VER-$PLATFORM.tar.gz \
&& mv geckodriver /usr/local/bin/ \
&& rm geckodriver-$GECKO_VER-$PLATFORM.tar.gz
# Create a non-root user (Required for Hugging Face Spaces)
RUN useradd -m -u 1000 user
USER user
WORKDIR $HOME/app
# Copy and 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 rest of the application
COPY --chown=user . .
# Expose the API port
EXPOSE 8002
# Run with Xvfb
CMD ["xvfb-run", "--server-args=-screen 0 1024x768x24", "python", "server.py"]