-
Notifications
You must be signed in to change notification settings - Fork 2k
/
Copy pathDockerfileWithOpentracing
96 lines (82 loc) · 3.65 KB
/
DockerfileWithOpentracing
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
ARG NGINX_VERSION=1.17.4
ARG OPENTRACING_CPP_VERSION=1.5.1
FROM nginx:${NGINX_VERSION} AS opentracing-builder
ARG OPENTRACING_CPP_VERSION
RUN set -x \
&& apt-get update \
&& apt-get install --no-install-recommends --no-install-suggests -y \
libcurl4-openssl-dev \
build-essential \
cmake \
git \
ca-certificates \
pkg-config \
wget \
libz-dev \
automake \
autogen \
autoconf \
libtool \
libpcre3 \
libpcre3-dev \
&& tempDir="$(mktemp -d)" \
&& chmod 777 "$tempDir" \
&& git clone https://github.com/opentracing-contrib/nginx-opentracing src \
&& cd "$tempDir" \
&& git clone -b v$OPENTRACING_CPP_VERSION https://github.com/opentracing/opentracing-cpp.git \
&& cd opentracing-cpp \
&& mkdir .build && cd .build \
&& cmake -DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTING=OFF .. \
&& make && make install \
&& cd "$tempDir" \
&& NGINX_VERSION_BUILD=`nginx -v 2>&1` && NGINX_VERSION_BUILD=${NGINX_VERSION_BUILD#*nginx/} \
&& DEBIAN_VERSION="$(cat /etc/os-release | grep CODENAME | cut -f2 -d '=')" \
&& echo "deb-src http://nginx.org/packages/mainline/debian/ $DEBIAN_VERSION nginx" >> /etc/apt/sources.list \
&& apt-get update \
&& apt-get build-dep -y nginx=${NGINX_VERSION_BUILD} \
&& wget -O nginx-release-${NGINX_VERSION_BUILD}.tar.gz https://github.com/nginx/nginx/archive/release-${NGINX_VERSION_BUILD}.tar.gz \
&& tar zxf nginx-release-${NGINX_VERSION_BUILD}.tar.gz \
&& cd nginx-release-${NGINX_VERSION_BUILD} \
&& auto/configure \
--with-compat \
--add-dynamic-module=/src/opentracing \
--with-debug \
&& make modules \
&& cp objs/ngx_http_opentracing_module.so /ngx_http_opentracing_module.so
FROM debian:stretch-slim AS tracer-downloader
ARG JAEGER_VERSION=v0.4.2
RUN set -x \
&& apt-get update \
&& apt-get install --no-install-recommends --no-install-suggests -y ca-certificates apt-transport-https wget \
&& wget https://github.com/jaegertracing/jaeger-client-cpp/releases/download/${JAEGER_VERSION}/libjaegertracing_plugin.linux_amd64.so -O /usr/local/lib/libjaegertracing_plugin.so
# Final Image
FROM nginx:${NGINX_VERSION}
ARG OPENTRACING_CPP_VERSION
# forward nginx access and error logs to stdout and stderr of the ingress
# controller process
RUN ln -sf /proc/1/fd/1 /var/log/nginx/access.log \
&& ln -sf /proc/1/fd/1 /var/log/nginx/stream-access.log \
&& ln -sf /proc/1/fd/2 /var/log/nginx/error.log
COPY --from=opentracing-builder /ngx_http_opentracing_module.so /usr/lib/nginx/modules/ngx_http_opentracing_module.so
COPY --from=opentracing-builder /usr/local/lib/libopentracing.so.${OPENTRACING_CPP_VERSION} /usr/local/lib/libopentracing.so.1
# Edit the line below to use a different tracer
COPY --from=tracer-downloader /usr/local/lib/libjaegertracing_plugin.so /usr/local/lib/libjaegertracing_plugin.so
RUN ldconfig
RUN mkdir -p /var/lib/nginx \
&& mkdir -p /etc/nginx/secrets \
&& apt-get update \
&& apt-get install -y libcap2-bin \
&& setcap 'cap_net_bind_service=+ep' /usr/sbin/nginx \
&& chown -R nginx:0 /etc/nginx \
&& chown -R nginx:0 /var/cache/nginx \
&& chown -R nginx:0 /var/lib/nginx \
&& apt-get remove --purge -y libcap2-bin \
&& rm /etc/nginx/conf.d/* \
&& rm -rf /var/lib/apt/lists/*
COPY nginx-ingress internal/configs/version1/nginx.ingress.tmpl internal/configs/version1/nginx.tmpl internal/configs/version2/nginx.virtualserver.tmpl /
# Uncomment the line below if you would like to add the default.pem to the image
# and use it as a certificate and key for the default server
# ADD default.pem /etc/nginx/secrets/default
USER nginx
ENTRYPOINT ["/nginx-ingress"]