Skip to content

Instantly share code, notes, and snippets.

@Tailzip
Last active July 13, 2022 10:38
Show Gist options
  • Save Tailzip/28cb9e4200d0ec06a4109ec70b64bd35 to your computer and use it in GitHub Desktop.
Save Tailzip/28cb9e4200d0ec06a4109ec70b64bd35 to your computer and use it in GitHub Desktop.
Custom Datadog Synthetics Private Location Worker Docker image

Custom Datadog Synthetics Private Location Worker Docker image

https://docs.datadoghq.com/synthetics/private_locations/?tab=docker

Why a custom image?

The datadog/synthetics-private-location-worker Docker image doesn't allow to set check runner's JSON config using environment variables, but only by mounting a JSON config file as a Docker volume.

This custom image uses an entrypoint script that allows you to set the check runner's JSON config by passing it as an environment variable (SYNTHETICS_CHECK_RUNNER_CONFIG_JSON).

Private location worker usage/config options remain unchanged.

$ docker build -t custom-synthetics-image .
$ docker run --rm -it -e SYNTHETICS_CHECK_RUNNER_CONFIG_JSON="__JSON_CONFIG__" custom-synthetics-image --help
FROM datadog/synthetics-private-location-worker:1.0.1
COPY entrypoint.sh /home/dog/custom-entrypoint.sh
ENTRYPOINT ["/home/dog/custom-entrypoint.sh"]
#!/bin/bash
set -o errexit
set -o nounset
SYNTHETICS_CHECK_RUNNER_CONFIG_JSON=${SYNTHETICS_CHECK_RUNNER_CONFIG_JSON:-}
if [ -z "$SYNTHETICS_CHECK_RUNNER_CONFIG_JSON" ]; then
>&2 echo "SYNTHETICS_CHECK_RUNNER_CONFIG_JSON environment variable is not set!"
exit 1
fi
# default synthetics-check-runner config path
echo -n "$SYNTHETICS_CHECK_RUNNER_CONFIG_JSON" > /etc/datadog/synthetics-check-runner.json
# default synthetics-check-runner entrypoint
/home/dog/entrypoint.sh "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment