Spaces:
Sleeping
Sleeping
File size: 2,366 Bytes
52013b5 2a081e2 52013b5 5cd111e a3bfafd 5cd111e 8e73dda 5cd111e 8e73dda 2a081e2 08f77cf 5cd111e 8e73dda ed449d2 8e73dda 7cc82b5 a3bfafd 2a081e2 a3bfafd 8e73dda 9c608e0 3cf6b15 8e73dda ca96613 8e73dda 9c608e0 2a081e2 8e73dda 52013b5 a3bfafd 955df2f 52013b5 8e73dda 52013b5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | # HuggingRun v2 — Ubuntu Server on HuggingFace Spaces
# Single port 7860: nginx → ttyd (web terminal) + SSH-over-WebSocket
# Persistence: tar.zst archive of /home + /root → HF Dataset
FROM ubuntu:24.04
ENV DEBIAN_FRONTEND=noninteractive
# Core: Python + git-lfs + huggingface_hub
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates curl wget python3 python3-pip python3-venv git git-lfs \
&& pip3 install --no-cache-dir --break-system-packages huggingface_hub websockets \
&& git lfs install \
&& rm -rf /var/lib/apt/lists/*
# Server: SSH + nginx + ttyd + tools
RUN apt-get update && apt-get install -y --no-install-recommends \
openssh-server openssh-client \
nginx \
ttyd \
procps htop vim nano less tmux \
build-essential rsync zstd \
&& rm -rf /var/lib/apt/lists/*
# Node.js 20 LTS (for Claude Code)
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y nodejs \
&& rm -rf /var/lib/apt/lists/*
# Claude Code (install globally so all users can access)
RUN npm install -g @anthropic-ai/claude-code 2>/dev/null \
|| (curl -fsSL https://claude.ai/install.sh | bash && \
cp /root/.local/bin/claude /usr/local/bin/claude 2>/dev/null || true)
# Snapshot base package list (to detect user-added packages later)
RUN dpkg-query -W -f='${Package}\n' | sort > /etc/base-packages.list
# SSH: host keys + privilege separation directory
RUN ssh-keygen -A && mkdir -p /run/sshd
# User account (for SSH login); container runs as root for system persistence
RUN useradd -m -u 1000 -s /bin/bash -p "$(openssl passwd -6 huggingrun)" tao-shen 2>/dev/null || true \
&& apt-get update && apt-get install -y --no-install-recommends sudo \
&& echo "tao-shen ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/tao-shen \
&& chmod 440 /etc/sudoers.d/tao-shen \
&& rm -rf /var/lib/apt/lists/*
# Root password for SSH login as root
RUN usermod -p "$(openssl passwd -6 huggingrun)" root
RUN mkdir -p /data
# v2: only 3 files (entrypoint + nginx + ws-bridge)
COPY entrypoint.py /entrypoint.py
COPY nginx.conf /etc/nginx/nginx.conf
COPY ws_ssh_bridge.py /ws_ssh_bridge.py
ENV PERSIST_PATH=/data
ENV PYTHONUNBUFFERED=1
# Run as root (needed for: apt install persistence, bind mounts, sshd)
EXPOSE 7860
ENTRYPOINT ["python3", "-u", "/entrypoint.py"]
|