Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions genai-cookbook/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
ARG GPU_TYPE=nvidia
FROM modular/max-${GPU_TYPE}-base
# //////////////////////////////////////////////////////////////////////
# BASE ON UNIVERSAL MAX CONTAINER
FROM modular/max-full

WORKDIR /app

# //////////////////////////////////////////////////////////////////////
# UPDATE SYSTEM

RUN apt-get update && apt-get install -y \
curl \
build-essential \
git \
wget \
&& rm -rf /var/lib/apt/lists/*

# //////////////////////////////////////////////////////////////////////
# INSTALL NODE & NPM PACKAGES

RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
&& apt-get install -y nodejs \
&& rm -rf /var/lib/apt/lists/*
&& apt-get install -y nodejs \
&& rm -rf /var/lib/apt/lists/*

RUN npm install -g pm2 [email protected]

COPY package*.json ./

RUN npm install

# //////////////////////////////////////////////////////////////////////
# BUILD WEB APP

COPY . /app

RUN npm run build
Expand Down
24 changes: 9 additions & 15 deletions genai-cookbook/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,40 +175,34 @@ To use the cookbook with MAX:

## Running with Docker

The GenAI Cookbook can be run entirely within a Docker container, including the MAX model server and web application.
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.

### Building the Container

The Dockerfile defaults to NVIDIA GPUs:
Build the universal container image:

```bash
docker build --ulimit nofile=65535:65535 -t max-recipes:latest .
```

Use the `--build-arg` flag to specify AMD:

```bash
docker build --build-arg GPU_TYPE=amd --ulimit nofile=65535:65535 -t max-recipes:latest .
docker build --ulimit nofile=65535:65535 -t max-cookbook:latest .
```

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

### Running the Container

#### With NVIDIA GPUs
#### NVIDIA GPU

```bash
docker run --gpus all \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env "HF_HUB_ENABLE_HF_TRANSFER=1" \
--env "HF_TOKEN=your-huggingface-token" \
--env "MAX_MODEL=google/gemma-3-27b-it" \
--env "MAX_MODEL=mistral-community/pixtral-12b" \
-p 8000:8000 \
-p 3000:3000 \
max-recipes:latest
max-cookbook:latest
```

#### With AMD GPUs
#### AMD GPU

```bash
docker run \
Expand All @@ -219,10 +213,10 @@ docker run \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env "HF_HUB_ENABLE_HF_TRANSFER=1" \
--env "HF_TOKEN=your-huggingface-token" \
--env "MAX_MODEL=google/gemma-3-27b-it" \
--env "MAX_MODEL=mistral-community/pixtral-12b" \
-p 8000:8000 \
-p 3000:3000 \
max-recipes:latest
max-cookbook:latest
```

**Configuration:**
Expand Down
11 changes: 7 additions & 4 deletions genai-cookbook/ecosystem.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ module.exports = {
apps: [
{
name: 'max-llm',
script: 'max',
args: `serve --model ${process.env.MAX_MODEL || 'google/gemma-3-27b-it'} --trust-remote-code`,
script: '/bin/bash',
args: [
'-c',
'exec python -m max.entrypoints.pipelines serve --model-path "${MAX_MODEL:-google/gemma-3-27b-it}" --trust-remote-code',
],
interpreter: 'none',
autorestart: true,
watch: false,
Expand All @@ -13,13 +16,13 @@ module.exports = {
MAX_SERVE_PORT: 8000,
NODE_ENV: 'production',
},
},
},
{
name: 'web-app',
script: '/bin/bash',
args: [
'-c',
'wait-on http-get://0.0.0.0:8000/health -t 600000 -i 2000 && npm start',
'wait-on http-get://0.0.0.0:8000/v1/health -t 600000 -i 2000 && npm start',
],
interpreter: 'none',
autorestart: true,
Expand Down