sft0farid commited on
Commit
e5ec0b3
·
verified ·
1 Parent(s): a7d03bb

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +29 -19
Dockerfile CHANGED
@@ -1,11 +1,7 @@
1
- # syntax=docker/dockerfile:1
2
- # ^^^ ЭТО ОБЯЗАТЕЛЬНО для heredoc в Dockerfile
3
-
4
- # ============================================
5
- # BASE
6
- # ============================================
7
  FROM python:3.11-slim
8
 
 
9
  RUN apt-get update && apt-get install -y \
10
  supervisor \
11
  curl \
@@ -13,11 +9,23 @@ RUN apt-get update && apt-get install -y \
13
  wget \
14
  && rm -rf /var/lib/apt/lists/*
15
 
16
- # ============================================
17
- # ZROK
18
- # ============================================
19
  RUN curl -sSf https://get.openziti.io/install.bash | bash -s zrok
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  # ============================================
22
  # SECTION: AIClient2API
23
  # ============================================
@@ -27,9 +35,7 @@ RUN git clone https://github.com/user/AIClient2API.git /data/aiclient2api \
27
  # ============================================
28
  # SECTION: Kiro-go
29
  # ============================================
30
- RUN mkdir -p /data/kirogo \
31
- && wget -O /data/kirogo/kiro-go \
32
- https://github.com/user/kiro-go/releases/download/v1.0/kiro-go-linux-amd64 \
33
  && chmod +x /data/kirogo/kiro-go
34
 
35
  # ============================================
@@ -39,15 +45,16 @@ RUN git clone https://github.com/user/bifrost.git /data/bifrost \
39
  && pip install --no-cache-dir -r /data/bifrost/requirements.txt
40
 
41
  # ============================================
42
- # CONFIGS — всё inline, никаких внешних файлов
 
43
  # ============================================
44
 
45
- # supervisord.conf прямо в Dockerfile
46
- COPY <<EOF /etc/supervisor/conf.d/supervisord.conf
47
  [supervisord]
48
  nodaemon=true
49
  logfile=/dev/stdout
50
  logfile_maxbytes=0
 
51
 
52
  [program:bifrost]
53
  command=python /data/bifrost/main.py --port 7860
@@ -80,7 +87,8 @@ stderr_logfile=/dev/stderr
80
  stderr_logfile_maxbytes=0
81
 
82
  [program:zrok]
83
- command=zrok share reserved %(ENV_ZROK_SHARE_NAME)s
 
84
  autostart=true
85
  autorestart=true
86
  stdout_logfile=/dev/stdout
@@ -89,17 +97,19 @@ stderr_logfile=/dev/stderr
89
  stderr_logfile_maxbytes=0
90
  EOF
91
 
92
- # startup скрипт тоже inline
93
- COPY <<'EOF' /data/start.sh
94
  #!/bin/bash
95
  if [ -n "$ZROK_TOKEN" ]; then
96
- zrok enable $ZROK_TOKEN 2>/dev/null || true
97
  fi
98
  exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
99
  EOF
100
 
101
  RUN chmod +x /data/start.sh
102
 
 
103
  EXPOSE 7860
104
 
 
105
  CMD ["/data/start.sh"]
 
1
+ # syntax=docker/dockerfile:1.4
 
 
 
 
 
2
  FROM python:3.11-slim
3
 
4
+ # 1. Установка системных зависимостей (от имени root)
5
  RUN apt-get update && apt-get install -y \
6
  supervisor \
7
  curl \
 
9
  wget \
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
+ # 2. Установка zrok (от имени root)
 
 
13
  RUN curl -sSf https://get.openziti.io/install.bash | bash -s zrok
14
 
15
+ # 3. Создание non-root пользователя для Hugging Face Spaces [1]
16
+ RUN useradd -m -u 1000 user
17
+
18
+ # 4. Создание всех нужных абсолютных путей и выдача прав пользователю "user" [1]
19
+ # Supervisor требует права на запись в /var/run и /var/log
20
+ RUN mkdir -p /data/aiclient2api /data/kirogo /data/bifrost /etc/supervisor/conf.d /var/log/supervisor /var/run/supervisor \
21
+ && chown -R user:user /data /etc/supervisor /var/log/supervisor /var/run/supervisor
22
+
23
+ # 5. Переключение на non-root пользователя [1], [2]
24
+ USER user
25
+
26
+ # 6. Установка рабочей директории (абсолютный путь)
27
+ WORKDIR /data
28
+
29
  # ============================================
30
  # SECTION: AIClient2API
31
  # ============================================
 
35
  # ============================================
36
  # SECTION: Kiro-go
37
  # ============================================
38
+ RUN wget -O /data/kirogo/kiro-go https://github.com/user/kiro-go/releases/download/v1.0/kiro-go-linux-amd64 \
 
 
39
  && chmod +x /data/kirogo/kiro-go
40
 
41
  # ============================================
 
45
  && pip install --no-cache-dir -r /data/bifrost/requirements.txt
46
 
47
  # ============================================
48
+ # CONFIGS (Heredoc синтаксис) [14]
49
+ # ВАЖНО: используем --chown=user:user чтобы у процесса был доступ к конфигурации
50
  # ============================================
51
 
52
+ COPY --chown=user:user <<EOF /etc/supervisor/conf.d/supervisord.conf
 
53
  [supervisord]
54
  nodaemon=true
55
  logfile=/dev/stdout
56
  logfile_maxbytes=0
57
+ pidfile=/var/run/supervisor/supervisord.pid
58
 
59
  [program:bifrost]
60
  command=python /data/bifrost/main.py --port 7860
 
87
  stderr_logfile_maxbytes=0
88
 
89
  [program:zrok]
90
+ # Добавлен флаг --headless для работы в контейнере [9]
91
+ command=zrok share reserved %(ENV_ZROK_SHARE_NAME)s --headless
92
  autostart=true
93
  autorestart=true
94
  stdout_logfile=/dev/stdout
 
97
  stderr_logfile_maxbytes=0
98
  EOF
99
 
100
+ # Скрипт запуска
101
+ COPY --chown=user:user <<'EOF' /data/start.sh
102
  #!/bin/bash
103
  if [ -n "$ZROK_TOKEN" ]; then
104
+ zrok enable $ZROK_TOKEN --headless 2>/dev/null || true
105
  fi
106
  exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
107
  EOF
108
 
109
  RUN chmod +x /data/start.sh
110
 
111
+ # Наружу выставляем только порт 7860 для основного UI
112
  EXPOSE 7860
113
 
114
+ # Запуск по абсолютному пути
115
  CMD ["/data/start.sh"]