Skip to content
29 changes: 17 additions & 12 deletions genai-cookbook/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
# //////////////////////////////////////////////////////////////////////
# BASE ON UNIVERSAL MAX CONTAINER
FROM modular/max-full
# Use MAX_VARIANT build arg to select base image:
# - omitted/default → max-full:nightly
# - MAX_VARIANT=amd → max-amd-full:nightly
# - MAX_VARIANT=nvidia → max-nvidia-full:nightly

ARG MAX_GPU=universal
ARG MAX_TAG=latest

FROM modular/max-full:${MAX_TAG} AS base-universal
FROM modular/max-amd:${MAX_TAG} AS base-amd
FROM modular/max-nvidia-full:${MAX_TAG} AS base-nvidia

FROM base-${MAX_GPU} AS final

WORKDIR /app

# //////////////////////////////////////////////////////////////////////
# UPDATE SYSTEM
# INSTALL NODE

RUN apt-get update && apt-get install -y \
curl \
build-essential \
git \
wget \
RUN wget -qO- https://deb.nodesource.com/setup_22.x | bash - \
&& apt-get install -y nodejs \
&& 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/*
# INSTALL NPM PACKAGES

RUN npm install -g pm2 wait-on@7.2.0

Expand Down
26 changes: 26 additions & 0 deletions genai-cookbook/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,32 @@ 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.

#### Build Arguments

You can customize the Docker build using these arguments to reduce container size:

- **MAX_GPU**: Selects the base image (default: `universal`)
- `universal` → `modular/max-full` (larger, supports all GPU types)
- `amd` → `modular/max-amd` (smaller, AMD-specific)
- `nvidia` → `modular/max-nvidia-full` (smaller, NVIDIA-specific)

- **MAX_TAG**: Selects the image version (default: `latest`)
- `latest` → Latest stable release
- `nightly` → Nightly development builds
- Specific versions (e.g., `25.7.0`)

**Examples:**

Build smaller AMD-specific container:
```bash
docker build --build-arg MAX_GPU=amd --ulimit nofile=65535:65535 -t max-cookbook:amd .
```

Build smaller NVIDIA-specific container with nightly builds:
```bash
docker build --build-arg MAX_GPU=nvidia --build-arg MAX_TAG=nightly --ulimit nofile=65535:65535 -t max-cookbook:nvidia-nightly .
```

### Running the Container

#### NVIDIA GPU
Expand Down