Update Java 8 to 11
[msb/apigateway.git] / distributions / msb-apigateway / src / main / basedocker / Dockerfile
1 # Dockerfile - msb-base
2 FROM openresty/openresty:alpine
3
4 # Setup proxy variables
5 ARG http_proxy
6 ARG https_proxy
7
8 ENV http_proxy  ${http_proxy}
9 ENV https_proxy ${https_proxy}
10
11 #install java-1.8-openjdk
12
13 ENV LANG C.UTF-8
14
15 # add a simple script that can auto-detect the appropriate JAVA_HOME value
16 # based on whether the JDK or only the JRE is installed
17 RUN { \
18                 echo '#!/bin/sh'; \
19                 echo 'set -e'; \
20                 echo; \
21                 echo 'dirname "$(dirname "$(readlink -f "$(which javac || which java)")")"'; \
22         } > /usr/local/bin/docker-java-home \
23         && chmod +x /usr/local/bin/docker-java-home
24 ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk
25 ENV PATH $PATH:/usr/lib/jvm/java-11-openjdk/jre/bin:/usr/lib/jvm/java-11-openjdk/bin
26
27 ENV JAVA_VERSION 11.0.9
28 ENV JAVA_ALPINE_VERSION 11.0.9_p11-r1
29
30 RUN set -x \
31         && apk add --no-cache \
32                 openjdk8="$JAVA_ALPINE_VERSION" \
33         && [ "$JAVA_HOME" = "$(docker-java-home)" ]
34         
35 #install redis
36
37 # add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
38 RUN addgroup -S redis && adduser -S -G redis redis
39
40 # grab su-exec for easy step-down from root
41 RUN apk add --no-cache 'su-exec>=0.2'
42
43 ENV REDIS_VERSION 4.0.1
44 ENV REDIS_DOWNLOAD_URL http://download.redis.io/releases/redis-4.0.1.tar.gz
45 ENV REDIS_DOWNLOAD_SHA 2049cd6ae9167f258705081a6ef23bb80b7eff9ff3d0d7481e89510f27457591
46
47 # for redis-sentinel see: http://redis.io/topics/sentinel
48 RUN set -ex; \
49         \
50         apk add --no-cache --virtual .build-deps \
51                 coreutils \
52                 gcc \
53                 linux-headers \
54                 make \
55                 musl-dev \
56         ; \
57         \
58         wget -O redis.tar.gz "$REDIS_DOWNLOAD_URL"; \
59         echo "$REDIS_DOWNLOAD_SHA *redis.tar.gz" | sha256sum -c -; \
60         mkdir -p /usr/src/redis; \
61         tar -xzf redis.tar.gz -C /usr/src/redis --strip-components=1; \
62         rm redis.tar.gz; \
63         \
64 # disable Redis protected mode [1] as it is unnecessary in context of Docker
65 # (ports are not automatically exposed when running inside Docker, but rather explicitly by specifying -p / -P)
66 # [1]: https://github.com/antirez/redis/commit/edd4d555df57dc84265fdfb4ef59a4678832f6da
67         grep -q '^#define CONFIG_DEFAULT_PROTECTED_MODE 1$' /usr/src/redis/src/server.h; \
68         sed -ri 's!^(#define CONFIG_DEFAULT_PROTECTED_MODE) 1$!\1 0!' /usr/src/redis/src/server.h; \
69         grep -q '^#define CONFIG_DEFAULT_PROTECTED_MODE 0$' /usr/src/redis/src/server.h; \
70 # for future reference, we modify this directly in the source instead of just supplying a default configuration flag because apparently "if you specify any argument to redis-server, [it assumes] you are going to specify everything"
71 # see also https://github.com/docker-library/redis/issues/4#issuecomment-50780840
72 # (more exactly, this makes sure the default behavior of "save on SIGTERM" stays functional by default)
73         \
74         make -C /usr/src/redis -j "$(nproc)"; \
75         make -C /usr/src/redis install; \
76         \
77         rm -r /usr/src/redis; \
78         mkdir /usr/local/redis; \
79         cd /usr/local/bin; \    
80     mv redis-server redis-cli  /usr/local/redis; \
81         \
82         apk del .build-deps
83
84