Docs/For AI Agents/Deployment Patterns

Deployment Patterns

Ready-to-use nexlayer.yaml templates for common application stacks. Copy these patterns and adapt them to the user's specific needs.

How to Use These Patterns

  1. Identify the stack that matches the user's application
  2. Copy the pattern and replace placeholder values (myuser, passwords, etc.)
  3. Adjust environment variables based on the user's actual configuration
  4. Add or remove pods as needed for the specific use case

Available Patterns

Static Website

Simple static site or SPA served by nginx

nexlayer.yaml
application:
  name: my-website

pods:
  - name: web
    image: nginx:latest
    path: /
    servicePorts: [80]

Next.js

Next.js application (standalone build)

nexlayer.yaml
application:
  name: nextjs-app

pods:
  - name: nextjs
    image: myuser/nextjs-app:latest
    path: /
    servicePorts: [3000]

Next.js + PostgreSQL

Full-stack Next.js with PostgreSQL database

nexlayer.yaml
application:
  name: nextjs-fullstack

pods:
  - name: nextjs
    image: myuser/nextjs-app:latest
    path: /
    servicePorts: [3000]
    vars:
      DATABASE_URL: postgresql://postgres:password@postgres.pod:5432/mydb

  - name: postgres
    image: postgres:15
    servicePorts: [5432]
    vars:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: password
      POSTGRES_DB: mydb
    volumes:
      - name: postgres-data
        size: 1Gi
        mountPath: /var/lib/postgresql/data

PERN Stack

PostgreSQL + Express + React + Node.js

nexlayer.yaml
application:
  name: pern-app

pods:
  # Database
  - name: postgres
    image: postgres:15
    servicePorts: [5432]
    vars:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: secretpassword
      POSTGRES_DB: myapp
    volumes:
      - name: pg-data
        size: 2Gi
        mountPath: /var/lib/postgresql/data

  # API
  - name: express
    image: myuser/express-api:latest
    path: /api
    servicePorts: [3000]
    vars:
      DATABASE_URL: postgresql://postgres:secretpassword@postgres.pod:5432/myapp
      NODE_ENV: production

  # Frontend
  - name: react
    image: myuser/react-app:latest
    path: /
    servicePorts: [80]
    vars:
      REACT_APP_API_URL: /api

MERN Stack

MongoDB + Express + React + Node.js

nexlayer.yaml
application:
  name: mern-app

pods:
  # Database
  - name: mongo
    image: mongo:7
    servicePorts: [27017]
    vars:
      MONGO_INITDB_ROOT_USERNAME: admin
      MONGO_INITDB_ROOT_PASSWORD: secretpassword
    volumes:
      - name: mongo-data
        size: 2Gi
        mountPath: /data/db

  # API
  - name: express
    image: myuser/express-api:latest
    path: /api
    servicePorts: [3000]
    vars:
      MONGODB_URI: mongodb://admin:secretpassword@mongo.pod:27017/myapp?authSource=admin
      NODE_ENV: production

  # Frontend
  - name: react
    image: myuser/react-app:latest
    path: /
    servicePorts: [80]

Python FastAPI

FastAPI with PostgreSQL

nexlayer.yaml
application:
  name: fastapi-app

pods:
  - name: api
    image: myuser/fastapi-app:latest
    path: /
    servicePorts: [8000]
    vars:
      DATABASE_URL: postgresql://postgres:password@postgres.pod:5432/mydb

  - name: postgres
    image: postgres:15
    servicePorts: [5432]
    vars:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: password
      POSTGRES_DB: mydb
    volumes:
      - name: postgres-data
        size: 1Gi
        mountPath: /var/lib/postgresql/data

Django

Django with PostgreSQL and Redis

nexlayer.yaml
application:
  name: django-app

pods:
  - name: django
    image: myuser/django-app:latest
    path: /
    servicePorts: [8000]
    vars:
      DATABASE_URL: postgresql://postgres:password@postgres.pod:5432/django
      REDIS_URL: redis://redis.pod:6379
      DJANGO_SETTINGS_MODULE: myapp.settings.production

  - name: postgres
    image: postgres:15
    servicePorts: [5432]
    vars:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: password
      POSTGRES_DB: django
    volumes:
      - name: postgres-data
        size: 2Gi
        mountPath: /var/lib/postgresql/data

  - name: redis
    image: redis:7-alpine
    servicePorts: [6379]

Go API

Go API with PostgreSQL

nexlayer.yaml
application:
  name: go-api

pods:
  - name: api
    image: myuser/go-api:latest
    path: /
    servicePorts: [8080]
    vars:
      DATABASE_URL: postgresql://postgres:password@postgres.pod:5432/mydb
      GIN_MODE: release

  - name: postgres
    image: postgres:15
    servicePorts: [5432]
    vars:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: password
      POSTGRES_DB: mydb
    volumes:
      - name: postgres-data
        size: 1Gi
        mountPath: /var/lib/postgresql/data

App + Redis Cache

Any app with Redis for caching/sessions

nexlayer.yaml
application:
  name: app-with-cache

pods:
  - name: app
    image: myuser/my-app:latest
    path: /
    servicePorts: [3000]
    vars:
      REDIS_URL: redis://redis.pod:6379

  - name: redis
    image: redis:7-alpine
    servicePorts: [6379]
    volumes:
      - name: redis-data
        size: 500Mi
        mountPath: /data

WordPress

WordPress with MySQL

nexlayer.yaml
application:
  name: wordpress-site

pods:
  - name: wordpress
    image: wordpress:latest
    path: /
    servicePorts: [80]
    vars:
      WORDPRESS_DB_HOST: mysql.pod:3306
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: secretpassword
      WORDPRESS_DB_NAME: wordpress
    volumes:
      - name: wp-content
        size: 5Gi
        mountPath: /var/www/html/wp-content

  - name: mysql
    image: mysql:8
    servicePorts: [3306]
    vars:
      MYSQL_ROOT_PASSWORD: rootpassword
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: secretpassword
    volumes:
      - name: mysql-data
        size: 2Gi
        mountPath: /var/lib/mysql

Remember

  • Replace myuser/ with the actual Docker Hub username or registry path
  • Generate strong passwords — don't use the placeholder values
  • Check that servicePorts match what the container actually exposes
  • Adjust volume sizes based on expected data storage needs
  • For production, add the url field with the custom domain