# Use a base Ubuntu image FROM ubuntu:20.04 # Set environment variables to prevent interactive prompts during installation ENV DEBIAN_FRONTEND=noninteractive # Phase 1: Install core dependencies for adding repositories and a base desktop RUN rm -rf /var/lib/apt/lists/* && \ apt-get update && \ apt-get install -y --no-install-recommends \ apt-transport-https \ curl \ gnupg \ software-properties-common \ wget \ ca-certificates \ dbus-x11 \ xfce4 \ tigervnc-standalone-server \ tigervnc-common \ sudo \ dos2unix && \ rm -rf /var/lib/apt/lists/* # Phase 2: Add all external repositories RUN \ # Add Brave Browser repository curl -fsSLo /usr/share/keyrings/brave-browser-archive-keyring.gpg https://brave-browser-apt-release.s3.brave.com/brave-browser-archive-keyring.gpg && \ echo "deb [signed-by=/usr/share/keyrings/brave-browser-archive-keyring.gpg] https://brave-browser-apt-release.s3.brave.com/ stable main" | tee /etc/apt/sources.list.d/brave-browser-release.list && \ \ # Add VS Code repository wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /etc/apt/trusted.gpg.d/packages.microsoft.gpg && \ echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" | tee /etc/apt/sources.list.d/vscode.list # Phase 3: Update and install all remaining applications RUN apt-get update && \ apt-get install -y \ brave-browser \ code \ docker.io \ tor \ qterminal \ git \ wget \ htop \ curl \ novnc \ websockify \ netcat-openbsd \ iputils-ping \ net-tools \ dnsutils && \ # Set Brave as the default browser update-alternatives --install /usr/bin/x-www-browser x-www-browser /usr/bin/brave-browser 200 && \ rm -rf /var/lib/apt/lists/* # Create a directory for our web app, COPY all noVNC files, # and rename the main file to index.html. # This is all done as root. RUN mkdir -p /opt/novnc && \ cp -r /usr/share/novnc/* /opt/novnc/ && \ mv /opt/novnc/vnc.html /opt/novnc/index.html # Create a non-root user to run the application RUN useradd -m -s /bin/bash user # Add the user to the sudo group RUN adduser user sudo # Switch to the non-root user USER user WORKDIR /home/user # Copy the startup scripts using --chown to set correct permissions immediately COPY --chown=user:user run.sh . COPY --chown=user:user xstartup . # Make the scripts executable AND convert line endings to Unix format RUN chmod +x run.sh xstartup && \ dos2unix run.sh xstartup # Set up the .vnc directory and move the xstartup script into it RUN mkdir -p .vnc && \ mv xstartup .vnc/ && \ echo "password" | \ vncpasswd -f > .vnc/passwd && \ chmod 600 .vnc/passwd # Expose the port that Hugging Face Spaces uses for applications EXPOSE 7860 # Command to run when the container starts CMD ["./run.sh"]