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:
- Install the GraphCool CLI.
- Install dependencies.
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.
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
package.json have not changed, Pipelines caches the
node_modules folder, making the installation process faster.
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.
We need the
GRAPHCOOL_TARGET_STAGING environment variables. You can get the
GRAPHCOOL_TARGET_STAGING from your
.graphcoolrc file. The
GRAPHCOOL_PLATFORM_TARGET is in your