Skip to content

CircleCI

Nullstone offers automatic builds and deploys; however, some teams prefer to build and deploy through their own CI/CD. This guide shows how to configure CircleCI to push and deploy new versions of your code.

TIP

Nullstone provides an orb to automate Nullstone commands. Check out the Nullstone CircleCI orb documentation for detailed reference.

Configure Nullstone context

  1. Create a Nullstone API Key. Visit your Nullstone Profile and add a new API Key. Name it CircleCI.

  2. Create a CircleCI Context. Visit CircleCI and add a context named nullstone. In that context, add two environment variables:

  • NULLSTONE_ORG=<your nullstone organization name>
  • NULLSTONE_API_KEY=<api key created above>

Add orb to configuration

Add another orb to your CircleCI configuration file.

yaml
# .circleci/config.yml
orbs:
  nullstone: nullstone/nullstone@1
...
# .circleci/config.yml
orbs:
  nullstone: nullstone/nullstone@1
...

Deploy app using Nullstone CLI

With our orb defined in the CircleCI config.yml, add a deploy that pushes and deploys your docker image. The following snippet does the following:

  • Configures the CLI with an API key and organization using the nullstone context on the workflow.
  • Configures the deploy job to use the dev Nullstone environment in the dev workflow.
  • Uses the NULLSTONE_APP environment variable to set the name of the deployed application.

TIP

Make sure to replace <app> and dev with the appropriate app name and environment name in Nullstone.

yaml
# .circleci/config.yml
...

workflows:
  dev:
    jobs:
      - build
      - deploy:
          env: dev
          context:
            - nullstone

jobs:
  build:
    # .. Build docker image here
  deploy:
    environment:
      NULLSTONE_APP: <app>
    parameters:
      env:
        description: "Deployment target env"
        type: string
    steps:
      - checkout
      - nullstone/install
      - nullstone/push:
          source: <docker image built above>
          env: << parameters.env >>
      - nullstone/deploy:
          env: << parameters.env >>
# .circleci/config.yml
...

workflows:
  dev:
    jobs:
      - build
      - deploy:
          env: dev
          context:
            - nullstone

jobs:
  build:
    # .. Build docker image here
  deploy:
    environment:
      NULLSTONE_APP: <app>
    parameters:
      env:
        description: "Deployment target env"
        type: string
    steps:
      - checkout
      - nullstone/install
      - nullstone/push:
          source: <docker image built above>
          env: << parameters.env >>
      - nullstone/deploy:
          env: << parameters.env >>