Prisma ServerDeployment Environments

Docker

Overview

Prisma servers can be run with Docker. This page contains everything you need to know around the Docker setup and relevant worfklows.

Prisma Docker image

The prisma Docker image is available via Docker Hub. You can pull the latest released version of the image using the following command:

docker pull prismagraphql/prisma

Common workflows

The Docker CLI and Docker Compose CLI are used to manage the Prisma servers.

Here's a quick rundown of the most important commands:

Note that these commands need to be executed in the directory where the Docker Compose file for your Prisma server is available.

Docker Compose file

Here is an overview of all properties you need to configure on the prisma Docker image inside your Docker Compose file. The all-uppercase words represent placeholders for the configuration variables you need to provide for your Prisma setup.

version: '3'
services:
  prisma:
    image: prismagraphql/prisma:__LATEST_PRISMA_VERSION__
    restart: always
    ports:
    - "4466:4466"
    environment:
      PRISMA_CONFIG: |
        managementApiSecret: __YOUR_MANAGEMENT_API_SECRET__
        port: __YOUR_PRISMA_SERVER_PORT__
        databases:
          default:
            connector: __YOUR_DATABASE_CONNECTOR__
            migrations: __ENABLE_DB_MIGRATIONS__
            host: __YOUR_DATABASE_HOST__
            port: __YOUR_DATABASE_PORT__
            user: __YOUR_DATABASE_USER__
            password: __YOUR_DATABASE_PASSWORD__
            connectionLimit: __YOUR_CONNECTION_LIMIT__

Most notably most of your configuration takes place in the PRISMA_CONFIG environment variable.

Despite seemingly following the YAML key-value structure, PRISMA_CONFIG is actually speficied as a string. The pipe character | right after PRISMA_CONFIG denotes the beginning of a multi-line string in YAML.

PRISMA_CONFIG reference

Root properties

These are the root properties of PRISMA_CONFIG:

KeyTypeDescription
managementApiSecretstringThe Management API secret is used by the Prisma CLI to generate authentication tokens and authenticate its requests against the Prisma server. Example: mysecret42
portnumberThe port on which the Prisma server is running. Example: 4466
databasesobjectSpecifies to which databases the Prisma server should connect to.

Database properties

Each database object in the databases object needs to include the following properties:

KeyTypeDescription
connectorstringSpecifies which database connector to be used. Learn more.
migrationsbooleanSpecifies if Prisma should be able to perform database migrations. Learn more.
hoststringThe IP address or URL of the machine hosting the database. Example: 127.0.0.1
portnumberThe post where the database is running.
databasestringThe database name. Default: prisma
userstringThe database user. Example: root
passwordstringThe password for the database user specified in user. Example: myDBpassword42
sslbooleanEnable SSL
connectionLimitnumberThe maximum number of database connections (must be at least 2). Learn more.

Debugging

To get insights into the internals of your Prisma server, you can check the logs of the Docker container.

Accessing Docker logs

View the raw logs from the running Docker containers:

docker-compose logs

Verify Docker containers

Verify that the containers are running:

docker ps

You should see an output similar to this:

$ docker ps
CONTAINER ID        IMAGE                               COMMAND                  CREATED             STATUS              PORTS                    NAMES
2b799c529e73        prismagraphql/prisma:1.26            "/bin/sh -c /app/sta…"   17 hours ago        Up 7 hours          0.0.0.0:4466->4466/tcp   myapp_prisma_1
757dfba212f7        mysql:5.7                           "docker-entrypoint.s…"   17 hours ago        Up 7 hours          3306/tcp                 prisma-db

This is helpful when you're getting an error message saying Error response from daemon: No such container.

Hard resetting the Docker environment

If your local Prisma server is in an unrecoverable state, it might be necessary to completely reset it:

docker-compose kill
docker-compose down
docker-compose up -d

Be careful as these commands will reset all data in your local Prisma server (including deployed Prisma APIs).