File size: 5,375 Bytes
4b8d178 f7e131b 8a937d7 f7e131b 8a937d7 f7e131b 4b8d178 8a937d7 f7e131b 4b8d178 f7e131b 4b8d178 f7e131b 99e251e f7e131b 4b8d178 8a937d7 f7e131b 4b8d178 f7e131b 99e251e f7e131b 4b8d178 f7e131b 99e251e f7e131b 4b8d178 f7e131b 8a937d7 f7e131b 4b8d178 d9ae4a4 8a937d7 f7e131b 99e251e 8a937d7 99e251e 8a937d7 f7e131b 8a937d7 f7e131b 8a937d7 f7e131b 8a937d7 f7e131b 8a937d7 f7e131b 43dc799 f7e131b 8a937d7 f7e131b 4b8d178 f7e131b 4b8d178 f7e131b 4b8d178 cc4d687 8a937d7 4b8d178 f7e131b 99e251e f7e131b | 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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | # ==============================================
# Full-Stack Dev Environment for Hugging Face Spaces
# Python 3.12 + Node.js + code-server + Auto Backup
# ==============================================
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
# -----------------------------
# Core tools + essentials
# -----------------------------
RUN apt-get update && apt-get install -y software-properties-common \
&& add-apt-repository -y ppa:apt-fast/stable \
&& apt-get update && apt-get -y install apt-fast \
&& echo "DOWNLOADBEFORE=true" | tee -a /etc/apt-fast.conf \
&& echo "MAXNUM=10" | tee -a /etc/apt-fast.conf \
&& echo "USE_PIGZ=1" | tee -a /etc/apt-fast.conf \
&& echo "APTFAST_PARA_OPTS=(--max-connection-per-server=12 --split=5)" | tee -a /etc/apt-fast.conf
RUN apt-fast update && apt-fast install -y \
curl wget git git-lfs unzip sudo nano bash apt-fast \
ca-certificates gnupg build-essential jq sqlite3 rsync pigz \
net-tools iputils-ping htop tree && rm -rf /var/lib/apt/lists/*
RUN git lfs install
# -----------------------------
# Python 3.12
# -----------------------------
RUN add-apt-repository ppa:deadsnakes/ppa -y && apt-fast update \
&& apt-fast install -y python3.12 python3.12-venv python3.12-dev \
&& curl -sS https://bootstrap.pypa.io/get-pip.py | python3.12 \
&& update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 1 \
&& update-alternatives --install /usr/bin/pip pip /usr/local/bin/pip3.12 1 \
&& update-alternatives --set python3 /usr/bin/python3.12
# -----------------------------
# Node.js + Yarn + PNPM
# -----------------------------
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-fast install -y nodejs \
&& npm install -g yarn pnpm typescript ts-node nodemon \
&& npm cache clean --force && rm -rf /var/lib/apt/lists/*
# -----------------------------
# PHP + Composer (optional)
# -----------------------------
RUN apt-fast update && apt-fast install -y php-cli unzip \
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
&& rm -rf /var/lib/apt/lists/*
# -----------------------------
# VS Code Server
# -----------------------------
RUN curl -fsSL https://code-server.dev/install.sh | sh
# -----------------------------
# Workspace setup
# -----------------------------
WORKDIR /home/vscode
RUN mkdir -p /home/vscode/workspace
COPY --chmod=755 app.py /app.py
COPY --chmod=755 backup.py /backup.py
COPY --chmod=755 restore.py /restore.py
RUN sudo chmod -R 777 /home/vscode
# -----------------------------
# Python packages
# -----------------------------
RUN pip install --upgrade pip setuptools wheel && \
pip install --ignore-installed blinker && \
pip install --no-cache-dir \
huggingface_hub hf_transfer flask fastapi django uvicorn requests
# -----------------------------
# Locale + database clients
# -----------------------------
RUN apt-fast update && apt-fast install -y locales mysql-client postgresql-client redis-tools \
&& locale-gen en_US.UTF-8 && update-locale LANG=en_US.UTF-8 && rm -rf /var/lib/apt/lists/*
ENV LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8
# MongoDB tools
RUN wget -qO - https://www.mongodb.org/static/pgp/server-7.0.asc | gpg --dearmor -o /usr/share/keyrings/mongodb.gpg \
&& echo "deb [signed-by=/usr/share/keyrings/mongodb.gpg] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" \
| tee /etc/apt/sources.list.d/mongodb-org-7.0.list \
&& apt-fast update && apt-fast install -y mongodb-database-tools && rm -rf /var/lib/apt/lists/*
# -----------------------------
# Productivity tools
# -----------------------------
RUN apt-fast update && apt-fast install -y tmux screen neovim httpie shellcheck man-db manpages-dev && rm -rf /var/lib/apt/lists/*
# Install Gradle
# -------------------------------
RUN wget https://services.gradle.org/distributions/gradle-8.13-bin.zip -O /tmp/gradle.zip \
&& unzip /tmp/gradle.zip -d /opt \
&& mv /opt/gradle-8.13 /opt/gradle \
&& rm /tmp/gradle.zip
# -------------------------------
# Install Kotlin
# -------------------------------
RUN wget https://github.com/JetBrains/kotlin/releases/download/v2.0.21/kotlin-compiler-2.0.21.zip -O /tmp/kotlin.zip \
&& unzip /tmp/kotlin.zip -d /opt \
&& mv /opt/kotlinc /opt/kotlin \
&& rm /tmp/kotlin.zip
# -------------------------------
# Install Flutter
# -------------------------------
RUN git clone https://github.com/flutter/flutter.git -b stable $FLUTTER_HOME \
&& $FLUTTER_HOME/bin/flutter config --android-sdk $ANDROID_SDK_ROOT \
&& $FLUTTER_HOME/bin/flutter precache \
&& $FLUTTER_HOME/bin/flutter doctor -v
# -----------------------------
# User setup
# -----------------------------
RUN useradd -ms /bin/bash vscode && echo "vscode ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
USER vscode
ENV PATH=$PATH:/home/vscode/.local/bin
# -----------------------------
# Environment defaults
# -----------------------------
ENV PORT=7860 \
BACKUP_INTERVAL=5 \
CONFIG_BACKUP_INTERVAL=60 \
CONFIG_KEEP_LIMIT=5 \
HF_HUB_ENABLE_HF_TRANSFER=1 \
PASSWORD=${PASSWORD:-dev12345}
# -----------------------------
# Entrypoint
# -----------------------------
VOLUME /home/vscode/workspace
ENTRYPOINT ["python3", "/app.py"]
|