Heroku (one-off)
Deploy the agent in a heroku worker dyno.
- Login and create the runops-agent app
plain textheroku login heroku container:login heroku apps:create runops-agent
- Pull the agent version from the dockerhub and push to the heroku registry
plain textdocker pull runops/agent docker tag runops/agent registry.heroku.com/runops-agent/worker docker push registry.heroku.com/runops-agent/worker
- Sign in to runops and configure the agent
The token must be retrieved from the webapp or using the cli
plain textheroku 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
- Start the agent
plain textheroku container:release --app runops-agent worker heroku ps:scale --app runops-agent worker=1 heroku logs --app runops-agent
- Reference: https://devcenter.heroku.com/articles/container-registry-and-runtime
Create the Connection
Lastly we need to link the agent to Runops API.
plain textrunops 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:
plain textrunops tasks create -t heroku-railsapp01 -s 'puts Rails.env'
Next steps: