The infrastructure agent support Docker version 1.12 or higher.
Be sure you already built the agent binaries, so these should be available at project root dist/
folder.
make build/base
builds the Docker image from this repo's Dockerfile.
The make target generates the Docker image in steps:
- Adds the
newrelic-infra
agent binary. - Generates and adds a
VERSION
file. - Adds all files in static assets.
- Sets image labels.
- Sets image environment variables required for the agent to run correctly inside a container.
See the comments in Makefile for the required env vars.
To build the Linux binary, see the README instructions. That will produce the newrelic-infra
binary in dist/
.
Once the binaries for your chose architecture are build you are ready to build the container image.
- Set the following environment variables:
PROJECT_ROOT
: Path to this cloned repo's rootIMAGE_VERSION
: Version to use for the Docker imageIMAGE_TAG
:newrelic/infrastructure
AGENT_VERSION
: Version of thenewrelic-infra
agent
- Run the make target:
make build/base
This should build the Docker image newrelic/infrastructure
and tag it with latest
.
- Set the following environment variables:
PROJECT_ROOT
: Path to this cloned repo's rootIMAGE_VERSION
: Version to use for the Docker imageIMAGE_TAG
:newrelic/infrastructure
AGENT_VERSION
: Version of thenewrelic-infra
agent
- Run the make target:
make build/base USE_BUILDX=true DOCKER_ARCH=<OS arch, eg. arm64>
This should build the Docker image for the target architecture newrelic/infrastructure
and tag it with latest
.
From the root of the project:
$ make dist-for-os GOOS=linux GOARCH=arm64
$ make -C build/container/ clean build/base USE_BUILDX=true DOCKER_ARCH=arm64
There is a shortcut make target for build ARM images:
make build/base-arm64
will build the base image as anarm64
imagemake build/base-arm
will build the base image as anarm
image
To publish all the supported images we can use the following make command (from the root of this project):
$ make -C build/container/ clean publish/multi-arch-base NS=test REPO=agent AGENT_VERSION=1.2.3
This will create all the docker images and tag them as follows, all as "release candidates":
arm
astest/agent:1.2.3-rc-arm
arm64
astest/agent:1.2.3-rc-arm64
amd64
astest/agent:1.2.3-rc-amd64
Setting NS
sets the Docker organisation to use (defaults to newrelic
) and REPO
sets the repo (defaults to infrastructure
).
The image version is set using AGENT_VERSION
and should match the one for the agent being added to the image.
This does not actually push the Docker images and manifest to Docker hub.
To do this you need to pass the argument DOCKER_PUBLISH=true
.
So if you're happy publishing to the default repo then the following will do that:
$ make -C build/container/ clean publish/multi-arch-base DOCKER_PUBLISH=true AGENT_VERSION=1.2.3
Once you are happy with the release candidate you can run the following make target to promote the release candidate:
$ make -C build/container/ publish/multi-arch-base-rc DOCKER_PUBLISH=true AGENT_VERSION=1.2.3
Again, if DOCKER_PUBLISH
not set to true
then nothing will be published to Docker hub.
Make sure the AGENT_VERSION
matches the one you used for the release candidate.