-
Notifications
You must be signed in to change notification settings - Fork 57
/
Dockerfile
373 lines (341 loc) · 17.2 KB
/
Dockerfile
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
# apigateway
#
# VERSION 1.9.7.3
#
# From https://hub.docker.com/_/alpine/
# alpine:3.4 if go <1.7
FROM alpine:3.4
# install dependencies
RUN apk update \
&& apk add gcc tar libtool zlib jemalloc jemalloc-dev perl \
make musl-dev openssl-dev pcre-dev g++ zlib-dev curl python \
perl-test-longstring perl-list-moreutils perl-http-message \
geoip-dev sudo
ENV ZMQ_VERSION 4.0.5
ENV CZMQ_VERSION 2.2.0
# Installing throttling dependencies
RUN echo " ... adding throttling support with ZMQ and CZMQ" \
&& apk add autoconf automake \
&& curl -L https://github.com/zeromq/zeromq4-x/archive/v${ZMQ_VERSION}.tar.gz -o /tmp/zeromq.tar.gz \
&& cd /tmp/ \
&& tar -xf /tmp/zeromq.tar.gz \
&& cd /tmp/zeromq*/ \
&& ./autogen.sh \
&& ./configure --prefix=/usr \
--sysconfdir=/etc \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
&& make && make install \
&& curl -L https://github.com/zeromq/czmq/archive/v${CZMQ_VERSION}.tar.gz -o /tmp/czmq.tar.gz \
&& cd /tmp/ \
&& tar -xf /tmp/czmq.tar.gz \
&& cd /tmp/czmq*/ \
&& ./autogen.sh \
&& ./configure --prefix=/usr \
--sysconfdir=/etc \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
&& make && make install \
&& apk del automake autoconf \
&& rm -rf /tmp/zeromq* && rm -rf /tmp/czmq* \
&& rm -rf /var/cache/apk/*
# openresty build
ENV OPENRESTY_VERSION=1.13.6.1 \
PCRE_VERSION=8.37 \
TEST_NGINX_VERSION=0.24 \
_prefix=/usr/local \
_exec_prefix=/usr/local \
_localstatedir=/var \
_sysconfdir=/etc \
_sbindir=/usr/local/sbin
RUN echo " ... adding Openresty, NGINX, and PCRE" \
&& mkdir -p /tmp/api-gateway \
&& readonly NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) \
&& echo "using up to $NPROC threads" \
&& cd /tmp/api-gateway/ \
&& curl -L https://s3.amazonaws.com/adobe-cloudops-apip-installers-ue1/3rd-party/pcre-${PCRE_VERSION}.tar.gz -o /tmp/api-gateway/pcre-${PCRE_VERSION}.tar.gz \
&& curl -L https://s3.amazonaws.com/adobe-cloudops-apip-installers-ue1/3rd-party/openresty-${OPENRESTY_VERSION}.tar.gz -o /tmp/api-gateway/openresty-${OPENRESTY_VERSION}.tar.gz \
&& tar -zxf ./openresty-${OPENRESTY_VERSION}.tar.gz \
&& tar -zxf ./pcre-${PCRE_VERSION}.tar.gz \
&& cd /tmp/api-gateway/openresty-${OPENRESTY_VERSION} \
&& echo " - building debugging version of the api-gateway ... " \
&& ./configure \
--prefix=${_exec_prefix}/api-gateway \
--sbin-path=${_sbindir}/api-gateway-debug \
--conf-path=${_sysconfdir}/api-gateway/api-gateway.conf \
--error-log-path=${_localstatedir}/log/api-gateway/error.log \
--http-log-path=${_localstatedir}/log/api-gateway/access.log \
--pid-path=${_localstatedir}/run/api-gateway.pid \
--lock-path=${_localstatedir}/run/api-gateway.lock \
--with-pcre=../pcre-${PCRE_VERSION}/ --with-pcre-jit \
--with-stream \
--with-stream_ssl_module \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_geoip_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_auth_request_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_degradation_module \
--with-http_auth_request_module \
--with-http_v2_module \
--with-luajit \
--without-http_ssi_module \
--without-http_userid_module \
--without-http_uwsgi_module \
--without-http_scgi_module \
--with-debug \
-j${NPROC} \
&& make -j${NPROC} \
&& make install \
&& echo " - building regular version of the api-gateway ... " \
&& ./configure \
--prefix=${_exec_prefix}/api-gateway \
--sbin-path=${_sbindir}/api-gateway \
--conf-path=${_sysconfdir}/api-gateway/api-gateway.conf \
--error-log-path=${_localstatedir}/log/api-gateway/error.log \
--http-log-path=${_localstatedir}/log/api-gateway/access.log \
--pid-path=${_localstatedir}/run/api-gateway.pid \
--lock-path=${_localstatedir}/run/api-gateway.lock \
--with-pcre=../pcre-${PCRE_VERSION}/ --with-pcre-jit \
--with-stream \
--with-stream_ssl_module \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_geoip_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_auth_request_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_degradation_module \
--with-http_v2_module \
--with-luajit \
--without-http_ssi_module \
--without-http_userid_module \
--without-http_uwsgi_module \
--without-http_scgi_module \
-j${NPROC} \
&& make -j${NPROC} \
&& make install \
&& echo " - adding Nginx Test support" \
&& curl -L https://github.com/openresty/test-nginx/archive/v${TEST_NGINX_VERSION}.tar.gz -o ${_prefix}/test-nginx-${TEST_NGINX_VERSION}.tar.gz \
&& cd ${_prefix} \
&& tar -xf ${_prefix}/test-nginx-${TEST_NGINX_VERSION}.tar.gz \
&& rm ${_prefix}/test-nginx-${TEST_NGINX_VERSION}.tar.gz \
&& cp -r ${_prefix}/test-nginx-0.24/inc/* /usr/local/share/perl5/site_perl/ \
&& ln -s ${_sbindir}/api-gateway-debug ${_sbindir}/nginx \
&& cp /tmp/api-gateway/openresty-${OPENRESTY_VERSION}/build/install ${_prefix}/api-gateway/bin/resty-install \
&& apk del g++ gcc make \
&& rm -rf /var/cache/apk/* \
&& rm -rf /tmp/api-gateway
ENV LUA_RESTY_HTTP_VERSION 0.07
RUN echo " ... installing lua-resty-http..." \
&& apk update \
&& apk add make \
&& mkdir -p /tmp/api-gateway \
&& curl -L https://github.com/pintsized/lua-resty-http/archive/v${LUA_RESTY_HTTP_VERSION}.tar.gz -o /tmp/api-gateway/lua-resty-http-${LUA_RESTY_HTTP_VERSION}.tar.gz \
&& tar -xf /tmp/api-gateway/lua-resty-http-${LUA_RESTY_HTTP_VERSION}.tar.gz -C /tmp/api-gateway/ \
&& cd /tmp/api-gateway/lua-resty-http-${LUA_RESTY_HTTP_VERSION} \
&& make install \
LUA_LIB_DIR=${_prefix}/api-gateway/lualib \
INSTALL=${_prefix}/api-gateway/bin/resty-install \
&& rm -rf /tmp/api-gateway
ENV LUA_RESTY_IPUTILS_VERSION 0.2.0
RUN echo " ... installing lua-resty-iputils..." \
&& apk update \
&& apk add make \
&& mkdir -p /tmp/api-gateway \
&& curl -L https://github.com/hamishforbes/lua-resty-iputils/archive/v${LUA_RESTY_IPUTILS_VERSION}.tar.gz -o /tmp/api-gateway/lua-resty-iputils-${LUA_RESTY_IPUTILS_VERSION}.tar.gz \
&& tar -xf /tmp/api-gateway/lua-resty-iputils-${LUA_RESTY_IPUTILS_VERSION}.tar.gz -C /tmp/api-gateway/ \
&& cd /tmp/api-gateway/lua-resty-iputils-${LUA_RESTY_IPUTILS_VERSION} \
&& export LUA_LIB_DIR=${_prefix}/api-gateway/lualib \
&& export INSTALL=${_prefix}/api-gateway/bin/resty-install \
&& $INSTALL -d ${LUA_LIB_DIR}/resty \
&& $INSTALL lib/resty/*.lua ${LUA_LIB_DIR}/resty/ \
&& rm -rf /tmp/api-gateway
ENV CONFIG_SUPERVISOR_VERSION 1.0.3
ENV GOPATH /usr/lib/go/bin
ENV GOBIN /usr/lib/go/bin
ENV PATH $PATH:/usr/lib/go/bin
RUN echo " ... installing api-gateway-config-supervisor ... " \
&& echo "http://dl-4.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \
&& apk update \
&& apk add gcc make git 'go' \
&& mkdir -p /tmp/api-gateway \
&& curl -L https://github.com/adobe-apiplatform/api-gateway-config-supervisor/archive/${CONFIG_SUPERVISOR_VERSION}.tar.gz -o /tmp/api-gateway/api-gateway-config-supervisor-${CONFIG_SUPERVISOR_VERSION}.tar.gz \
&& cd /tmp/api-gateway \
&& tar -xf /tmp/api-gateway/api-gateway-config-supervisor-${CONFIG_SUPERVISOR_VERSION}.tar.gz \
&& mkdir -p /tmp/go \
&& mv /tmp/api-gateway/api-gateway-config-supervisor-${CONFIG_SUPERVISOR_VERSION}/* /tmp/go \
&& cd /tmp/go \
&& make setup \
&& mkdir -p /tmp/go/Godeps/_workspace \
&& ln -s /tmp/go/vendor /tmp/go/Godeps/_workspace/src \
&& mkdir -p /tmp/go-src/src/github.com/adobe-apiplatform \
&& ln -s /tmp/go /tmp/go-src/src/github.com/adobe-apiplatform/api-gateway-config-supervisor \
&& GOPATH=/tmp/go/vendor:/tmp/go-src CGO_ENABLED=0 GOOS=linux /usr/lib/go/bin/godep go build -ldflags "-s" -a -installsuffix cgo -o api-gateway-config-supervisor ./ \
&& mv /tmp/go/api-gateway-config-supervisor /usr/local/sbin/ \
&& echo "installing rclone sync ... skipped due to https://github.com/ncw/rclone/issues/663 ... " \
# && go get github.com/ncw/rclone \
# && mv /usr/lib/go/bin/rclone /usr/local/sbin/ \
&& echo " cleaning up ... " \
&& rm -rf /usr/lib/go/bin/src \
&& rm -rf /tmp/go \
&& rm -rf /tmp/go-src \
&& rm -rf /usr/lib/go/bin/pkg/ \
&& rm -rf /usr/lib/go/bin/godep \
&& apk del make git go gcc \
&& rm -rf /var/cache/apk/*
RUN echo " ... installing aws-cli ..." \
&& apk update \
&& apk add python \
&& apk add py-pip \
&& pip install --upgrade pip \
&& pip install awscli
ENV HMAC_LUA_VERSION 1.0.0
RUN echo " ... installing api-gateway-hmac ..." \
&& apk update \
&& apk add make \
&& mkdir -p /tmp/api-gateway \
&& curl -L https://github.com/adobe-apiplatform/api-gateway-hmac/archive/${HMAC_LUA_VERSION}.tar.gz -o /tmp/api-gateway/api-gateway-hmac-${HMAC_LUA_VERSION}.tar.gz \
&& tar -xf /tmp/api-gateway/api-gateway-hmac-${HMAC_LUA_VERSION}.tar.gz -C /tmp/api-gateway/ \
&& cd /tmp/api-gateway/api-gateway-hmac-${HMAC_LUA_VERSION} \
&& cp -r /usr/local/test-nginx-${TEST_NGINX_VERSION}/* ./test/resources/test-nginx/ \
&& make test \
&& make install \
LUA_LIB_DIR=${_prefix}/api-gateway/lualib \
INSTALL=${_prefix}/api-gateway/bin/resty-install \
&& rm -rf /tmp/api-gateway
ENV CACHE_MANAGER_VERSION 1.0.1
RUN echo " ... installing api-gateway-cachemanager..." \
&& apk update \
&& apk add make \
&& mkdir -p /tmp/api-gateway \
&& curl -L https://github.com/adobe-apiplatform/api-gateway-cachemanager/archive/${CACHE_MANAGER_VERSION}.tar.gz -o /tmp/api-gateway/api-gateway-cachemanager-${CACHE_MANAGER_VERSION}.tar.gz \
&& tar -xf /tmp/api-gateway/api-gateway-cachemanager-${CACHE_MANAGER_VERSION}.tar.gz -C /tmp/api-gateway/ \
&& cd /tmp/api-gateway/api-gateway-cachemanager-${CACHE_MANAGER_VERSION} \
&& cp -r /usr/local/test-nginx-${TEST_NGINX_VERSION}/* ./test/resources/test-nginx/ \
# && apk update && apk add redis \
# && REDIS_SERVER=/usr/bin/redis-server make test \
&& make install \
LUA_LIB_DIR=${_prefix}/api-gateway/lualib \
INSTALL=${_prefix}/api-gateway/bin/resty-install \
&& apk del redis \
&& rm -rf /var/cache/apk/* \
&& rm -rf /tmp/api-gateway
ENV AWS_VERSION 1.7.1
RUN echo " ... installing api-gateway-aws ..." \
&& apk update \
&& apk add make \
&& mkdir -p /tmp/api-gateway \
&& curl -L https://github.com/adobe-apiplatform/api-gateway-aws/archive/${AWS_VERSION}.tar.gz -o /tmp/api-gateway/api-gateway-aws-${AWS_VERSION}.tar.gz \
&& tar -xf /tmp/api-gateway/api-gateway-aws-${AWS_VERSION}.tar.gz -C /tmp/api-gateway/ \
&& cd /tmp/api-gateway/api-gateway-aws-${AWS_VERSION} \
&& cp -r /usr/local/test-nginx-${TEST_NGINX_VERSION}/* ./test/resources/test-nginx/ \
# && make test \
&& make install \
LUA_LIB_DIR=${_prefix}/api-gateway/lualib \
INSTALL=${_prefix}/api-gateway/bin/resty-install \
&& rm -rf /var/cache/apk/* \
&& rm -rf /tmp/api-gateway
ENV REQUEST_VALIDATION_VERSION 1.2.4
RUN echo " ... installing api-gateway-request-validation ..." \
&& apk update \
&& apk add make \
&& mkdir -p /tmp/api-gateway \
&& curl -L https://github.com/adobe-apiplatform/api-gateway-request-validation/archive/${REQUEST_VALIDATION_VERSION}.tar.gz -o /tmp/api-gateway/api-gateway-request-validation-${REQUEST_VALIDATION_VERSION}.tar.gz \
&& tar -xf /tmp/api-gateway/api-gateway-request-validation-${REQUEST_VALIDATION_VERSION}.tar.gz -C /tmp/api-gateway/ \
&& cd /tmp/api-gateway/api-gateway-request-validation-${REQUEST_VALIDATION_VERSION} \
&& cp -r /usr/local/test-nginx-${TEST_NGINX_VERSION}/* ./test/resources/test-nginx/ \
# && apk update && apk add redis \
# && REDIS_SERVER=/usr/bin/redis-server make test \
&& make install \
LUA_LIB_DIR=${_prefix}/api-gateway/lualib \
INSTALL=${_prefix}/api-gateway/bin/resty-install \
&& apk del redis \
&& rm -rf /var/cache/apk/* \
&& rm -rf /tmp/api-gateway
ENV ASYNC_LOGGER_VERSION 1.0.1
RUN echo " ... installing api-gateway-async-logger ..." \
&& apk update \
&& apk add make \
&& mkdir -p /tmp/api-gateway \
&& curl -L https://github.com/adobe-apiplatform/api-gateway-async-logger/archive/${ASYNC_LOGGER_VERSION}.tar.gz -o /tmp/api-gateway/api-gateway-async-logger-${ASYNC_LOGGER_VERSION}.tar.gz \
&& tar -xf /tmp/api-gateway/api-gateway-async-logger-${ASYNC_LOGGER_VERSION}.tar.gz -C /tmp/api-gateway/ \
&& cd /tmp/api-gateway/api-gateway-async-logger-${ASYNC_LOGGER_VERSION} \
&& cp -r /usr/local/test-nginx-${TEST_NGINX_VERSION}/* ./test/resources/test-nginx/ \
# && make test \
&& make install \
LUA_LIB_DIR=${_prefix}/api-gateway/lualib \
INSTALL=${_prefix}/api-gateway/bin/resty-install \
&& rm -rf /var/cache/apk/* \
&& rm -rf /tmp/api-gateway
ENV ZMQ_ADAPTOR_VERSION 0.2.1
RUN echo " ... installing api-gateway-zmq-adaptor" \
&& curl -L https://github.com/adobe-apiplatform/api-gateway-zmq-adaptor/archive/${ZMQ_ADAPTOR_VERSION}.tar.gz -o /tmp/api-gateway-zmq-adaptor-${ZMQ_ADAPTOR_VERSION} \
&& apk update \
&& apk add check-dev g++ gcc \
&& cd /tmp/ \
&& tar -xf /tmp/api-gateway-zmq-adaptor-${ZMQ_ADAPTOR_VERSION} \
&& cd /tmp/api-gateway-zmq-adaptor-* \
&& make test \
&& PREFIX=/usr/local/sbin make install \
&& rm -rf /tmp/api-gateway-zmq-adaptor-* \
&& apk del check-dev g++ gcc \
&& rm -rf /var/cache/apk/*
ENV ZMQ_LOGGER_VERSION 1.0.0
RUN echo " ... installing api-gateway-zmq-logger ..." \
&& mkdir -p /tmp/api-gateway \
&& curl -L https://github.com/adobe-apiplatform/api-gateway-zmq-logger/archive/${ZMQ_LOGGER_VERSION}.tar.gz -o /tmp/api-gateway/api-gateway-zmq-logger-${ZMQ_LOGGER_VERSION}.tar.gz \
&& tar -xf /tmp/api-gateway/api-gateway-zmq-logger-${ZMQ_LOGGER_VERSION}.tar.gz -C /tmp/api-gateway/ \
&& cd /tmp/api-gateway/api-gateway-zmq-logger-${ZMQ_LOGGER_VERSION} \
&& cp -r /usr/local/test-nginx-${TEST_NGINX_VERSION}/* ./test/resources/test-nginx/ \
&& make test \
&& make install \
LUA_LIB_DIR=/usr/local/api-gateway/lualib \
INSTALL=/usr/local/api-gateway/bin/resty-install \
&& rm -rf /tmp/api-gateway
ENV REQUEST_TRACKING_VERSION 1.0.1
RUN echo " ... installing api-gateway-request-tracking ..." \
&& mkdir -p /tmp/api-gateway \
&& curl -L https://github.com/adobe-apiplatform/api-gateway-request-tracking/archive/${REQUEST_TRACKING_VERSION}.tar.gz -o /tmp/api-gateway/api-gateway-request-tracking-${REQUEST_TRACKING_VERSION}.tar.gz \
&& tar -xf /tmp/api-gateway/api-gateway-request-tracking-${REQUEST_TRACKING_VERSION}.tar.gz -C /tmp/api-gateway/ \
&& cd /tmp/api-gateway/api-gateway-request-tracking-${REQUEST_TRACKING_VERSION} \
&& cp -r /usr/local/test-nginx-${TEST_NGINX_VERSION}/* ./test/resources/test-nginx/ \
# && apk update && apk add redis \
# && REDIS_SERVER=/usr/bin/redis-server make test \
&& make install \
LUA_LIB_DIR=/usr/local/api-gateway/lualib \
INSTALL=/usr/local/api-gateway/bin/resty-install \
# && apk del redis \
&& rm -rf /tmp/api-gateway
RUN \
curl -L -k -s -o /usr/local/bin/jq https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64 \
&& apk update \
&& apk add gawk \
&& chmod 755 /usr/local/bin/jq \
&& rm -rf /var/cache/apk/*
COPY init.sh /etc/init-container.sh
#add the default configuration for the Gateway
COPY api-gateway-config /etc/api-gateway
RUN adduser -S nginx-api-gateway -u 1000 \
&& addgroup -S nginx-api-gateway -g 1000
RUN mkdir -p /usr/local/api-gateway \
&& chown -R nginx-api-gateway /etc/api-gateway /var/log/api-gateway /usr/local \
&& chmod 755 -R /etc/api-gateway /var/log/api-gateway /usr/local \
&& chmod 4755 /bin/busybox \
&& echo "nginx-api-gateway ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
# add the default configuration for the Gateway
USER nginx-api-gateway
ENTRYPOINT ["/etc/init-container.sh"]