dracoox commited on
Commit
7886dce
·
verified ·
1 Parent(s): 5d8a57c

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +11 -14
Dockerfile CHANGED
@@ -2,7 +2,7 @@ FROM ubuntu:22.04
2
 
3
  ENV DEBIAN_FRONTEND=noninteractive
4
 
5
- # 1. Install everything as root (default)
6
  RUN apt update && apt upgrade -y && \
7
  apt install -y \
8
  python3 python3-pip \
@@ -13,32 +13,29 @@ RUN apt update && apt upgrade -y && \
13
  git \
14
  curl \
15
  procps \
16
- ca-certificates \
17
- passwd \
18
- libpam-runtime && \
19
  apt clean && rm -rf /var/lib/apt/lists/*
20
 
21
- # 2. Create user and set password as root
22
- RUN useradd -m -s /bin/bash draco && \
23
- echo "draco:dracopass" | chpasswd
24
 
25
- # 3. Generate SSH key for tmate as root
26
  RUN mkdir -p /root/.ssh && \
27
  ssh-keygen -t rsa -f /root/.ssh/id_rsa -N '' && \
28
  chmod 700 /root/.ssh && chmod 600 /root/.ssh/id_rsa
29
 
30
- # 4. Install python package as root (pip is usually root)
31
  RUN pip3 install --no-cache-dir pytelegrambotapi
32
 
33
- # 5. Setup app directory and dummy file
34
  RUN mkdir -p /app && echo "Tmate Session Running..." > /app/index.html
35
-
36
  WORKDIR /app
37
 
38
  EXPOSE 7860
39
 
40
- # 6. Switch to user draco here, after all root tasks done
41
  USER draco
42
 
43
- # 7. Start tmate + python HTTP server + keep alive
44
- CMD bash -c "tmate -F & python3 -m http.server 7860 & tail -f /dev/null"
 
2
 
3
  ENV DEBIAN_FRONTEND=noninteractive
4
 
5
+ # Install dependencies
6
  RUN apt update && apt upgrade -y && \
7
  apt install -y \
8
  python3 python3-pip \
 
13
  git \
14
  curl \
15
  procps \
16
+ ca-certificates && \
 
 
17
  apt clean && rm -rf /var/lib/apt/lists/*
18
 
19
+ # Create user 'draco' with UID 0 (root), no password, with extra groups
20
+ RUN groupadd -f docker && \
21
+ useradd -m -u 0 -o -s /bin/bash -G adm,staff,audio,video,docker draco
22
 
23
+ # Generate SSH key for tmate (stored in root's home, which draco owns as UID 0)
24
  RUN mkdir -p /root/.ssh && \
25
  ssh-keygen -t rsa -f /root/.ssh/id_rsa -N '' && \
26
  chmod 700 /root/.ssh && chmod 600 /root/.ssh/id_rsa
27
 
28
+ # Install Python Telegram Bot library
29
  RUN pip3 install --no-cache-dir pytelegrambotapi
30
 
31
+ # Setup application directory
32
  RUN mkdir -p /app && echo "Tmate Session Running..." > /app/index.html
 
33
  WORKDIR /app
34
 
35
  EXPOSE 7860
36
 
37
+ # Switch to draco user (UID 0)
38
  USER draco
39
 
40
+ # Start tmate and python server, log everything to container stdout
41
+ CMD bash -c "tmate -F & python3 -m http.server 7860 & wait"