GraphCool Continuous Deployment with Bitbucket Pipeline

johnpaulada

John Paul Ada

Posted on May 14, 2018

GraphCool Continuous Deployment with Bitbucket Pipeline

This was originally posted on the GAPLabs Engineering Blog.

If you can automate it, you should.

We all try to live by this, but it’s not always easy. Automation is not the easiest thing to do. But it should be. And continuously deploying a GraphCool server with Bitbucket Pipelines is. Because we use Bitbucket everyday, it’s a no-brainer that we’d use Bitbucket Pipelines as our service of choice.

In order to deploy a GraphCool server, we just need to do these steps:

  1. Install the GraphCool CLI.
  2. Install dependencies.
  3. Run graphcool deploy.

bitbucket-pipelines.yml

Bitbucket Pipelines

That’s it. Just include this bitbucket-pipelines.yml file in your root directory and push some changes to the master or dev branches. It will then begin the build and deploy. If you think this is confusing, here’s a little breakdown.

Breakdown

This pipeline uses the johnpaulada/graphcool image as its runtime image, which is just a Node image with the GraphCool CLI installed. This takes care of the step 1 above.

After loading the image, it will then start installing the dependencies with Yarn. This takes care of step 2. If the yarn.lock or package.json have not changed, Pipelines caches the node_modules folder, making the installation process faster.

After that, graphcool deploy is run, which starts the deployment process. It knows where to deploy it from the GRAPHCOOL_TARGET environment variable. If deploying to dev, we use the GRAPHCOOL_TARGET_STAGING instead. This takes care of step 3.

Environment Variables

We need the GRAPHCOOL_TARGET, GRAPHCOOL_PLATFORM_TARGET, and GRAPHCOOL_TARGET_STAGING environment variables. You can get the GRAPHCOOL_TARGET and GRAPHCOOL_TARGET_STAGING from your .graphcoolrc file. The GRAPHCOOL_PLATFORM_TARGET is in your ~/.graphcoolrc file.

💖 💪 🙅 🚩
johnpaulada
John Paul Ada

Posted on May 14, 2018

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related