# Switched to bookworm for newer system libraries and GCC 12+ FROM python:3.11-slim-bookworm ENV DEBIAN_FRONTEND=noninteractive \ PYTHONUNBUFFERED=1 \ # Ensure CMake finds the libraries we install in /usr CMAKE_PREFIX_PATH=/usr # 1. Install System Dependencies & Build Tools # Added: libgl1-mesa-glx/dri (Fixes Chrome black screen), libcurl4-openssl-dev (for WebRTC) RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ pkg-config \ cmake \ git \ libswscale-dev \ libavutil-dev \ python3-dev \ xvfb \ x11-utils \ x11-xserver-utils \ xdotool \ matchbox-window-manager \ # X11 Development Headers libx11-dev \ libxtst-dev \ libxext-dev \ libxrandr-dev \ libxfixes-dev \ libxcomposite-dev \ libxcursor-dev \ libxdamage-dev \ libxi-dev \ libxss-dev \ # Media & Encoding libssl-dev \ libx264-dev \ libavcodec-dev \ libavdevice-dev \ libavfilter-dev \ libavformat-dev \ libavutil-dev \ libswscale-dev \ libswresample-dev \ libvpx-dev \ libopus-dev \ # Software Rendering (Crucial for Xvfb/Chrome) libgl1-mesa-dri \ libgl1-mesa-glx \ mesa-utils \ libgbm1 \ libasound2 \ # Chrome/Electron Deps libnss3 \ libatk1.0-0 \ libatk-bridge2.0-0 \ libcups2 \ libdrm2 \ libpangocairo-1.0-0 \ libgtk-3-0 \ fonts-liberation \ fonts-noto-color-emoji \ # Utilities wget \ curl \ gnupg \ procps \ ca-certificates \ unzip \ && rm -rf /var/lib/apt/lists/* # 2. Build and Install LibDataChannel (C++ WebRTC Library) # We explicitely use CMAKE_INSTALL_PREFIX=/usr to ensure pkg-config finds it later RUN cd /tmp && \ git clone https://github.com/paullouisageneau/libdatachannel.git && \ cd libdatachannel && \ git submodule update --init --recursive && \ cmake -B build \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr \ -DUSE_GNUTLS=0 \ -DUSE_NICE=0 \ -DNO_WEBSOCKET=OFF \ -DNO_EXAMPLES=ON \ -DNO_TESTS=ON && \ cmake --build build -j$(nproc) && \ cmake --install build && \ ldconfig && \ cd .. && rm -rf libdatachannel # 3. Install Chrome RUN wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && \ apt-get update && \ apt-get install -y ./google-chrome-stable_current_amd64.deb && \ rm google-chrome-stable_current_amd64.deb && \ rm -rf /var/lib/apt/lists/* # 4. Configure Chrome Wrapper (Sandbox disabled for Docker) RUN mv /usr/bin/google-chrome /usr/bin/google-chrome-orig && \ echo '#!/bin/bash\n/usr/bin/google-chrome-orig --no-sandbox --start-maximized --no-first-run --no-default-browser-check --disable-gpu-compositing --disable-dev-shm-usage "$@"' > /usr/bin/google-chrome && \ chmod +x /usr/bin/google-chrome RUN update-alternatives --install /usr/bin/x-www-browser x-www-browser /usr/bin/google-chrome 9999 # 5. Install Antigravity (With Robust GPG Key Handling) RUN mkdir -p /etc/apt/keyrings && \ curl -fsSL https://us-central1-apt.pkg.dev/doc/repo-signing-key.gpg -o /tmp/antigravity-key.gpg && \ gpg --dearmor --yes -o /etc/apt/keyrings/antigravity-repo-key.gpg /tmp/antigravity-key.gpg && \ echo "deb [signed-by=/etc/apt/keyrings/antigravity-repo-key.gpg] https://us-central1-apt.pkg.dev/projects/antigravity-auto-updater-dev/ antigravity-debian main" | tee /etc/apt/sources.list.d/antigravity.list && \ apt-get update && \ apt-get install -y antigravity && \ rm -rf /var/lib/apt/lists/* /tmp/antigravity-key.gpg # 6. User Setup RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH \ LD_LIBRARY_PATH=/usr/lib:/usr/local/lib WORKDIR $HOME/app # 7. Install Python Dependencies # We install aiohttp explicitly first because app.py needs it to compile COPY --chown=user:user requirements.txt . RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir aiohttp psutil && \ pip install --no-cache-dir -r requirements.txt # 8. Copy App and Compile Extension COPY --chown=user:user app.py . # Force compilation of the C++ extension during build time. # DISPLAY="" prevents X11 connection attempts during build. RUN DISPLAY="" python -c "import app; print('C++ Extension Compiled Successfully')" # 9. Environment Configuration ENV DISPLAY=:99 \ RESOLUTION=1280x720 \ BROWSER=/usr/bin/google-chrome EXPOSE 7860 CMD ["python", "app.py"]