Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
cff3f19
For the tracing example, add options to the run script to set the Ngi…
xlamorlette-datadog Apr 14, 2026
6578fc1
Code clean: fix casing for local variables in shell script
xlamorlette-datadog Apr 14, 2026
ec48077
For the OpenResty example, add a script to download the Datadog modul…
xlamorlette-datadog Apr 14, 2026
1d90941
Remove warning when variables are not set
xlamorlette-datadog Apr 14, 2026
4bca0bc
For Ingress Nginx example, use Colima instead of Docker Desktop
xlamorlette-datadog Apr 14, 2026
0425bd5
Shell check fixes
xlamorlette-datadog Apr 14, 2026
546cd59
Merge branch 'master' into xlamorlette/IDMPL-350-Nginx-Simplify-smoke…
xlamorlette-datadog Apr 15, 2026
0d407cf
Update example/ingress-nginx/README.md
xlamorlette-datadog Apr 15, 2026
55c7070
Update example/tracing/services/nginx/install_datadog.sh
xlamorlette-datadog Apr 15, 2026
7675365
Update example/tracing/services/nginx/install_datadog.sh
xlamorlette-datadog Apr 15, 2026
9547abf
Update example/openresty/services/openresty/install_datadog.sh
xlamorlette-datadog Apr 15, 2026
ddb51fe
Update example/openresty/services/openresty/install_datadog.sh
xlamorlette-datadog Apr 15, 2026
4f776b2
Update example/openresty/services/openresty/install_datadog.sh
xlamorlette-datadog Apr 15, 2026
c49f428
Factorise utility functions across install_datadog.sh scripts for tra…
xlamorlette-datadog Apr 15, 2026
9a71755
Factorize more things across install_datadog.sh scripts
xlamorlette-datadog Apr 15, 2026
c92d146
clean code: get arch by return value form detect_arch
xlamorlette-datadog Apr 15, 2026
9e7fad8
Merge branch 'master' into xlamorlette/IDMPL-350-Nginx-Simplify-smoke…
pawelchcki Apr 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions example/ingress-nginx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ Add the `ingress-nginx` repository in your local Helm configuration:
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
```

In Docker Desktop, go the 'Kubernetes' tab, and create a cluster. Then use it:
Get a local Kubernetes cluster, then use it. For example, with Colima:

```shell
kubectl config use-context docker-desktop
colima start --cpu 4 --memory 16 --vm-type=vz --vz-rosetta --kubernetes
kubectl config use-context colima
```

Install `ingress-nginx` (with the Datadog module):
Expand Down
49 changes: 49 additions & 0 deletions example/install_datadog_utils.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/sh
# Shared utility functions for install_datadog.sh scripts.

detect_arch() {
raw_arch="$(uname -m)"
case "$raw_arch" in
aarch64)
echo "arm64"
;;
x86_64)
echo "amd64"
;;
*)
>&2 echo "Platform ${raw_arch} is not supported."
exit 1
;;
esac
}

get_latest_release() {
tag=$(curl --silent --fail "https://api.github.com/repos/$1/releases/latest" | jq --raw-output .tag_name)
if [ -z "$tag" ] || [ "$tag" = "null" ]; then
>&2 echo "Failed to fetch latest release tag for $1. Check network and GitHub API rate limits."
exit 1
fi
echo "$tag"
}

install_packages() {
# Install the requested list of packages.
# `apt-get` (Debian, Ubuntu), `apk` (Alpine), and `yum` (Amazon Linux) are supported.
if is_installed apt-get; then
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y "$@"
elif is_installed apk; then
apk update
apk add "$@"
elif is_installed yum; then
yum update -y
yum install -y "$@"
else
>&2 printf 'Did not find a supported package manager.\n'
exit 3
fi
}

is_installed() {
command -v "$1" > /dev/null 2>&1
}
8 changes: 1 addition & 7 deletions example/openresty/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,13 @@ export DD_API_KEY=your_api_key_here
bin/run
```

You can also choose which OpenResty version to run with the RESTY_VERSION environment variable:

```shell
RESTY_VERSION=1.27.1.2 bin/run
```

Then, in another shell, make HTTP or gRPC calls to the `openresty` service using
the included command line tools:

```shell
bin/curl http://openresty/openresty

openresty lua
openresty lua generated content
```

See [services/openresty/nginx.conf](services/openresty/nginx.conf) for the available routes.
Expand Down
61 changes: 45 additions & 16 deletions example/openresty/bin/run
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,57 @@ set -e

cd "$(dirname "$0")"/..

if [ -z "$RESTY_VERSION" ]; then
export RESTY_VERSION=1.29.2.1
fi
DEFAULT_OPENRESTY_VERSION=1.29.2.1

if [ -z "$BASE_IMAGE" ]; then
BASE_IMAGE="openresty/openresty:${RESTY_VERSION}-alpine"
export BASE_IMAGE
fi
usage() {
echo "Usage: $0 [--openresty OpenResty_version] [--nginx-datadog Nginx_Datadog_version] [--no-cache]"
echo " -h, --help"
echo " show this help message"
echo " --openresty OpenResty_version"
echo " OpenResty version (default: $DEFAULT_OPENRESTY_VERSION)"
echo " --nginx-datadog Nginx_Datadog_version"
echo " Nginx Datadog release tag (example: 1.0.0, default: latest one)"
echo " --no-cache"
echo " disable cache when building Docker images"
}

# Fail fast in case the base image is not supported.
# For now, we only support nginx, nginx-alpine, and amazonlinux images.
case "$BASE_IMAGE" in
openresty/openresty:*) ;;
*)
>&2 echo 'BASE_IMAGE value "%s" is invalid.' "$BASE_IMAGE"
exit 1
;;
esac
while [ $# -gt 0 ]; do
case "$1" in
-h|--help)
usage
exit 0
;;
--openresty)
[ $# -ge 2 ] || { usage >&2; exit 1; }
OPENRESTY_VERSION="$2"
shift 2
;;
--nginx-datadog)
[ $# -ge 2 ] || { usage >&2; exit 1; }
NGINX_DATADOG_VERSION="$2"
shift 2
;;
--no-cache)
NO_CACHE=true
shift
;;
*)
usage >&2
exit 1
;;
esac
done

OPENRESTY_VERSION=${OPENRESTY_VERSION:-${DEFAULT_OPENRESTY_VERSION}}
export OPENRESTY_VERSION
export NGINX_DATADOG_VERSION

if [ "$DD_API_KEY" = '' ]; then
>&2 echo 'The environment variable DD_API_KEY must be set to a Datadog API key.'
exit 1
fi

if [ -n "$NO_CACHE" ]; then
docker compose build --no-cache
fi
docker compose up --build --abort-on-container-exit --remove-orphans
7 changes: 4 additions & 3 deletions example/openresty/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ services:
# `openresty` is an instance of openresty that has the Datadog tracing module loaded.
openresty:
build:
context: ./services/openresty
dockerfile: ./Dockerfile
context: ..
dockerfile: openresty/services/openresty/Dockerfile
args:
BASE_IMAGE: ${BASE_IMAGE}
OPENRESTY_VERSION: ${OPENRESTY_VERSION:-}
NGINX_DATADOG_VERSION: ${NGINX_DATADOG_VERSION:-}
environment:
- DD_AGENT_HOST=agent
depends_on:
Expand Down
19 changes: 15 additions & 4 deletions example/openresty/services/openresty/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
# Build an nginx container that includes the module for Datadog tracing.
ARG BASE_IMAGE
# Build an Nginx container that includes the module for Datadog tracing.
# The default value for BASE_IMAGE is to silent the InvalidDefaultArgInFrom
# warning. Actually BASE_IMAGE is set in docker-compose.yml.
ARG OPENRESTY_VERSION=1.29.2.1
ARG BASE_IMAGE=openresty/openresty:${OPENRESTY_VERSION}-alpine
FROM ${BASE_IMAGE}

COPY ngx_http_datadog_module.so* /usr/local/openresty/nginx/modules
COPY ./nginx.conf /usr/local/openresty/nginx/conf/nginx.conf
# Install the Datadog tracing module.
ARG OPENRESTY_VERSION
ENV OPENRESTY_VERSION=${OPENRESTY_VERSION}
ARG NGINX_DATADOG_VERSION
ENV NGINX_DATADOG_VERSION=${NGINX_DATADOG_VERSION}
COPY ./install_datadog_utils.sh /tmp/
COPY ./openresty/services/openresty/install_datadog.sh /tmp/
RUN /tmp/install_datadog.sh

COPY ./openresty/services/openresty/nginx.conf /usr/local/openresty/nginx/conf/nginx.conf

ENTRYPOINT ["nginx"]
CMD ["-g", "daemon off;"]
30 changes: 30 additions & 0 deletions example/openresty/services/openresty/install_datadog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh
# Install the Nginx Datadog module.

set -x
set -e

. /tmp/install_datadog_utils.sh

arch=$(detect_arch)

install_packages curl jq tar wget

if [ -z "$OPENRESTY_VERSION" ]; then
>&2 echo 'OPENRESTY_VERSION must be set (e.g. "1.29.2.1").'
exit 1
fi

tarball="openresty-ngx_http_datadog_module-appsec-${arch}-${OPENRESTY_VERSION}.so.tgz"
Comment thread
xlamorlette-datadog marked this conversation as resolved.

repository="DataDog/nginx-datadog"

if [ -n "$NGINX_DATADOG_VERSION" ]; then
nginx_datadog_release_tag="v${NGINX_DATADOG_VERSION}"
else
nginx_datadog_release_tag=$(get_latest_release "$repository")
fi

wget "https://github.com/$repository/releases/download/$nginx_datadog_release_tag/$tarball"
tar -xzf "$tarball" -C /usr/local/openresty/nginx/modules
rm "$tarball"
49 changes: 48 additions & 1 deletion example/tracing/bin/run
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,52 @@ set -e

cd "$(dirname "$0")"/..

BASE_IMAGE="${BASE_IMAGE:-nginx:1.29.7-alpine}"
DEFAULT_NGINX_VERSION=1.29.7

usage() {
echo "Usage: $0 [--nginx Nginx_version] [--nginx-datadog Nginx_Datadog_version] [--no-cache]"
echo " -h, --help"
echo " show this help message"
echo " --nginx Nginx_version"
echo " Nginx version (default: $DEFAULT_NGINX_VERSION)"
echo " --nginx-datadog Nginx_Datadog_version"
echo " Nginx Datadog release tag (example: 1.0.0, default: latest one)"
echo " --no-cache"
echo " disable cache when building Docker images"
}

while [ $# -gt 0 ]; do
case "$1" in
-h|--help)
usage
exit 0
;;
--nginx)
[ $# -ge 2 ] || { usage >&2; exit 1; }
NGINX_VERSION="$2"
shift 2
;;
--nginx-datadog)
[ $# -ge 2 ] || { usage >&2; exit 1; }
NGINX_DATADOG_VERSION="$2"
shift 2
;;
--no-cache)
NO_CACHE=true
shift
;;
*)
usage >&2
exit 1
;;
esac
done

NGINX_VERSION=${NGINX_VERSION:-${DEFAULT_NGINX_VERSION}}
export NGINX_VERSION
BASE_IMAGE=${BASE_IMAGE:-nginx:${NGINX_VERSION}-alpine}
export BASE_IMAGE
export NGINX_DATADOG_VERSION

# Fail fast in case the base image is not supported.
# For now, we only support nginx, nginx-alpine, and amazonlinux images.
Expand All @@ -22,4 +66,7 @@ if [ "$DD_API_KEY" = '' ]; then
exit 1
fi

if [ -n "$NO_CACHE" ]; then
docker compose build --no-cache
fi
docker compose up --build --abort-on-container-exit --remove-orphans
7 changes: 4 additions & 3 deletions example/tracing/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ services:
# `nginx` is an instance of nginx that has the Datadog tracing module loaded.
nginx:
build:
context: ./services/nginx
dockerfile: ./Dockerfile
context: ..
dockerfile: tracing/services/nginx/Dockerfile
args:
BASE_IMAGE: ${BASE_IMAGE}
BASE_IMAGE: ${BASE_IMAGE:-}
NGINX_DATADOG_VERSION: ${NGINX_DATADOG_VERSION:-}
environment:
- DD_AGENT_HOST=agent
depends_on:
Expand Down
9 changes: 6 additions & 3 deletions example/tracing/services/nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# Build an nginx container that includes the module for Datadog tracing.
# Build an Nginx container that includes the module for Datadog tracing.
# The default value for BASE_IMAGE is to silent the InvalidDefaultArgInFrom
# warning. Actually BASE_IMAGE is set in docker-compose.yml.
ARG BASE_IMAGE=nginx:1.29.7-alpine
FROM ${BASE_IMAGE}

# Install the Datadog tracing module.
COPY ./install_datadog.sh /tmp/
COPY ./install_datadog_utils.sh /tmp/
COPY ./tracing/services/nginx/install_datadog.sh /tmp/
ARG BASE_IMAGE
ENV BASE_IMAGE=${BASE_IMAGE}
ARG NGINX_DATADOG_VERSION
ENV NGINX_DATADOG_VERSION=${NGINX_DATADOG_VERSION}
RUN /tmp/install_datadog.sh

COPY ./nginx.conf /etc/nginx/nginx.conf
COPY ./tracing/services/nginx/nginx.conf /etc/nginx/nginx.conf

ENTRYPOINT ["nginx"]
CMD ["-g", "daemon off;"]
Loading
Loading