raw9 commited on
Commit
4078e96
Β·
verified Β·
1 Parent(s): 651d125

Upload Dockerfile.txt

Browse files
Files changed (1) hide show
  1. Dockerfile.txt +97 -0
Dockerfile.txt ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ============================================================
2
+ # Pro Linux Workspace β€” Dockerfile
3
+ # Optimised for Hugging Face Spaces (port 7860)
4
+ # ============================================================
5
+ FROM ubuntu:22.04
6
+
7
+ ENV DEBIAN_FRONTEND=noninteractive \
8
+ LANG=en_US.UTF-8 \
9
+ LANGUAGE=en_US:en \
10
+ LC_ALL=en_US.UTF-8 \
11
+ HOME=/home/user \
12
+ PATH="/home/user/.local/bin:/usr/local/bin:/usr/bin:/bin" \
13
+ PYTHONDONTWRITEBYTECODE=1 \
14
+ PYTHONUNBUFFERED=1
15
+
16
+ # ── Layer 1: Base system packages ────────────────────────────
17
+ RUN apt-get update && apt-get install -y --no-install-recommends \
18
+ # Locale
19
+ locales tzdata \
20
+ # Network & TLS
21
+ ca-certificates curl wget gnupg2 \
22
+ # Shell & Terminal
23
+ zsh tmux \
24
+ # Editors
25
+ nano \
26
+ # VCS
27
+ git \
28
+ # Monitoring
29
+ htop \
30
+ # Python
31
+ python3 python3-pip python3-dev \
32
+ # Privilege escalation
33
+ sudo \
34
+ # Archive tools
35
+ unzip zip \
36
+ && locale-gen en_US.UTF-8 \
37
+ && apt-get clean \
38
+ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
39
+
40
+ # ── Layer 2: Caddy (reverse proxy) ───────────────────────────
41
+ RUN curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' \
42
+ | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg \
43
+ && curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' \
44
+ | tee /etc/apt/sources.list.d/caddy-stable.list \
45
+ && apt-get update \
46
+ && apt-get install -y --no-install-recommends caddy \
47
+ && apt-get clean \
48
+ && rm -rf /var/lib/apt/lists/*
49
+
50
+ # ── Layer 3: Filebrowser ─────────────────────────────────────
51
+ RUN curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | bash \
52
+ && filebrowser version
53
+
54
+ # ── Layer 4: Code-server (VS Code) ───────────────────────────
55
+ RUN curl -fsSL https://code-server.dev/install.sh \
56
+ | sh -s -- --method=standalone --prefix=/usr/local \
57
+ && code-server --version
58
+
59
+ # ── Layer 5: ttyd (prebuilt binary β€” no build deps needed) ───
60
+ RUN TTYD_VERSION=$(curl -fsSL https://api.github.com/repos/tsl0922/ttyd/releases/latest \
61
+ | grep '"tag_name"' | sed 's/.*"tag_name": "\(.*\)".*/\1/') \
62
+ && echo "Installing ttyd ${TTYD_VERSION}" \
63
+ && curl -fsSL \
64
+ "https://github.com/tsl0922/ttyd/releases/download/${TTYD_VERSION}/ttyd.x86_64" \
65
+ -o /usr/local/bin/ttyd \
66
+ && chmod +x /usr/local/bin/ttyd \
67
+ && ttyd --version
68
+
69
+ # ── Layer 6: Non-root user ───────────────────────────────────
70
+ RUN useradd -m -s /bin/zsh -u 1000 user \
71
+ && echo "user ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers \
72
+ && mkdir -p \
73
+ /home/user/Drive \
74
+ /home/user/app \
75
+ /home/user/.config \
76
+ /home/user/.local/bin \
77
+ && chown -R user:user /home/user
78
+
79
+ USER user
80
+ WORKDIR /home/user/app
81
+
82
+ # ── Layer 7: Python packages (as user) ───────────────────────
83
+ COPY --chown=user:user requirements.txt /home/user/app/requirements.txt
84
+
85
+ RUN python3 -m pip install --no-cache-dir --upgrade pip \
86
+ && python3 -m pip install --no-cache-dir -r /home/user/app/requirements.txt
87
+
88
+ # ── Layer 8: Application files ───────────────────────────────
89
+ COPY --chown=user:user . /home/user/app/
90
+
91
+ # ── Healthcheck ──────────────────────────────────────────────
92
+ HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
93
+ CMD curl -f http://127.0.0.1:7860/ || exit 1
94
+
95
+ EXPOSE 7860
96
+
97
+ CMD ["python3", "-u", "app.py"]