Skip to content

Commit 23c28c7

Browse files
committed
Clean up image, build ollama image with pre-pulled model, update compose
1 parent 5890b50 commit 23c28c7

File tree

5 files changed

+27
-19
lines changed

5 files changed

+27
-19
lines changed

Dockerfile

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,18 @@ FROM node:${NODE_VERSION}-alpine
1212

1313
WORKDIR /usr/src/app
1414

15-
# Download dependencies as a separate step to take advantage of Docker's caching.
16-
# Leverage a cache mount to /root/.npm to speed up subsequent builds.
17-
# Leverage a bind mounts to package.json and package-lock.json to avoid having to copy them into
18-
# into this layer.
19-
RUN --mount=type=bind,source=package.json,target=package.json \
20-
--mount=type=bind,source=package-lock.json,target=package-lock.json \
21-
--mount=type=cache,target=/root/.npm \
22-
npm ci --omit=dev
23-
2415
# Run the application as a non-root user.
2516
USER node
2617

2718
# Copy the rest of the source files into the image.
28-
COPY . .
19+
20+
COPY package.json package-lock.json /usr/src/app/
21+
22+
COPY server.js .
23+
24+
COPY src/ .
25+
26+
COPY public/ .
2927

3028
# Expose the port that the application listens on.
3129
EXPOSE 3000

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ I used compose to develop this locally.
2525
- `docker compose up --build`
2626
- When done, `docker compose down`
2727

28+
#### Build the Ollama image with model pre pulled
29+
- Build: `docker build -f ollama/Dockerfile -t ollama_model --platform=linux/amd64 .`
30+
- Run: `docker run -d --platform=linux/amd64 ollama_model`
31+
2832
### On EKS or MiniKube
2933
- Set up an EKS cluster. I followed this [tutorial](https://medium.com/@tamerbenhassan/deploying-a-simple-application-using-eks-step-by-step-guide-512b1559a7bd).
3034
- `kubectl apply -k out/overlays/desktop`
@@ -33,5 +37,8 @@ I used compose to develop this locally.
3337
- I had to rebuild for AMD when the image was not able to be pulled by the pod. It should know to pull the AMD image build.
3438
- The default image size for your nodes is m5.large. Increase your resource requests as needed.
3539

40+
- Create a node group for the model containers with the taint and labels set correctly (to model=true)
41+
- Set up your Route 53 by pointing the alias to the K8s cluster public domain, and request a certificate and put the CNAME name and values into Route 53. Additionally, add your pre-generated nameservers to the domain service DNS tab.
42+
3643
#### General Notes:
3744
- Switch kube contexts when working with MiniKube vs. EKS. Get contexts by running `kubectl config get-contexts` and swtich by running: `kubectl config use-context {NAME}`

compose.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,15 @@ services:
1717
context: .
1818
volumes:
1919
- ./:/usr/src/app
20-
- /usr/src/app/node_modules
20+
#- /usr/src/app/node_modules
2121
env_file:
2222
- .env.compose
2323
ports:
2424
- 3000:3000
2525
- 5002:5002
2626
model:
2727
container_name: model
28-
image: ollama/ollama:0.6.2
28+
build:
29+
context: ./ollama
2930
ports:
3031
- 11434:11434
31-
post_start:
32-
- command: ollama pull llama3.2

ollama/Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM ollama/ollama:0.6.2
2+
3+
# Pre-pull the model during build
4+
RUN ollama serve & \
5+
sleep 3 && \
6+
ollama pull llama3.2 && \
7+
pkill ollama

out/base/model-deployment.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ spec:
3232
effect: "NoSchedule"
3333
containers:
3434
- name: ollama
35-
image: ollama/ollama:0.6.2
35+
image: samanthamorris684/ollama:latest
3636
imagePullPolicy: IfNotPresent
3737
ports:
3838
- name: model-11434
@@ -44,7 +44,4 @@ spec:
4444
limits:
4545
cpu: "7000m"
4646
memory: "30Gi"
47-
lifecycle:
48-
postStart:
49-
exec:
50-
command: ["/bin/sh", "-c", "ollama pull llama3.2"]
47+

0 commit comments

Comments
 (0)