Skip to main content

Heroku (one-off)

Deploy the agent in a heroku worker dyno.

  1. Login and create the runops-agent app
heroku login
heroku container:login
heroku apps:create runops-agent
  1. Pull the agent version from the dockerhub and push to the heroku registry
docker pull runops/agent
docker tag runops/agent registry.heroku.com/runops-agent/worker
docker push registry.heroku.com/runops-agent/worker
  1. Sign in to runops and configure the agent

The token must be retrieved from the webapp or using the cli

heroku config:set TOKEN=<RUNOPS_AGENT_TOKEN>
heroku config:set GOSU_DISABLE=true
# for each app, set a configuration in the agent
heroku config:set HEROKU_APP_01='{"HEROKU_API_KEY": "api-key", "HEROKU_APP": "myapp01", "HEROKU_EXEC_COMMAND": "rails runner -"}'
heroku config:set HEROKU_APP_02='{"HEROKU_API_KEY": "api-key", "HEROKU_APP": "myapp02", "HEROKU_EXEC_COMMAND": "rails runner -"}'
# optional
heroku config:set TAGS=test

  1. Start the agent
heroku container:release --app runops-agent worker
heroku ps:scale --app runops-agent worker=1
heroku logs --app runops-agent

Create the Connection

Lastly we need to link the agent to Runops API.

runops targets create \
--name heroku-railsapp01 \
--type heroku \
--secret_provider env-var \
--secret_path HEROKU_APP_01

If you set a tag in your agent, make sure to create the a connection with the same value, e.g.: runops targets create ... --tags <my-tag>

Congrats! Now the Tasks of this Connection will use the new agent! We can run a ruby scripts, try it out:

runops tasks create -t heroku-railsapp01 -s 'puts Rails.env'

Next steps: