Skip to content

Commit

Permalink
conditional build for empty KEY
Browse files Browse the repository at this point in the history
  • Loading branch information
steveww committed Jun 25, 2021
1 parent 9d8c340 commit 0328084
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
7 changes: 5 additions & 2 deletions web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 12 additions & 6 deletions web/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;"

0 comments on commit 0328084

Please sign in to comment.