Heroku CI

Integrate Onboardbase CLI into your Heroku builds

📘

This section assumes you already used Onboardbase CLI in your project, check the installation and setup sections.

📘

TIP

You can authenticate the CLI with Environment variables.
Supported environment variables are:

  • ONBOARDBASE_TOKEN - A service token
  • ONBOARDBASE_PROJECT - an onboardbase project name
  • ONBOARDBASE_ENVIRONMENT - an environment in the specified project

It is easier to create an Onboardbase configuration file during development through the onboardbase setup command, which is not the case most time for automated CI/CD processes.

In this guide, we will illustrate how to pull all your managed Onboardbase secrets into your CI/CD pipelines that automatically authorize and set up with values from Heroku CI Environment Configurations.

This section assumes you already used Onboardbase CLI in your project. Check the installation and setup sections.

Generate Service Token

From an admin account, click on the Manage Organization, and generate two service tokens, one for staging and the other for production.

Go to your CircleCI project setting, and add new secrets STAGING_ONBOARDBASE_TOKEN and PRODUCTION_ONBOARDBASE_TOKEN with the new service tokens, respectively.

Generate Setup File

Login to your Onboardbase account, select the project to set up for, click on the environment to switch to the right environment, then from the dropdown towards the right, once you open it, you'll see a generated setup you can copy.

Generate the setup for both your production and staging secrets.

Setting up Heroku

Now that you have all the required credentials, create new environment variables with the name:

  • STAGING_ONBOARDBASE_SETUP : Should include the Onboardbase setup file.
  • ONBOARDBASE_TOKEN : This should contain the token that was generated and copied earlier.

Docker Deployment file

Use a Dockerfile to build the image that will install Onboardbase CLI into the dyno.

Below is a docker file that inherits from NodeJS Alpine image, installs, and setup Onboardbase CLI.

FROM node:14-alpine

RUN apk add --no-cache --update curl bash
WORKDIR /app

ENV PORT=$PORT
ENV NODE_ENV=development

# Pick $STAGING_ONBOARDBASE_SETUP and $ONBOARDBASE_TOKEN from the config variables
ENV ONBOARDBASE_SETUP=$STAGING_ONBOARDBASE_SETUP
ENV ONBOARDBASE_TOKEN=$ONBOARDBASE_TOKEN

# Install Onboardbase
RUN curl -Ss https://files.onboardbase.com/install.sh | bash - && source ~/.bashrc \
    onboardbase --version

# Use ENV to setup the CLI
RUN onboardbase config:set-token $ONBOARDBASE_TOKEN

# Copy Setup from env
RUN echo $ONBOARDBASE_SETUP > ./.onboardbase.yml

COPY package* ./
# Install the npm packages
RUN npm install && npm update

COPY . .

# Run the image as a non-root user
RUN adduser -D myuser
USER myuser

EXPOSE $PORT
# Run the managed start command
CMD ["npm", "run", "start"]

heroku.yml

To finalize the deployment process, create a heroku.yml file at the root of the project.

Notice the build section; we are using docker image config and specifying the name of our dockerfile we created above.

Also, the run section instructs the web to start the Dyno with npm start

setup:
  addons:
    - plan: heroku-redis
      as: REDIS
  config:
    APP_NAME: heroku-dockerize
build:
  docker:
    web: Dockerfile
  config:
    NODE_ENV: production
run:
  web: npm start