imbecome commited on
Commit
38c8e16
·
verified ·
1 Parent(s): c31e0ad

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +14 -11
Dockerfile CHANGED
@@ -1,42 +1,45 @@
1
  FROM python:3.10-slim
2
 
3
- # Install system dependencies
4
  RUN apt-get update && apt-get install -y \
5
  curl ffmpeg git build-essential libgomp1 procps \
6
  && rm -rf /var/lib/apt/lists/*
7
 
8
- # PERBAIKAN TOTAL: Download langsung dari link statis resmi Ollama
9
- # Menggunakan -f agar build gagal jika download gagal
10
- RUN curl -L -f https://ollama.com/download/ollama-linux-amd64 -o /usr/bin/ollama && \
11
  chmod +x /usr/bin/ollama
12
 
13
- # Pastikan biner benar-benar terinstal (Cek versi saat build)
14
  RUN /usr/bin/ollama --version
15
 
16
- # Buat user non-root
17
  RUN useradd -m -u 1000 user
18
  WORKDIR /home/user/app
19
 
20
- # Folder cache dengan izin penuh
21
  RUN mkdir -p /home/user/app/models_cache/.ollama && \
22
  chown -R user:user /home/user/app && \
23
  chmod -R 777 /home/user/app/models_cache
24
 
25
- # Copy project files
26
  COPY --chown=user:user requirements.txt .
27
- RUN pip install --no-cache-dir -r requirements.txt
 
28
 
 
29
  COPY --chown=user:user . .
 
30
 
 
31
  ENV HF_HOME=/home/user/app/models_cache
32
  ENV OLLAMA_MODELS=/home/user/app/models_cache/.ollama
33
  ENV HOME=/home/user/app
34
  ENV PYTHONUNBUFFERED=1
35
 
36
- RUN chmod +x start.sh
37
  USER user
38
 
39
- # Pre-download (opsional)
40
  RUN python download_models.py
41
 
42
  EXPOSE 7860
 
1
  FROM python:3.10-slim
2
 
3
+ # 1. Install dependencies sistem
4
  RUN apt-get update && apt-get install -y \
5
  curl ffmpeg git build-essential libgomp1 procps \
6
  && rm -rf /var/lib/apt/lists/*
7
 
8
+ # 2. FIX: Gunakan URL alternatif jika ollama.com bermasalah
9
+ # Kita tambahkan flag -S (silent) tapi tetap tampilkan error jika gagal
10
+ RUN curl -L -f -S https://ollama.com/download/ollama-linux-amd64 -o /usr/bin/ollama && \
11
  chmod +x /usr/bin/ollama
12
 
13
+ # 3. Validasi instan: Jika ini gagal, build akan stop di sini (mencegah error runtime)
14
  RUN /usr/bin/ollama --version
15
 
16
+ # 4. Setup User & Direktori
17
  RUN useradd -m -u 1000 user
18
  WORKDIR /home/user/app
19
 
20
+ # 5. Buat folder cache dan atur izin akses di awal
21
  RUN mkdir -p /home/user/app/models_cache/.ollama && \
22
  chown -R user:user /home/user/app && \
23
  chmod -R 777 /home/user/app/models_cache
24
 
25
+ # 6. Install Python Requirements (Layering agar hemat waktu build)
26
  COPY --chown=user:user requirements.txt .
27
+ RUN pip install --no-cache-dir --upgrade pip && \
28
+ pip install --no-cache-dir -r requirements.txt
29
 
30
+ # 7. Copy Project & Scripts
31
  COPY --chown=user:user . .
32
+ RUN chmod +x start.sh
33
 
34
+ # 8. Environment Variables
35
  ENV HF_HOME=/home/user/app/models_cache
36
  ENV OLLAMA_MODELS=/home/user/app/models_cache/.ollama
37
  ENV HOME=/home/user/app
38
  ENV PYTHONUNBUFFERED=1
39
 
 
40
  USER user
41
 
42
+ # 9. Download model (pastikan script ini tidak error)
43
  RUN python download_models.py
44
 
45
  EXPOSE 7860