From 0328084ad4ed45fb41a3a04207921d36a47f1a6f Mon Sep 17 00:00:00 2001 From: SteveWW Date: Fri, 25 Jun 2021 12:18:18 +0100 Subject: [PATCH] conditional build for empty KEY --- web/Dockerfile | 7 +++++-- web/entrypoint.sh | 18 ++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/web/Dockerfile b/web/Dockerfile index 57c57ea..ee1b067 100644 --- a/web/Dockerfile +++ b/web/Dockerfile @@ -5,13 +5,16 @@ WORKDIR /instana RUN apk add --update --no-cache curl -RUN curl \ +RUN if [ -n "$KEY" ]; then curl \ --output instana.zip \ --user "_:$KEY" \ https://artifact-public.instana.io/artifactory/shared/com/instana/nginx_tracing/1.1.2/linux-amd64-glibc-nginx-1.20.1.zip && \ unzip instana.zip && \ mv glibc-libinstana_sensor.so libinstana_sensor.so && \ - mv glibc-nginx-1.20.1-ngx_http_ot_module.so ngx_http_opentracing_module.so + mv glibc-nginx-1.20.1-ngx_http_ot_module.so ngx_http_opentracing_module.so; \ + else echo "KEY not provided. Not adding tracing"; \ + touch dummy.so; \ + fi FROM nginx:1.20.1 diff --git a/web/entrypoint.sh b/web/entrypoint.sh index 89304c7..98d8a42 100755 --- a/web/entrypoint.sh +++ b/web/entrypoint.sh @@ -29,10 +29,12 @@ chmod 644 $BASE_DIR/eum.html # apply environment variables to default.conf envsubst '${CATALOGUE_HOST} ${USER_HOST} ${CART_HOST} ${SHIPPING_HOST} ${PAYMENT_HOST} ${RATINGS_HOST}' < /etc/nginx/conf.d/default.conf.template > /etc/nginx/conf.d/default.conf -# Patching for Instana tracing -mv /tmp/ngx_http_opentracing_module.so /usr/lib/nginx/modules -mv /tmp/libinstana_sensor.so /usr/local/lib -cat - /etc/nginx/nginx.conf << !EOF! > /tmp/nginx.conf +if [ -f /tmp/ngx_http_opnetracing_module.so -a -f /tmp/libinstana_sensor.so ] +then + # Patching for Instana tracing + mv /tmp/ngx_http_opentracing_module.so /usr/lib/nginx/modules + mv /tmp/libinstana_sensor.so /usr/local/lib + cat - /etc/nginx/nginx.conf << !EOF! > /tmp/nginx.conf # Extra configuration for Instana tracing load_module modules/ngx_http_opentracing_module.so; @@ -44,8 +46,12 @@ env INSTANA_MAX_BUFFERED_SPANS; env INSTANA_DEV; !EOF! -mv /tmp/nginx.conf /etc/nginx/nginx.conf -echo "{}" > /etc/instana-config.json + mv /tmp/nginx.conf /etc/nginx/nginx.conf + echo "{}" > /etc/instana-config.json +else + # remove tracing config + sed -i '1,3d' /etc/nginx/conf.d/default.conf +fi exec nginx-debug -g "daemon off;"