Skip to content

Commit 4d5ee4d

Browse files
authored
[cookbook] Make container universal (#86)
* Make container universal with `modular/max-full` base image * Update readme
1 parent afe9904 commit 4d5ee4d

File tree

3 files changed

+30
-23
lines changed

3 files changed

+30
-23
lines changed

genai-cookbook/Dockerfile

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,35 @@
1-
ARG GPU_TYPE=nvidia
2-
FROM modular/max-${GPU_TYPE}-base
1+
# //////////////////////////////////////////////////////////////////////
2+
# BASE ON UNIVERSAL MAX CONTAINER
3+
FROM modular/max-full
34

45
WORKDIR /app
56

7+
# //////////////////////////////////////////////////////////////////////
8+
# UPDATE SYSTEM
9+
610
RUN apt-get update && apt-get install -y \
711
curl \
812
build-essential \
913
git \
1014
wget \
1115
&& rm -rf /var/lib/apt/lists/*
1216

17+
# //////////////////////////////////////////////////////////////////////
18+
# INSTALL NODE & NPM PACKAGES
19+
1320
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
14-
&& apt-get install -y nodejs \
15-
&& rm -rf /var/lib/apt/lists/*
21+
&& apt-get install -y nodejs \
22+
&& rm -rf /var/lib/apt/lists/*
1623

1724
RUN npm install -g pm2 [email protected]
1825

1926
COPY package*.json ./
2027

2128
RUN npm install
2229

30+
# //////////////////////////////////////////////////////////////////////
31+
# BUILD WEB APP
32+
2333
COPY . /app
2434

2535
RUN npm run build

genai-cookbook/README.md

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -175,40 +175,34 @@ To use the cookbook with MAX:
175175
176176
## Running with Docker
177177
178-
The GenAI Cookbook can be run entirely within a Docker container, including the MAX model server and web application.
178+
The GenAI Cookbook can be run entirely within a Docker container, including the MAX model server and web application. The container uses the universal MAX image with the nightly build, supporting both NVIDIA and AMD GPUs.
179179
180180
### Building the Container
181181
182-
The Dockerfile defaults to NVIDIA GPUs:
182+
Build the universal container image:
183183
184184
```bash
185-
docker build --ulimit nofile=65535:65535 -t max-recipes:latest .
186-
```
187-
188-
Use the `--build-arg` flag to specify AMD:
189-
190-
```bash
191-
docker build --build-arg GPU_TYPE=amd --ulimit nofile=65535:65535 -t max-recipes:latest .
185+
docker build --ulimit nofile=65535:65535 -t max-cookbook:latest .
192186
```
193187

194188
**Note:** The `--ulimit nofile=65535:65535` flag increases the file descriptor limit, which is needed for Next.js builds.
195189

196190
### Running the Container
197191

198-
#### With NVIDIA GPUs
192+
#### NVIDIA GPU
199193

200194
```bash
201195
docker run --gpus all \
202196
-v ~/.cache/huggingface:/root/.cache/huggingface \
203197
--env "HF_HUB_ENABLE_HF_TRANSFER=1" \
204198
--env "HF_TOKEN=your-huggingface-token" \
205-
--env "MAX_MODEL=google/gemma-3-27b-it" \
199+
--env "MAX_MODEL=mistral-community/pixtral-12b" \
206200
-p 8000:8000 \
207201
-p 3000:3000 \
208-
max-recipes:latest
202+
max-cookbook:latest
209203
```
210204

211-
#### With AMD GPUs
205+
#### AMD GPU
212206

213207
```bash
214208
docker run \
@@ -219,10 +213,10 @@ docker run \
219213
-v ~/.cache/huggingface:/root/.cache/huggingface \
220214
--env "HF_HUB_ENABLE_HF_TRANSFER=1" \
221215
--env "HF_TOKEN=your-huggingface-token" \
222-
--env "MAX_MODEL=google/gemma-3-27b-it" \
216+
--env "MAX_MODEL=mistral-community/pixtral-12b" \
223217
-p 8000:8000 \
224218
-p 3000:3000 \
225-
max-recipes:latest
219+
max-cookbook:latest
226220
```
227221

228222
**Configuration:**

genai-cookbook/ecosystem.config.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@ module.exports = {
22
apps: [
33
{
44
name: 'max-llm',
5-
script: 'max',
6-
args: `serve --model ${process.env.MAX_MODEL || 'google/gemma-3-27b-it'} --trust-remote-code`,
5+
script: '/bin/bash',
6+
args: [
7+
'-c',
8+
'exec python -m max.entrypoints.pipelines serve --model-path "${MAX_MODEL:-google/gemma-3-27b-it}" --trust-remote-code',
9+
],
710
interpreter: 'none',
811
autorestart: true,
912
watch: false,
@@ -13,13 +16,13 @@ module.exports = {
1316
MAX_SERVE_PORT: 8000,
1417
NODE_ENV: 'production',
1518
},
16-
},
19+
},
1720
{
1821
name: 'web-app',
1922
script: '/bin/bash',
2023
args: [
2124
'-c',
22-
'wait-on http-get://0.0.0.0:8000/health -t 600000 -i 2000 && npm start',
25+
'wait-on http-get://0.0.0.0:8000/v1/health -t 600000 -i 2000 && npm start',
2326
],
2427
interpreter: 'none',
2528
autorestart: true,

0 commit comments

Comments
 (0)