eoeooe commited on
Commit
b9fe82c
·
verified ·
1 Parent(s): 785ea81

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +63 -0
Dockerfile ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM ubuntu:22.04
2
+
3
+ USER root
4
+ ENV DEBIAN_FRONTEND=noninteractive
5
+
6
+ RUN apt-get update && apt-get install -y \
7
+ curl wget sudo ttyd qemu-system-x86 qemu-kvm \
8
+ && rm -rf /var/lib/apt/lists/*
9
+
10
+ RUN useradd -m -u 1000 user && echo "user ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
11
+ USER user
12
+ WORKDIR /home/user
13
+
14
+ COPY --chown=user:user start.sh /home/user/start.sh
15
+ RUN chmod +x /home/user/start.sh
16
+
17
+ ENTRYPOINT ["/home/user/start.sh"]
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+ #!/bin/bash
27
+
28
+ # Configuration from your images
29
+ REPO_ID=
30
+ HF_TOKEN=""
31
+
32
+ echo "--- System Starting ---"
33
+
34
+ #
35
+ echo "Restoring files from $REPO_ID..."
36
+ huggingface-cli download $REPO_ID --local-dir /home/user/storage --repo-type dataset --token $HF_TOKEN
37
+
38
+ #
39
+ cat <<EOF > /home/user/auto_backup.sh
40
+ #!/bin/bash
41
+ while true; do
42
+ sleep 300
43
+ echo "Backing up data to Hugging Face..."
44
+ huggingface-cli upload $REPO_ID /home/user/storage . --repo-type=dataset --token=$HF_TOKEN
45
+ done
46
+ EOF
47
+ chmod +x /home/user/auto_backup.sh
48
+ ./auto_backup.sh &
49
+
50
+ #
51
+ cat <<EOF > /home/user/final_backup.sh
52
+ #!/bin/bash
53
+ #
54
+
55
+ echo "Hugging Face is about to restart soon. Taking final backup..."
56
+ huggingface-cli upload $REPO_ID /home/user/storage . --repo-type=dataset --token=$HF_TOKEN
57
+ EOF
58
+ chmod +x /home/user/final_backup.sh
59
+ ./final_backup.sh &
60
+
61
+ # เงช.
62
+ echo "--- System is Ready. Access via Web Terminal ---"
63
+ ttyd -p 7860 -W bash