conditional build for empty KEY

This commit is contained in:
SteveWW
2021-06-25 12:18:18 +01:00
parent 9d8c34027f
commit 0328084ad4
2 changed files with 17 additions and 8 deletions

View File

@@ -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

View File

@@ -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;"