-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathDockerfile
85 lines (64 loc) · 2.4 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# .github/Dockerfile
# ---------------------------------------------------
# 1) Node base image - Using Debian slim for smaller footprint
# ---------------------------------------------------
FROM node:22-slim AS base
# Install only required system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg git make curl ca-certificates cmake python3 python3-pip \
libopenblas-dev g++ build-essential && rm -rf /var/lib/apt/lists/* \
&& apt-get clean
RUN update-ca-certificates
WORKDIR /usr/src/app
# Install yt-dlp
RUN curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp \
-o /usr/local/bin/yt-dlp && \
chmod a+rx /usr/local/bin/yt-dlp
# Install tsx globally
RUN npm install -g tsx
# Install whisper.cpp and download models
RUN git clone --depth=1 https://github.com/ggerganov/whisper.cpp.git && \
cd whisper.cpp && \
cmake -B build && \
cmake --build build -j --config Release && \
./models/download-ggml-model.sh large-v3-turbo && \
./models/download-ggml-model.sh base && \
./models/download-ggml-model.sh tiny && \
rm -rf .git
# Copy package files and install deps
COPY package*.json ./
RUN npm ci --production && npm cache clean --force
# Copy source code
COPY src ./src
COPY .github/docker-entrypoint.sh ./
RUN chmod +x /usr/src/app/docker-entrypoint.sh
# ---------------------------------------------------
# 2) Setup Ollama with models
# ---------------------------------------------------
FROM ollama/ollama:latest AS ollama
WORKDIR /root/.ollama
# Start Ollama server and pull models
RUN ollama serve & \
sleep 10 && \
ollama pull llama3.2:1b && \
pkill ollama
# ---------------------------------------------------
# 3) Final stage combining everything
# ---------------------------------------------------
FROM base
# Copy Ollama binary and the pre-downloaded models
COPY --from=ollama /bin/ollama /usr/local/bin/ollama
COPY --from=ollama /root/.ollama /root/.ollama
ENV WHISPER_FORCE_CPU=1
ENV WHISPER_NO_GPU=1
# Create content directory first
RUN mkdir -p /usr/src/app/content
# Set proper permissions for the entire app directory including content
RUN chown -R node:node /usr/src/app && \
chmod -R 755 /usr/src/app && \
chmod 777 /usr/src/app/content # Ensure content dir is fully writable
# Switch to non-root user
USER node
EXPOSE 3000
ENTRYPOINT ["/usr/src/app/docker-entrypoint.sh"]
CMD ["serve"]