Run Prisma Server

Local Prisma Setup

Overview

You can run a local instance of a Prisma service using Docker. Learn more about the Docker configuration of Prisma servers here.

This page explains how you can use Prisma with a local database instance. Both the Prisma server and the database are configured locally through Docker.

Example Docker Compose setup

MySQL

The following Docker Compose file configures two Docker containers:

  • prisma: The container running your Prisma server.
  • mysql-db: The container running a local MySQL instance, based on the MySQL Docker image.

prisma is using the mysql-db container as its database. Instead of referencing the database host via an IP address or URL, it simply references the mysql-db image as the database host:

version: '3'
services:
  prisma:
    image: prismagraphql/prisma:1.20
    restart: always
    ports:
      - '4466:4466'
    environment:
      PRISMA_CONFIG: |
        managementApiSecret: my-server-secret-123
        port: 4466
        databases:
          default:
            connector: mysql
            migrations: true
            host: mysql-db
            port: 3306
            user: root
            password: prisma
  mysql-db:
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: prisma
    volumes:
      - mysql:/var/lib/mysql
volumes:
  mysql: ~

Postgres

The following Docker Compose file configures two Docker containers:

  • prisma: The container running your Prisma server.
  • postgres-db: The container running a local Postgres instance, based on the Postgres Docker image.

prisma is using the postgres-db container as its database. Instead of referencing the database host via an IP address or URL, it simply references the postgres-db image as the database host:

version: '3'
services:
  prisma:
    image: prismagraphql/prisma:1.20
    restart: always
    ports:
      - '4466:4466'
    environment:
      PRISMA_CONFIG: |
        port: 4466
        managementApiSecret: mysecret42
        databases:
          default:
            connector: postgres
            host: postgres-db
            port: 5432
            user: prisma
            password: prisma
            migrations: true
  postgres-db:
    image: postgres
    restart: always
    environment:
      POSTGRES_USER: prisma
      POSTGRES_PASSWORD: prisma
    volumes:
      - postgres:/var/lib/postgresql/data
volumes:
  postgres: ~