diff options
author | Andrei Belov <defan@nginx.com> | 2019-10-03 17:46:28 +0300 |
---|---|---|
committer | Andrei Belov <defan@nginx.com> | 2019-10-03 17:46:28 +0300 |
commit | 3dd3f861f4c3aa320aa137802f033f8f1fc7dc41 (patch) | |
tree | 357577c560920eb0f5837b7d073999f5c7a1a2cd /pkg/docker | |
parent | 9de7aea721245cda9f079a2b29d8efaf99c440fd (diff) | |
parent | 59db9a3887211fccdaec04b7952ad0140090de22 (diff) | |
download | unit-3dd3f861f4c3aa320aa137802f033f8f1fc7dc41.tar.gz unit-3dd3f861f4c3aa320aa137802f033f8f1fc7dc41.tar.bz2 |
Merged with the default branch.
Diffstat (limited to 'pkg/docker')
-rw-r--r-- | pkg/docker/Dockerfile.full | 6 | ||||
-rw-r--r-- | pkg/docker/Dockerfile.go1.7-dev | 6 | ||||
-rw-r--r-- | pkg/docker/Dockerfile.go1.8-dev | 6 | ||||
-rw-r--r-- | pkg/docker/Dockerfile.minimal | 6 | ||||
-rw-r--r-- | pkg/docker/Dockerfile.perl5.24 | 6 | ||||
-rw-r--r-- | pkg/docker/Dockerfile.php7.0 | 6 | ||||
-rw-r--r-- | pkg/docker/Dockerfile.python2.7 | 6 | ||||
-rw-r--r-- | pkg/docker/Dockerfile.python3.5 | 6 | ||||
-rw-r--r-- | pkg/docker/Dockerfile.ruby2.3 | 6 | ||||
-rw-r--r-- | pkg/docker/Dockerfile.tmpl | 4 | ||||
-rw-r--r-- | pkg/docker/Makefile | 2 | ||||
-rwxr-xr-x | pkg/docker/docker-entrypoint.sh | 71 |
12 files changed, 121 insertions, 10 deletions
diff --git a/pkg/docker/Dockerfile.full b/pkg/docker/Dockerfile.full index ae700b32..c6646fda 100644 --- a/pkg/docker/Dockerfile.full +++ b/pkg/docker/Dockerfile.full @@ -2,7 +2,7 @@ FROM debian:stretch-slim LABEL maintainer="NGINX Docker Maintainers <docker-maint@nginx.com>" -ENV UNIT_VERSION 1.11.0-2~stretch +ENV UNIT_VERSION 1.12.0-1~stretch RUN set -x \ && apt-get update \ @@ -86,4 +86,8 @@ RUN ln -sf /dev/stdout /var/log/unit.log STOPSIGNAL SIGTERM +COPY docker-entrypoint.sh /usr/local/bin/ +RUN mkdir /docker-entrypoint.d/ +ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] + CMD ["unitd", "--no-daemon", "--control", "unix:/var/run/control.unit.sock"] diff --git a/pkg/docker/Dockerfile.go1.7-dev b/pkg/docker/Dockerfile.go1.7-dev index 12b80daa..9b57d3ec 100644 --- a/pkg/docker/Dockerfile.go1.7-dev +++ b/pkg/docker/Dockerfile.go1.7-dev @@ -2,7 +2,7 @@ FROM debian:stretch-slim LABEL maintainer="NGINX Docker Maintainers <docker-maint@nginx.com>" -ENV UNIT_VERSION 1.11.0-2~stretch +ENV UNIT_VERSION 1.12.0-1~stretch RUN set -x \ && apt-get update \ @@ -86,4 +86,8 @@ RUN ln -sf /dev/stdout /var/log/unit.log STOPSIGNAL SIGTERM +COPY docker-entrypoint.sh /usr/local/bin/ +RUN mkdir /docker-entrypoint.d/ +ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] + CMD ["unitd", "--no-daemon", "--control", "unix:/var/run/control.unit.sock"] diff --git a/pkg/docker/Dockerfile.go1.8-dev b/pkg/docker/Dockerfile.go1.8-dev index 58b36458..5f650aae 100644 --- a/pkg/docker/Dockerfile.go1.8-dev +++ b/pkg/docker/Dockerfile.go1.8-dev @@ -2,7 +2,7 @@ FROM debian:stretch-slim LABEL maintainer="NGINX Docker Maintainers <docker-maint@nginx.com>" -ENV UNIT_VERSION 1.11.0-2~stretch +ENV UNIT_VERSION 1.12.0-1~stretch RUN set -x \ && apt-get update \ @@ -86,4 +86,8 @@ RUN ln -sf /dev/stdout /var/log/unit.log STOPSIGNAL SIGTERM +COPY docker-entrypoint.sh /usr/local/bin/ +RUN mkdir /docker-entrypoint.d/ +ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] + CMD ["unitd", "--no-daemon", "--control", "unix:/var/run/control.unit.sock"] diff --git a/pkg/docker/Dockerfile.minimal b/pkg/docker/Dockerfile.minimal index 587ef3f1..427a3ada 100644 --- a/pkg/docker/Dockerfile.minimal +++ b/pkg/docker/Dockerfile.minimal @@ -2,7 +2,7 @@ FROM debian:stretch-slim LABEL maintainer="NGINX Docker Maintainers <docker-maint@nginx.com>" -ENV UNIT_VERSION 1.11.0-2~stretch +ENV UNIT_VERSION 1.12.0-1~stretch RUN set -x \ && apt-get update \ @@ -86,4 +86,8 @@ RUN ln -sf /dev/stdout /var/log/unit.log STOPSIGNAL SIGTERM +COPY docker-entrypoint.sh /usr/local/bin/ +RUN mkdir /docker-entrypoint.d/ +ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] + CMD ["unitd", "--no-daemon", "--control", "unix:/var/run/control.unit.sock"] diff --git a/pkg/docker/Dockerfile.perl5.24 b/pkg/docker/Dockerfile.perl5.24 index fb77a03a..7e51adcf 100644 --- a/pkg/docker/Dockerfile.perl5.24 +++ b/pkg/docker/Dockerfile.perl5.24 @@ -2,7 +2,7 @@ FROM debian:stretch-slim LABEL maintainer="NGINX Docker Maintainers <docker-maint@nginx.com>" -ENV UNIT_VERSION 1.11.0-2~stretch +ENV UNIT_VERSION 1.12.0-1~stretch RUN set -x \ && apt-get update \ @@ -86,4 +86,8 @@ RUN ln -sf /dev/stdout /var/log/unit.log STOPSIGNAL SIGTERM +COPY docker-entrypoint.sh /usr/local/bin/ +RUN mkdir /docker-entrypoint.d/ +ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] + CMD ["unitd", "--no-daemon", "--control", "unix:/var/run/control.unit.sock"] diff --git a/pkg/docker/Dockerfile.php7.0 b/pkg/docker/Dockerfile.php7.0 index 2654fe04..9615e041 100644 --- a/pkg/docker/Dockerfile.php7.0 +++ b/pkg/docker/Dockerfile.php7.0 @@ -2,7 +2,7 @@ FROM debian:stretch-slim LABEL maintainer="NGINX Docker Maintainers <docker-maint@nginx.com>" -ENV UNIT_VERSION 1.11.0-2~stretch +ENV UNIT_VERSION 1.12.0-1~stretch RUN set -x \ && apt-get update \ @@ -86,4 +86,8 @@ RUN ln -sf /dev/stdout /var/log/unit.log STOPSIGNAL SIGTERM +COPY docker-entrypoint.sh /usr/local/bin/ +RUN mkdir /docker-entrypoint.d/ +ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] + CMD ["unitd", "--no-daemon", "--control", "unix:/var/run/control.unit.sock"] diff --git a/pkg/docker/Dockerfile.python2.7 b/pkg/docker/Dockerfile.python2.7 index 61a3e655..eb599f95 100644 --- a/pkg/docker/Dockerfile.python2.7 +++ b/pkg/docker/Dockerfile.python2.7 @@ -2,7 +2,7 @@ FROM debian:stretch-slim LABEL maintainer="NGINX Docker Maintainers <docker-maint@nginx.com>" -ENV UNIT_VERSION 1.11.0-2~stretch +ENV UNIT_VERSION 1.12.0-1~stretch RUN set -x \ && apt-get update \ @@ -86,4 +86,8 @@ RUN ln -sf /dev/stdout /var/log/unit.log STOPSIGNAL SIGTERM +COPY docker-entrypoint.sh /usr/local/bin/ +RUN mkdir /docker-entrypoint.d/ +ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] + CMD ["unitd", "--no-daemon", "--control", "unix:/var/run/control.unit.sock"] diff --git a/pkg/docker/Dockerfile.python3.5 b/pkg/docker/Dockerfile.python3.5 index 85c0ccb9..362fb3ed 100644 --- a/pkg/docker/Dockerfile.python3.5 +++ b/pkg/docker/Dockerfile.python3.5 @@ -2,7 +2,7 @@ FROM debian:stretch-slim LABEL maintainer="NGINX Docker Maintainers <docker-maint@nginx.com>" -ENV UNIT_VERSION 1.11.0-2~stretch +ENV UNIT_VERSION 1.12.0-1~stretch RUN set -x \ && apt-get update \ @@ -86,4 +86,8 @@ RUN ln -sf /dev/stdout /var/log/unit.log STOPSIGNAL SIGTERM +COPY docker-entrypoint.sh /usr/local/bin/ +RUN mkdir /docker-entrypoint.d/ +ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] + CMD ["unitd", "--no-daemon", "--control", "unix:/var/run/control.unit.sock"] diff --git a/pkg/docker/Dockerfile.ruby2.3 b/pkg/docker/Dockerfile.ruby2.3 index 253e9ed0..cc2e8637 100644 --- a/pkg/docker/Dockerfile.ruby2.3 +++ b/pkg/docker/Dockerfile.ruby2.3 @@ -2,7 +2,7 @@ FROM debian:stretch-slim LABEL maintainer="NGINX Docker Maintainers <docker-maint@nginx.com>" -ENV UNIT_VERSION 1.11.0-2~stretch +ENV UNIT_VERSION 1.12.0-1~stretch RUN set -x \ && apt-get update \ @@ -86,4 +86,8 @@ RUN ln -sf /dev/stdout /var/log/unit.log STOPSIGNAL SIGTERM +COPY docker-entrypoint.sh /usr/local/bin/ +RUN mkdir /docker-entrypoint.d/ +ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] + CMD ["unitd", "--no-daemon", "--control", "unix:/var/run/control.unit.sock"] diff --git a/pkg/docker/Dockerfile.tmpl b/pkg/docker/Dockerfile.tmpl index 18d6d34e..c721931b 100644 --- a/pkg/docker/Dockerfile.tmpl +++ b/pkg/docker/Dockerfile.tmpl @@ -86,4 +86,8 @@ RUN ln -sf /dev/stdout /var/log/unit.log STOPSIGNAL SIGTERM +COPY docker-entrypoint.sh /usr/local/bin/ +RUN mkdir /docker-entrypoint.d/ +ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] + CMD ["unitd", "--no-daemon", "--control", "unix:/var/run/control.unit.sock"] diff --git a/pkg/docker/Makefile b/pkg/docker/Makefile index b4ed95f4..e826cb95 100644 --- a/pkg/docker/Makefile +++ b/pkg/docker/Makefile @@ -2,7 +2,7 @@ include ../../version -DEFAULT_RELEASE := 2 +DEFAULT_RELEASE := 1 VERSION ?= $(NXT_VERSION) RELEASE ?= $(DEFAULT_RELEASE) diff --git a/pkg/docker/docker-entrypoint.sh b/pkg/docker/docker-entrypoint.sh new file mode 100755 index 00000000..4ad7cb9a --- /dev/null +++ b/pkg/docker/docker-entrypoint.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash + +set -e + +curl_put() +{ + RET=`/usr/bin/curl -s -w '%{http_code}' -X PUT --data-binary @$1 --unix-socket /var/run/control.unit.sock http://localhost/$2` + RET_BODY=${RET::-3} + RET_STATUS=$(echo $RET | /usr/bin/tail -c 4) + if [ "$RET_STATUS" -ne "200" ]; then + echo "$0: Error: HTTP response status code is '$RET_STATUS'" + echo "$RET_BODY" + return 1 + else + echo "$0: OK: HTTP response status code is '$RET_STATUS'" + echo "$RET_BODY" + fi + return 0 +} + +if [ "$1" = "unitd" ]; then + if /usr/bin/find "/var/lib/unit/" -mindepth 1 -print -quit 2>/dev/null | /bin/grep -q .; then + echo "$0: /var/lib/unit/ is not empty, skipping initial configuration..." + else + if /usr/bin/find "/docker-entrypoint.d/" -mindepth 1 -print -quit 2>/dev/null | /bin/grep -q .; then + echo "$0: /docker-entrypoint.d/ is not empty, launching Unit daemon to perform initial configuration..." + /usr/sbin/unitd --control unix:/var/run/control.unit.sock + + while [ ! -S /var/run/control.unit.sock ]; do echo "$0: Waiting for control socket to be created..."; /bin/sleep 0.1; done + # even when the control socket exists, it does not mean unit has finished initialisation + # this curl call will get a reply once unit is fully launched + /usr/bin/curl -s -X GET --unix-socket /var/run/control.unit.sock http://localhost/ + + echo "$0: Looking for certificate bundles in /docker-entrypoint.d/..." + for f in $(/usr/bin/find /docker-entrypoint.d/ -type f -name "*.pem"); do + echo "$0: Uploading certificates bundle: $f" + curl_put $f "certificates/$(basename $f .pem)" + done + + echo "$0: Looking for configuration snippets in /docker-entrypoint.d/..." + for f in $(/usr/bin/find /docker-entrypoint.d/ -type f -name "*.json"); do + echo "$0: Applying configuration $f"; + curl_put $f "config" + done + + echo "$0: Looking for shell scripts in /docker-entrypoint.d/..." + for f in $(/usr/bin/find /docker-entrypoint.d/ -type f -name "*.sh"); do + echo "$0: Launching $f"; + "$f" + done + + # warn on filetypes we don't know what to do with + for f in $(/usr/bin/find /docker-entrypoint.d/ -type f -not -name "*.sh" -not -name "*.json" -not -name "*.pem"); do + echo "$0: Ignoring $f"; + done + + echo "$0: Stopping Unit daemon after initial configuration..." + kill -TERM `/bin/cat /var/run/unit.pid` + + while [ -S /var/run/control.unit.sock ]; do echo "$0: Waiting for control socket to be removed..."; /bin/sleep 0.1; done + + echo + echo "$0: Unit initial configuration complete; ready for start up..." + echo + else + echo "$0: /docker-entrypoint.d/ is empty, skipping initial configuration..." + fi + fi +fi + +exec "$@" |