d / README.md
pabla1322's picture
Upload 14 files
e5de808 verified
|
Raw
History Blame Contribute Delete
6.4 kB
metadata
title: Ubuntu Desktop
emoji: 🐧
colorFrom: indigo
colorTo: blue
sdk: docker
pinned: false

🐧 Ubuntu Desktop on Hugging Face Spaces

A browser-accessible Ubuntu 24.04 XFCE Desktop running on a free Hugging Face Docker Space β€” inspired by Android Termux + PRoot-Distro workflows, adapted for cloud deployment with zero manual setup.


✨ What You Get

Feature Detail
Desktop Ubuntu 24.04 + XFCE4, accessible from any browser
VNC TigerVNC (Xvnc) at 1280Γ—720, 16-bit colour, 24 FPS
Browser Access noVNC via WebSocket β€” no VNC client needed
Persistent Storage All data stored in /data β€” survives Space restarts
Dashboard Flask app with live CPU / RAM / disk stats + log viewer
Browser Firefox ESR pre-installed
Free CPU Tier Optimised for low RAM + CPU (β‰ˆ 400 MB idle)

πŸš€ Deployment to Hugging Face Spaces

Prerequisites

  • A Hugging Face account
  • Git installed locally (or use the HF web UI)

Step 1 β€” Create a new Space

  1. Go to huggingface.co/new-space
  2. Choose Docker as the Space SDK
  3. Set hardware to CPU Basic (free tier)
  4. Enable Persistent Storage in the Space settings (required for /data)

Step 2 β€” Upload the files

Either use the HF web editor to paste each file, or clone the Space repo and push:

git clone https://huggingface.co/spaces/<YOUR_USERNAME>/<YOUR_SPACE_NAME>
cd <YOUR_SPACE_NAME>

# Copy all project files here
cp -r /path/to/hf-ubuntu-space/* .

git add .
git commit -m "Initial Ubuntu Desktop Space"
git push

Step 3 β€” Wait for the build

The first build takes 5–8 minutes (downloading Ubuntu + XFCE packages). Watch the Build Logs tab in the Space UI.

Step 4 β€” Access your desktop

Once the Space shows Running, click the App tab, or open:

https://<username>-<spacename>.hf.space

Click πŸ–₯ Launch Desktop to open the noVNC browser desktop.


πŸ–₯ Browser Desktop Access

URL Purpose
https://…hf.space/ Launcher page (recommended)
https://…hf.space/vnc/vnc.html noVNC direct (raw interface)
https://…hf.space/dashboard System stats dashboard

The launcher page auto-detects your Space's hostname and builds the correct WebSocket URL for noVNC β€” this is important because HF Spaces use Cloudflare proxying where the port is always 443 externally.

Mobile browsers

noVNC works on mobile. Use the scale/resize button (β€’) in the noVNC toolbar to fit the 1280Γ—720 desktop to your screen.


πŸ’Ύ Persistent Storage

All state lives under /data (Hugging Face's persistent volume):

/data/
β”œβ”€β”€ home/          ← ubuntu user home (~/.bashrc, Desktop, etc.)
β”œβ”€β”€ workspace/     ← your project files (persists forever)
β”œβ”€β”€ downloads/     ← browser and wget downloads
β”œβ”€β”€ firefox/       ← Firefox profile (bookmarks, passwords, etc.)
β”œβ”€β”€ xfce/          ← XFCE session config, wallpaper, themes
β”œβ”€β”€ vnc/           ← VNC server state + xstartup
β”œβ”€β”€ logs/          ← all service logs
└── cache/         ← app-level cache

Note: You must enable Persistent Storage in your Space settings. Without it /data is ephemeral and resets on every restart.


βš™οΈ PRoot-Distro Similarities

This Space simulates the Termux + PRoot-Distro workflow:

Termux / PRoot This Space
pkg install proot-distro Base Docker layer
proot-distro install ubuntu FROM ubuntu:24.04 in Dockerfile
proot-distro login ubuntu Container starts automatically
~ (Termux home) /data/home (persisted)
Internal storage /data/workspace

The key difference is that this runs Docker natively (not PRoot), giving full kernel-level isolation without the overhead of a userspace chroot.


πŸ”§ Configuration

Environment variables (set in Space settings)

Variable Default Description
VNC_PASSWORD (empty) Set a VNC password (optional; localhost-only anyway)
RESOLUTION 1280x720 Desktop resolution
COLOR_DEPTH 16 VNC colour depth (16 or 24)

Changing resolution

Edit supervisord.conf, update the Xvnc command:

command=Xvnc :1 -geometry 1920x1080 -depth 24 ...

πŸ›  Troubleshooting

Desktop doesn't load / black screen

  1. Open the Dashboard β†’ check all services show Running
  2. Check Xvnc and XFCE4 logs for errors
  3. Try restarting XFCE4 from the dashboard restart button

"Failed to connect to server" in noVNC

  • Make sure you're using the launcher page (/) not a hard-coded URL
  • The WebSocket path must be /websockify β€” check the URL bar in noVNC shows the correct host

Space keeps sleeping

HF free CPU Spaces sleep after ~15 min of no browser traffic. This is expected. Wake it by opening the Space URL. Your /data files are always preserved.

High memory usage

XFCE4 uses ~300–400 MB at idle. With Firefox open, expect 800 MB+. The free CPU tier has 16 GB RAM, so this is fine. If you see OOM kills, close unused browser tabs in the desktop.

Logs

All logs are in /data/logs/ and viewable from the Dashboard log viewer:

/data/logs/supervisord.log
/data/logs/xvnc.log / xvnc_err.log
/data/logs/xfce4.log / xfce4_err.log
/data/logs/websockify.log
/data/logs/dashboard.log
/data/logs/nginx.log / nginx_error.log

πŸ— Architecture

Browser (HTTPS :443)
    β”‚
    β–Ό
nginx :7860 (HF Spaces default port)
    β”œβ”€ / ──────────────────────── Launcher HTML (auto-builds WSS URL)
    β”œβ”€ /vnc/ ─────────────────── noVNC static assets
    β”œβ”€ /websockify ───────────── WebSocket proxy ──► websockify :6080
    β”‚                                                       β”‚
    β”‚                                                    Xvnc :5901
    β”‚                                                    XFCE4 session
    β”œβ”€ /dashboard ────────────── Flask app :5000
    └─ /api/ ─────────────────── Flask REST API :5000

πŸ“„ Licence

MIT β€” use freely, no warranties.