Code Monkey home page Code Monkey logo

prisma-heroku's Introduction

Prisma on Heroku example

This repository showcases how to deploy Prisma to Heroku.

Prerequisites

  1. A Heroku account.
  2. Heroku CLI installed.
  3. Docker installed.

Step-by-step example deployment

  1. Clone this repo

  2. Log the Heroku CLI into Heroku: heroku login

  3. Log into the Heroku docker registry:

    1. heroku container:login
    2. If you face issues, try docker login --username=_ --password=$(heroku auth:token) registry.heroku.com
  4. Create a Heroku app via the web interface or via CLI: heroku create. This will return an app name if you didn't specify one, like endless-sand-123456. We need this name in the next steps.

  5. Execute the build script with the app name and desired Prisma version as args, for example: ./build.sh 1.8.4 endless-sand-123456. This does 2 things:

    1. It takes the Prisma docker image as a base and adds a prerun hook that renders the Prisma config required to run the app, and adds a CMD docker directive to the image that Heroku requires all images to have.
    2. It tags the image correctly for the Heroku registry and pushes it.
    3. This does NOT deploy the app.
  6. Optionally you can use Heroku Postgres for your database. If you would like to use Heroku to manage your Postgres database, first

    1. Create a new Postgres instance with: heroku addons:create heroku-postgresql:hobby-dev -a <your_app_name>
    2. Get the connection string for your new database: heroku config -a <your_app_name>
    3. Then you can extract the details for the next step from that string in the form postgres://<DB_USER>:<DB_PASSWORD>@<DB_HOST>/<DB_NAME>
  7. Now we need to configure the env vars:

    1. Either set them one by one via the CLI with heroku config:set <key>=<value> -a <your_app_name>...
    2. ...or navigate to the web interface and set them under settings
    3. Set the config vars:
      1. DB_HOST to your database host
      2. DB_PASSWORD to your database password
      3. DB_PORT to your database port
      4. DB_USER to your database user
      5. DB_HOST to your database name
      6. PRISMA_CONFIG_PATH to /app/config.yml
    4. Note: This example repo uses PostgreSQL. To change that, simply change the connector: postgres to connector: mysql in prerun_hook.sh.
  8. Finally, deploy the app with heroku container:release web -a <your_app_name>

  9. Open the app with heroku open -a <your_app_name> (this can take a bit, depending on the Dyno startup for example)

Additional notes

If you want to change the Prisma config, for example to add authentication (recommended), look at the prerun_hook.sh file and edit the config there. It is recommended to follow the existing pattern there and use env var interpolation with Heroku config vars to not accidentially commit secrets.

prisma-heroku's People

Contributors

dpetrick avatar stefl avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.