etsadiz commited on
Commit
4b8d178
·
verified ·
1 Parent(s): 758e368

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +44 -56
Dockerfile CHANGED
@@ -1,3 +1,8 @@
 
 
 
 
 
1
  FROM ubuntu:22.04
2
 
3
  ENV DEBIAN_FRONTEND=noninteractive
@@ -14,43 +19,43 @@ RUN apt-get update && apt-get install -y software-properties-common \
14
  && echo "USE_PIGZ=1" | tee -a /etc/apt-fast.conf \
15
  && echo "APTFAST_PARA_OPTS=(--max-connection-per-server=12 --split=5)" | tee -a /etc/apt-fast.conf
16
 
17
- # Minimal set of basic tools (kept lightweight)
18
  RUN apt-fast update && apt-fast install -y \
19
  curl wget git git-lfs unzip sudo nano bash apt-fast \
20
- software-properties-common ca-certificates gnupg \
21
- valgrind gdb strace ltrace \
22
- htop tree jq sqlite3 \
23
- net-tools iputils-ping rsync pigz \
24
  && rm -rf /var/lib/apt/lists/*
25
 
26
  RUN git lfs install
27
 
28
  # -----------------------------
29
- # Python 3.12 (only)
30
  # -----------------------------
31
- RUN add-apt-repository ppa:deadsnakes/ppa -y && apt-fast update
32
- RUN apt-fast install -y python3.12 python3.12-venv python3.12-dev \
33
- && curl -sS https://bootstrap.pypa.io/get-pip.py | python3.12
34
- RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 1 \
35
- && update-alternatives --install /usr/bin/pip pip /usr/local/bin/pip3.12 1
36
- RUN update-alternatives --set python3 /usr/bin/python3.12
37
 
38
  # -----------------------------
39
  # Node.js + Yarn + PNPM
40
  # -----------------------------
41
  RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
42
- && apt-fast install -y nodejs
43
- RUN npm install -g yarn pnpm
 
 
44
 
45
  # -----------------------------
46
- # PHP + Composer
47
  # -----------------------------
48
  RUN apt-fast update && apt-fast install -y php-cli unzip \
49
  && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
50
  && rm -rf /var/lib/apt/lists/*
51
 
52
  # -----------------------------
53
- # code-server
54
  # -----------------------------
55
  RUN curl -fsSL https://code-server.dev/install.sh | sh
56
 
@@ -59,40 +64,43 @@ RUN curl -fsSL https://code-server.dev/install.sh | sh
59
  # -----------------------------
60
  WORKDIR /home/vscode
61
  RUN mkdir -p /home/vscode/workspace
62
- COPY restore.py /restore.py
63
- COPY app.py /app.py
64
- COPY backup.py /home/backup.py
65
- RUN chmod -R 777 /home
 
 
 
66
 
67
  # -----------------------------
68
- # Minimal pip packages
69
  # -----------------------------
70
- RUN pip install --upgrade pip setuptools wheel
71
- RUN pip install huggingface_hub huggingface_hub[cli] hf_xet hf_transfer
 
72
  ENV HF_HUB_ENABLE_HF_TRANSFER=1
73
 
74
  # -----------------------------
75
  # Locales
76
  # -----------------------------
77
  RUN apt-fast update && apt-fast install -y locales \
78
- && locale-gen en_US.UTF-8 \
79
- && update-locale LANG=en_US.UTF-8
80
  ENV LANG=en_US.UTF-8
81
  ENV LANGUAGE=en_US:en
82
  ENV LC_ALL=en_US.UTF-8
83
 
84
  # -----------------------------
85
- # Database Clients
86
  # -----------------------------
87
  RUN apt-fast update && apt-fast install -y \
88
  mysql-client postgresql-client redis-tools \
89
- gnupg wget ca-certificates \
90
  && rm -rf /var/lib/apt/lists/*
91
 
92
  # MongoDB Tools
93
  RUN wget -qO - https://www.mongodb.org/static/pgp/server-7.0.asc | gpg --dearmor -o /usr/share/keyrings/mongodb.gpg \
94
  && echo "deb [signed-by=/usr/share/keyrings/mongodb.gpg] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" \
95
- | tee /etc/apt/sources.list.d/mongodb-org-7.0.list \
96
  && apt-fast update && apt-fast install -y mongodb-database-tools \
97
  && rm -rf /var/lib/apt/lists/*
98
 
@@ -112,43 +120,23 @@ export HISTSIZE=0\n\
112
  export HISTFILESIZE=0\n\
113
  export HISTCONTROL=ignoreboth\n\
114
  export PROMPT_COMMAND="history -r /dev/null"\n\
115
- ' >> /etc/profile && \
116
- echo '\
117
- unset HISTFILE\n\
118
- export HISTSIZE=0\n\
119
- export HISTFILESIZE=0\n\
120
- export HISTCONTROL=ignoreboth\n\
121
- export PROMPT_COMMAND="history -r /dev/null"\n\
122
- ' >> /etc/bash.bashrc && \
123
- rm -f /root/.bash_history && \
124
- mkdir -p /etc/skel && \
125
- echo '\
126
- unset HISTFILE\n\
127
- export HISTSIZE=0\n\
128
- export HISTFILESIZE=0\n\
129
- export HISTCONTROL=ignoreboth\n\
130
- export PROMPT_COMMAND="history -r /dev/null"\n\
131
- ' >> /etc/skel/.bashrc
132
 
133
  # -----------------------------
134
  # Create vscode user
135
  # -----------------------------
136
- RUN useradd -ms /bin/bash vscode \
137
- && echo "vscode:vscode" | chpasswd \
138
- && mkdir -p /home/vscode/.ssh \
139
- && chown -R vscode:vscode /home/vscode
140
-
141
  USER vscode
142
  ENV PATH=$PATH:/home/vscode/.local/bin
143
 
144
  # -----------------------------
145
- # Restore backup from HF dataset
146
  # -----------------------------
147
- RUN mkdir -p /home/vscode/backup
148
- RUN hf download ThongCoder/vscode-public-data --local-dir /home/vscode --repo-type dataset
149
- RUN cat /home/vscode/backup/workspace-backup.tar.gz.part-* > /home/vscode/backup/workspace-backup.tar.gz
150
- RUN tar -xzf /home/vscode/backup/workspace-backup.tar.gz -C /home/vscode/workspace
151
- RUN rm -rf /home/vscode/backup/*
152
 
153
  # -----------------------------
154
  # Entrypoint
 
1
+ # ==============================================
2
+ # Full-Stack Dev Environment for Hugging Face Spaces
3
+ # Python 3.12 + Node.js + code-server + Auto Backup
4
+ # ==============================================
5
+
6
  FROM ubuntu:22.04
7
 
8
  ENV DEBIAN_FRONTEND=noninteractive
 
19
  && echo "USE_PIGZ=1" | tee -a /etc/apt-fast.conf \
20
  && echo "APTFAST_PARA_OPTS=(--max-connection-per-server=12 --split=5)" | tee -a /etc/apt-fast.conf
21
 
22
+ # Lightweight developer tools
23
  RUN apt-fast update && apt-fast install -y \
24
  curl wget git git-lfs unzip sudo nano bash apt-fast \
25
+ ca-certificates gnupg build-essential jq sqlite3 rsync pigz \
26
+ net-tools iputils-ping htop tree \
 
 
27
  && rm -rf /var/lib/apt/lists/*
28
 
29
  RUN git lfs install
30
 
31
  # -----------------------------
32
+ # Python 3.12
33
  # -----------------------------
34
+ RUN add-apt-repository ppa:deadsnakes/ppa -y && apt-fast update \
35
+ && apt-fast install -y python3.12 python3.12-venv python3.12-dev \
36
+ && curl -sS https://bootstrap.pypa.io/get-pip.py | python3.12 \
37
+ && update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 1 \
38
+ && update-alternatives --install /usr/bin/pip pip /usr/local/bin/pip3.12 1 \
39
+ && update-alternatives --set python3 /usr/bin/python3.12
40
 
41
  # -----------------------------
42
  # Node.js + Yarn + PNPM
43
  # -----------------------------
44
  RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
45
+ && apt-fast install -y nodejs \
46
+ && npm install -g yarn pnpm typescript ts-node nodemon \
47
+ && npm cache clean --force \
48
+ && rm -rf /var/lib/apt/lists/*
49
 
50
  # -----------------------------
51
+ # PHP + Composer (optional)
52
  # -----------------------------
53
  RUN apt-fast update && apt-fast install -y php-cli unzip \
54
  && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
55
  && rm -rf /var/lib/apt/lists/*
56
 
57
  # -----------------------------
58
+ # VS Code Server
59
  # -----------------------------
60
  RUN curl -fsSL https://code-server.dev/install.sh | sh
61
 
 
64
  # -----------------------------
65
  WORKDIR /home/vscode
66
  RUN mkdir -p /home/vscode/workspace
67
+
68
+ # Copy your runtime scripts
69
+ COPY --chmod=755 app.py /app.py
70
+ COPY --chmod=755 backup.py /backup.py
71
+ COPY --chmod=755 restore.py /restore.py
72
+
73
+ RUN sudo chmod -R 777 /home/vscode
74
 
75
  # -----------------------------
76
+ # Python packages
77
  # -----------------------------
78
+ RUN pip install --upgrade pip setuptools wheel && \
79
+ pip install huggingface_hub hf_transfer flask fastapi django uvicorn requests
80
+
81
  ENV HF_HUB_ENABLE_HF_TRANSFER=1
82
 
83
  # -----------------------------
84
  # Locales
85
  # -----------------------------
86
  RUN apt-fast update && apt-fast install -y locales \
87
+ && locale-gen en_US.UTF-8 && update-locale LANG=en_US.UTF-8 \
88
+ && rm -rf /var/lib/apt/lists/*
89
  ENV LANG=en_US.UTF-8
90
  ENV LANGUAGE=en_US:en
91
  ENV LC_ALL=en_US.UTF-8
92
 
93
  # -----------------------------
94
+ # Database clients (optional)
95
  # -----------------------------
96
  RUN apt-fast update && apt-fast install -y \
97
  mysql-client postgresql-client redis-tools \
 
98
  && rm -rf /var/lib/apt/lists/*
99
 
100
  # MongoDB Tools
101
  RUN wget -qO - https://www.mongodb.org/static/pgp/server-7.0.asc | gpg --dearmor -o /usr/share/keyrings/mongodb.gpg \
102
  && echo "deb [signed-by=/usr/share/keyrings/mongodb.gpg] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" \
103
+ | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list \
104
  && apt-fast update && apt-fast install -y mongodb-database-tools \
105
  && rm -rf /var/lib/apt/lists/*
106
 
 
120
  export HISTFILESIZE=0\n\
121
  export HISTCONTROL=ignoreboth\n\
122
  export PROMPT_COMMAND="history -r /dev/null"\n\
123
+ ' | sudo tee -a /etc/profile /etc/bash.bashrc > /dev/null && \
124
+ rm -f /root/.bash_history
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
 
126
  # -----------------------------
127
  # Create vscode user
128
  # -----------------------------
129
+ RUN useradd -ms /bin/bash vscode && echo "vscode ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
 
 
 
 
130
  USER vscode
131
  ENV PATH=$PATH:/home/vscode/.local/bin
132
 
133
  # -----------------------------
134
+ # Environment defaults
135
  # -----------------------------
136
+ ENV PORT=7860 \
137
+ BACKUP_INTERVAL=45 \
138
+ HF_HUB_ENABLE_HF_TRANSFER=1 \
139
+ PASSWORD=${PASSWORD:-dev12345}
 
140
 
141
  # -----------------------------
142
  # Entrypoint