chatbotMOAI / Dockerfile
code-slicer's picture
Update Dockerfile
9116ec3 verified
raw
history blame
1.81 kB
# 1. ํŒŒ์ด์ฌ ๋ฒ„์ „์„ 3.10์œผ๋กœ ์„ค์ •
FROM python:3.11-slim
# 2. ํ•„์š”ํ•œ ์‹œ์Šคํ…œ ํŒจํ‚ค์ง€ ๋ฐ git-lfs ์„ค์น˜
RUN pip install --no-cache-dir hf_transfer>=0.1.6
RUN apt-get update && apt-get install -y \
build-essential \
curl \
git \
git-lfs \
&& rm -rf /var/lib/apt/lists/*
# 3. ์ž‘์—… ๋””๋ ‰ํ„ฐ๋ฆฌ ์„ค์ •
WORKDIR /app
# 4. ์†Œ์Šค ์ฝ”๋“œ ๋ณต์‚ฌ
COPY . /app
# 5. Git LFS ์„ค์ • ๋ฐ ๋Œ€์šฉ๋Ÿ‰ ํŒŒ์ผ ๋‹ค์šด๋กœ๋“œ
RUN git lfs install && \
git lfs pull
# 6. ํŒŒ์ด์ฌ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์„ค์น˜
RUN pip install --no-cache-dir -r requirements.txt
# 7. ์ŠคํŠธ๋ฆผ๋ฆฟ์ด ์‚ฌ์šฉํ•  ์„ค์ • ํด๋”๋ฅผ ๋ฏธ๋ฆฌ ๋งŒ๋“ค๊ณ  ๊ถŒํ•œ ๋ถ€์—ฌ (PermissionError ํ•ด๊ฒฐ)
# ๊ถŒํ•œ/๊ฒฝ๋กœ ๊ณ ์ •
ENV HOME=/app
ENV STREAMLIT_HOME=/app/.streamlit
RUN mkdir -p /app/.streamlit && chmod -R 777 /app/.streamlit
# ๊ถŒ์žฅ: ์บ์‹œ ๊ฒฝ๋กœ๋ฅผ ํ™˜๊ฒฝ๋ณ€์ˆ˜๋กœ ๊ณ ์ •
ENV HF_HOME=/tmp/hf-home \
TRANSFORMERS_CACHE=/tmp/hf-cache \
HUGGINGFACE_HUB_CACHE=/tmp/hf-cache \
TORCH_HOME=/tmp/torch-cache \
XDG_CACHE_HOME=/tmp/xdg-cache
RUN mkdir -p /tmp/hf-home /tmp/hf-cache /tmp/torch-cache /tmp/xdg-cache
# 8. ํฌํŠธ ๊ฐœ๋ฐฉ
EXPOSE 8501
# ์˜ฌ๋ผ๋งˆ ์„œ๋ฒ„
FROM ubuntu:22.04
RUN apt-get update && apt-get install -y curl ca-certificates && rm -rf /var/lib/apt/lists/*
RUN curl -fsSL https://ollama.com/install.sh | bash
ENV OLLAMA_MODELS=/data/ollama
ENV OLLAMA_ORIGINS=* # ์šด์˜์—์„  ์ •ํ™•ํ•œ ๋„๋ฉ”์ธ์œผ๋กœ ์ œํ•œ ๊ถŒ์žฅ
CMD bash -lc '\
OLLAMA_HOST=0.0.0.0:$PORT ollama serve & \
until curl -s http://127.0.0.1:$PORT/api/version >/dev/null; do sleep 1; done; \
# (์„ ํƒ) ๋ฏธ๋ฆฌ ํ•œ ๋ชจ๋ธ pull: ollama pull llama3.1:8b || true; \
wait'
# 9. ์•ฑ ์‹คํ–‰ (PermissionError ์ถ”๊ฐ€ ๋ฐฉ์ง€)
CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.fileWatcherType=none"]