Skip to content

Instantly share code, notes, and snippets.

@ivorpad
Last active October 6, 2019 03:20
Show Gist options
  • Save ivorpad/f39bd6c0e659f8d2991b48f1c8198113 to your computer and use it in GitHub Desktop.
Save ivorpad/f39bd6c0e659f8d2991b48f1c8198113 to your computer and use it in GitHub Desktop.
Quick instructions to setup a Prisma server on Linode
  1. SSH to server
  2. Install Docker and Docker Compose:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install -y docker-ce
sudo curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
  1. Install Node:
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs
  1. Install Prisma CLI npm -g install prisma
  2. Create docker-compose.yml with the following content:
version: '3'
services:
  prisma:
    image: prismagraphql/prisma:1.12
    restart: always
    ports:
    - "4466:4466"
    environment:
      PRISMA_CONFIG: |
        port: 4466
        managementApiSecret: my-secret
        databases:
          default:
            connector: mysql
            host: mysql
            port: 3306
            user: root
            password: prisma
            migrations: true
  mysql:
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: prisma
    volumes:
      - mysql:/var/lib/mysql
volumes:
  mysql:
  1. Make sure you create a managementApiSecret which you will put in your .env file.

  2. Run docker-compose up -d which will fetch the Docker images for Prisma and MySQL

  3. Verify containers with docker ps

  4. Bootstrap a new Prisma service with prisma init hello-world

  5. Select Use other server and it'll prompt for your Prisma Server endpoint, enter the public IP of your Linode with the Prisma port e.g. http://<linode_public_ip>:4466, hit enter and provide a service name e.g. hello then a stage e.g. dev

  6. cd hello-world open your .env file or create one if it doesn't exist and make sure it has the variable PRISMA_MANAGEMENT_API_SECRET with the same API secret from docker-compose.yml

  7. prisma deploy and wait for it to finish and open the following webpage:

http://<linode_public_io>:4466/hello/dev

@ivorpad
Copy link
Author

ivorpad commented Sep 21, 2018

To get /generated/prisma.graphql first install the GraphQL CLI and run the init command: graphql init this will generate a new file called .grapqhqlconfig.yaml and make sure it looks similar to:

projects:
  prisma:
    schemaPath: generated/prisma.graphql
    extensions:
      prisma: prisma.yml
      prepare-binding:
        output: generated/prisma.ts
        generator: prisma-ts

Then copy into prisma.yml:

endpoint: http://<linode_public_ip>:4466/hello/dev
datamodel: datamodel.graphql

hooks:
  post-deploy:
    - echo "Deploy finished"
    - graphql get-schema --project prisma
    - graphql prepare

@mharrvic
Copy link

mharrvic commented Nov 8, 2018

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment