{
  "$type": "site.standard.document",
  "canonicalUrl": "https://numergent.com/2016-10/Deploying-a-Clojure-application-from-Gitlab-CI-to-Heroku.html",
  "path": "/2016-10/Deploying-a-Clojure-application-from-Gitlab-CI-to-Heroku.html",
  "publishedAt": "2016-10-17T06:18:39.000Z",
  "site": "at://did:plc:cf6futaebyc2k4wgzsr4v42k/site.standard.publication/3mp2ewx43js2g",
  "tags": [
    "clojure",
    "git",
    "heroku",
    "continuous integration"
  ],
  "textContent": "Now that we have our Clojure application tested every time we push it to Gitlab, let's configure another stage to deploy it to Heroku.\n\nThis assumes that:\n\n Anything you merge to master is ready to deploy, \n You have your Heroku API key handy, and\n You already have a Heroku app configured, with all the necessary environment variables.\n\nThere's two ways we can do this.\n\n\n\nConfiguring your secret variables\n\nYou'll need your Heroku API key to deploy from Gitlab. \n\nWhen talking about Gitlab CI, I mentioned that it supported secret environment variables.  We don't want our API key to be on our .gitlab-ci.yml file, so before going any further, make sure you go to Settings > Variables and add it. \n\nThe configuration below assumes you'll call it HEROKU_PRODUCTION_API_KEY. \n\nThe lein way\n\nHeroku provides a leiningen plugin which allows for easy deployment. To use it, you'll need to add the reference to your plugin vector and add a :heroku section to your project.clj:\n\nYou'll then need to add a new production section to your CI configuration.  You'll find mine below, where I:\n\n Configure it to allow snapshots in release (since otherwise lein uberjar refuses to build if there's a reference to a snapshot anywhere),\n Build the uberjar, and\n Use the lein-heroku plugin to deploy it.\n  \n\nYou'll see there's  an artifacts section.  This tells Gitlab CI to save a copy of the generated uberjar artifact, in case I need to review it. You can find these on the Pipelines for your project.\n\nThe only drawback to using lein-heroku is that it's one year old and has some outdated dependencies. It's possible some of these will clash with your project's, or that by the time you read this, it'll be entirely unsupported.\n\nIf so, you can try the second option below.\n\nThe gem path\n\nIf the plugin above breaks for you, there's an alternate path. You can use dpl, which is written in Ruby and supports not only Heroku but also other providers.\n\nSince we're working off a Docker image for Clojure, we don't have Ruby or Gem installed. We'll need to install them.\n\nIn this case, we don't build a uberjar, and just use dpl to send our repository directly to Heroku for building.\n\nThat's it!",
  "title": "Deploying a Clojure application from Gitlab CI to Heroku"
}