Skip to main content
The Portkey AI Gateway provides official Docker images for easy deployment. Run a single container with Docker or orchestrate multiple services with Docker Compose.

Docker Hub Image

The official Docker image is available at portkeyai/gateway on Docker Hub.

Quick Start with Docker

Run the latest version of the gateway with a single command:
docker run --rm -p 8787:8787 portkeyai/gateway:latest
The gateway will be available at http://localhost:8787.

Docker Run Options

1

Run in detached mode

Run the container in the background:
docker run -d -p 8787:8787 --name portkey-gateway portkeyai/gateway:latest
2

Mount configuration

Mount a custom configuration file:
docker run -d -p 8787:8787 \
  -v $(pwd)/conf.json:/app/conf.json \
  portkeyai/gateway:latest
3

Set environment variables

Pass environment variables to configure the gateway:
docker run -d -p 8787:8787 \
  -e LOG_LEVEL=debug \
  portkeyai/gateway:latest

Docker Compose

For production deployments, Docker Compose provides a more maintainable approach.

Download Compose File

1

Download the compose file

Download the official Docker Compose configuration:
wget "https://raw.githubusercontent.com/Portkey-AI/gateway/main/docker-compose.yaml"
2

Start the services

Launch the gateway:
docker compose up -d
3

Verify deployment

Check that the service is running:
docker compose ps

Docker Compose Configuration

Here’s the complete docker-compose.yaml file:
docker-compose.yaml
version: '3'
services:
  web:
    ports:
      - "8787:8787"
    image: "portkeyai/gateway:latest"
    restart: always

Customize Docker Compose

Extend the configuration for your needs:
version: '3'
services:
  web:
    ports:
      - "8787:8787"
    image: "portkeyai/gateway:latest"
    restart: always
    volumes:
      - ./conf.json:/app/conf.json
      - ./logs:/app/logs

Build from Source

You can also build the Docker image from source.

Dockerfile

The gateway uses a multi-stage build for optimal image size:
Dockerfile
# Use the official Node.js runtime as a parent image
FROM node:20-alpine AS build

# Set the working directory in the container
WORKDIR /app

# Copy package.json and package-lock.json to the working directory
COPY package*.json ./
COPY patches ./

# Upgrade system packages
RUN apk upgrade --no-cache

# Upgrade npm to version 10.9.2
RUN npm install -g [email protected]

# Install app dependencies
RUN npm install

# Copy the rest of the application code
COPY . .

# Build the application and clean up
RUN npm run build \
&& rm -rf node_modules \
&& npm install --omit=dev

# Use the official Node.js runtime as a parent image
FROM node:20-alpine

# Upgrade system packages
RUN apk upgrade --no-cache

# Upgrade npm to version 10.9.2
RUN npm install -g [email protected]

# Set the working directory in the container
WORKDIR /app

# Copy the build directory, node_modules, and package.json to the working directory
COPY --from=build /app/build /app/build
COPY --from=build /app/node_modules /app/node_modules
COPY --from=build /app/package.json /app/package.json
COPY --from=build /app/patches /app/patches

# Expose port 8787
EXPOSE 8787

ENTRYPOINT ["npm"]
CMD ["run", "start:node"]

Build Steps

1

Clone the repository

git clone https://github.com/portkey-ai/gateway
cd gateway
2

Build the image

docker build -t portkey-gateway:custom .
3

Run your custom image

docker run -p 8787:8787 portkey-gateway:custom

Docker Management

View Logs

# Follow logs
docker logs -f portkey-gateway

# With Docker Compose
docker compose logs -f

Stop and Remove

# Stop container
docker stop portkey-gateway

# Remove container
docker rm portkey-gateway

# With Docker Compose
docker compose down

Update to Latest Version

# Pull latest image
docker pull portkeyai/gateway:latest

# Restart container
docker restart portkey-gateway

# With Docker Compose
docker compose pull
docker compose up -d

Health Checks

Add health checks to your Docker deployment:
docker-compose.yaml
version: '3'
services:
  web:
    ports:
      - "8787:8787"
    image: "portkeyai/gateway:latest"
    restart: always
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8787/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

Next Steps

Kubernetes

Scale your deployment with Kubernetes

Configuration

Configure the gateway for your needs

Build docs developers (and LLMs) love