NewRelic deploy hooks for Docker
This will walk you through how to install NewRelic on your Docker stack using deploy hooks.
Create a new docker stack, provide the git information or the docker image and any databases your application might need and go the next step. Now your custom git repository is created, on the side bar on the right you should see:
Use custom git repository to add your deploy_hooks.yml : email@example.com:your_git_name_and_id.git
Since Docker stacks do not have a git repository we create one for you to use for your deploy hooks amongst another things.
The first thing to do is to clone this repository on your machine:
git clone firstname.lastname@example.org:your_git_name_and_id.git
Then create a new file in that folder called
deploy_hooks.ymland add the following:
production: first_thing: - snippet: cloud66/newrelic target: any sudo: true execute: true apply_during: all
apply_duringis set to
allthis will run on every deployment - set this value to
build_onlyto only run during stack build.
This deploy hook will run the following code snippet to automate the installation of NewRelic, and requires the
NEWRELIC_KEYenvironment variable to be set on a stack. This snippet is open source and can be found here.
Then add this file to the git repository with:
git add deploy_hooks.yml
Check that is has been added:
And then commit to the repository and push:
git commit -m 'Deploy hook - initial commit'
git push origin master
Back on Cloud 66 stack creation page click on Add environment variables button on the right and add a new one called
NEWRELIC_KEYwith your key from NewRelic.
When you now deploy your stack the snippet will be the first thing (after after_checkout) that will run on the server and will install everything that is needed.