code-slicer commited on
Commit
6a5727c
·
verified ·
1 Parent(s): f1cfff4

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +19 -15
Dockerfile CHANGED
@@ -10,19 +10,16 @@ RUN apt-get update && apt-get install -y \
10
  git-lfs \
11
  && rm -rf /var/lib/apt/lists/*
12
 
13
- # 기존 명령어 (404 오류 발생)
14
- # RUN curl -L --fail https://ollama.com/download/ollama-linux-amd64 -o /usr/local/bin/ollama \
15
- # && chmod +x /usr/local/bin/ollama
16
-
17
- # 수정된 명령어 (install.sh 스크립트 사용)
18
  RUN curl -fsSL https://ollama.com/install.sh | sh
19
 
20
- # Ollama가 홈/모델 경로를 /app/.ollama 로 통일
 
21
  ENV OLLAMA_HOME=/app/.ollama
22
  ENV OLLAMA_MODELS=/app/.ollama
23
  RUN mkdir -p /app/.ollama && chmod -R 777 /app/.ollama
24
 
25
- # 빌드 중 잠깐 서버를 띄워서 모델만 미리 받아두고 종료
26
  RUN set -eux; \
27
  ollama serve & pid=$!; \
28
  i=0; \
@@ -47,13 +44,11 @@ COPY . /app
47
  # 5. Git LFS 설정 및 대용량 파일 다운로드
48
  RUN git lfs install && git lfs pull || true
49
 
50
- # 7. 스트림릿이 사용할 설정 폴더를 미리 만들고 권한 부여 (PermissionError 해결)
51
- # 권한/경로 고정
52
  ENV HOME=/app
53
  ENV STREAMLIT_HOME=/app/.streamlit
54
  RUN mkdir -p /app/.streamlit && chmod -R 777 /app/.streamlit
55
 
56
- # 권장: 캐시 경로를 환경변수로 고정
57
  ENV HF_HOME=/tmp/hf-home \
58
  TRANSFORMERS_CACHE=/tmp/hf-cache \
59
  HUGGINGFACE_HUB_CACHE=/tmp/hf-cache \
@@ -62,15 +57,24 @@ ENV HF_HOME=/tmp/hf-home \
62
 
63
  RUN mkdir -p /tmp/hf-home /tmp/hf-cache /tmp/torch-cache /tmp/xdg-cache
64
 
65
- # 내부 연결용 환경변수(앱에서 읽게 하려면 편의상 지정)
66
  ENV OLLAMA_HOST=http://127.0.0.1:11434
67
  EXPOSE 8501
68
- # (외부로 Ollama를 열 필요는 없지만, 있어도 무방)
69
  EXPOSE 11434
70
 
71
- # 🔴 최종 실행 커맨드: ollama serve → 레디체크 → streamlit
72
  CMD bash -lc '\
 
 
73
  ollama serve & \
74
- for i in {1..120}; do curl -fsS http://127.0.0.1:11434/api/version >/dev/null && break || sleep 1; done; \
75
- ollama pull ${OLLAMA_MODEL} || exit 1; \
 
 
 
 
 
 
 
 
 
76
  streamlit run app.py --server.address=0.0.0.0 --server.port=${PORT:-8501}'
 
10
  git-lfs \
11
  && rm -rf /var/lib/apt/lists/*
12
 
13
+ # Ollama 설치
 
 
 
 
14
  RUN curl -fsSL https://ollama.com/install.sh | sh
15
 
16
+ # 환경변수 설정 (명시적으로 모델명 지정)
17
+ ENV OLLAMA_MODEL=gemma2:9b
18
  ENV OLLAMA_HOME=/app/.ollama
19
  ENV OLLAMA_MODELS=/app/.ollama
20
  RUN mkdir -p /app/.ollama && chmod -R 777 /app/.ollama
21
 
22
+ # 빌드 중 모델 다운로드
23
  RUN set -eux; \
24
  ollama serve & pid=$!; \
25
  i=0; \
 
44
  # 5. Git LFS 설정 및 대용량 파일 다운로드
45
  RUN git lfs install && git lfs pull || true
46
 
47
+ # 환경변수 설정
 
48
  ENV HOME=/app
49
  ENV STREAMLIT_HOME=/app/.streamlit
50
  RUN mkdir -p /app/.streamlit && chmod -R 777 /app/.streamlit
51
 
 
52
  ENV HF_HOME=/tmp/hf-home \
53
  TRANSFORMERS_CACHE=/tmp/hf-cache \
54
  HUGGINGFACE_HUB_CACHE=/tmp/hf-cache \
 
57
 
58
  RUN mkdir -p /tmp/hf-home /tmp/hf-cache /tmp/torch-cache /tmp/xdg-cache
59
 
 
60
  ENV OLLAMA_HOST=http://127.0.0.1:11434
61
  EXPOSE 8501
 
62
  EXPOSE 11434
63
 
64
+ # 수정된 CMD
65
  CMD bash -lc '\
66
+ export OLLAMA_MODEL=${OLLAMA_MODEL:-gemma2:9b}; \
67
+ echo "Starting Ollama with model: $OLLAMA_MODEL"; \
68
  ollama serve & \
69
+ for i in {1..120}; do \
70
+ if curl -fsS http://127.0.0.1:11434/api/version >/dev/null 2>&1; then \
71
+ echo "Ollama server is ready"; \
72
+ break; \
73
+ fi; \
74
+ echo "Waiting for Ollama... ($i/120)"; \
75
+ sleep 1; \
76
+ done; \
77
+ echo "Ensuring model is available: $OLLAMA_MODEL"; \
78
+ ollama pull "$OLLAMA_MODEL" || { echo "Failed to pull model"; exit 1; }; \
79
+ echo "Starting Streamlit app"; \
80
  streamlit run app.py --server.address=0.0.0.0 --server.port=${PORT:-8501}'