# 1. Use Debian Bullseye (Stable Linux) # This ensures Python and Tkinter match perfectly to prevent the 503 crash. FROM debian:bullseye # 2. Prevent interactive prompts ENV DEBIAN_FRONTEND=noninteractive # 3. Install Python, Tkinter, and GUI tools RUN apt-get update && apt-get install -y \ python3 \ python3-pip \ python3-tk \ xvfb \ x11vnc \ fluxbox \ novnc \ net-tools \ scrot \ && rm -rf /var/lib/apt/lists/* # 4. Fix the 403 Error (Missing Index) RUN ln -s /usr/share/novnc/vnc.html /usr/share/novnc/index.html # 5. Set up work directory WORKDIR /app # 6. Copy files COPY . . # 7. Install Python requirements # CORRECTION: Removed '--break-system-packages' which causes errors on Bullseye RUN pip3 install --no-cache-dir -r requirements.txt # 8. Create the user (ID 1000) RUN useradd -m -u 1000 user # 9. GENERATE STARTUP SCRIPT RUN echo '#!/bin/bash' > start.sh && \ echo 'export DISPLAY=:1' >> start.sh && \ echo 'Xvfb :1 -screen 0 1440x960x24 &' >> start.sh && \ echo 'sleep 2' >> start.sh && \ echo 'fluxbox &' >> start.sh && \ echo 'python3 main.py &' >> start.sh && \ echo 'x11vnc -display :1 -nopw -forever -quiet &' >> start.sh && \ echo '/usr/share/novnc/utils/launch.sh --vnc localhost:5900 --listen 7860' >> start.sh && \ chmod +x start.sh # 10. Fix permissions RUN chown -R user:user /app # 11. Switch to user and run USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH CMD ["./start.sh"]