From 9d3d64df2de89518345ce01d52d8c10def874699 Mon Sep 17 00:00:00 2001 From: Nitish Tiwari Date: Tue, 20 Jun 2017 19:24:45 -0700 Subject: [PATCH] Added HEALTHCHECK in release Dockerfiles (#4550) A new script `healthcheck.sh` checks for http status 200/404 --- Dockerfile.release | 13 ++++++++----- Dockerfile.release.aarch64 | 13 ++++++++----- Dockerfile.release.armhf | 13 ++++++++----- buildscripts/healthcheck.sh | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 15 deletions(-) create mode 100644 buildscripts/healthcheck.sh diff --git a/Dockerfile.release b/Dockerfile.release index 10272aa63..762e14ffa 100644 --- a/Dockerfile.release +++ b/Dockerfile.release @@ -1,23 +1,26 @@ FROM alpine:3.5 MAINTAINER Minio Inc + +COPY buildscripts/docker-entrypoint.sh buildscripts/healthcheck.sh /usr/bin/ RUN \ apk add --no-cache ca-certificates && \ apk add --no-cache --virtual .build-deps curl && \ echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf && \ curl https://dl.minio.io/server/minio/release/linux-amd64/minio > /usr/bin/minio && \ - chmod +x /usr/bin/minio && apk del .build-deps + chmod +x /usr/bin/minio && \ + chmod +x /usr/bin/docker-entrypoint.sh && \ + chmod +x /usr/bin/healthcheck.sh EXPOSE 9000 -COPY buildscripts/docker-entrypoint.sh /usr/bin/ - -RUN chmod +x /usr/bin/docker-entrypoint.sh - ENTRYPOINT ["/usr/bin/docker-entrypoint.sh"] VOLUME ["/export"] +HEALTHCHECK --interval=30s --timeout=5s \ + CMD /usr/bin/healthcheck.sh + CMD ["minio"] diff --git a/Dockerfile.release.aarch64 b/Dockerfile.release.aarch64 index 072b4f858..64bb9b246 100644 --- a/Dockerfile.release.aarch64 +++ b/Dockerfile.release.aarch64 @@ -2,21 +2,24 @@ FROM resin/aarch64-alpine:3.5 MAINTAINER Minio Inc +COPY buildscripts/docker-entrypoint.sh buildscripts/healthcheck.sh /usr/bin/ + RUN \ apk add --no-cache ca-certificates && \ apk add --no-cache --virtual .build-deps curl && \ echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf && \ curl https://dl.minio.io/server/minio/release/linux-arm64/minio > /usr/bin/minio && \ - chmod +x /usr/bin/minio && apk del .build-deps + chmod +x /usr/bin/minio && \ + chmod +x /usr/bin/docker-entrypoint.sh && \ + chmod +x /usr/bin/healthcheck.sh EXPOSE 9000 -COPY buildscripts/docker-entrypoint.sh /usr/bin/ - -RUN chmod +x /usr/bin/docker-entrypoint.sh - ENTRYPOINT ["/usr/bin/docker-entrypoint.sh"] VOLUME ["/export"] +HEALTHCHECK --interval=30s --timeout=5s \ + CMD /usr/bin/healthcheck.sh + CMD ["minio"] diff --git a/Dockerfile.release.armhf b/Dockerfile.release.armhf index b21ef6b58..6e8649735 100644 --- a/Dockerfile.release.armhf +++ b/Dockerfile.release.armhf @@ -2,21 +2,24 @@ FROM resin/armhf-alpine:3.5 MAINTAINER Minio Inc +COPY buildscripts/docker-entrypoint.sh buildscripts/healthcheck.sh /usr/bin/ + RUN \ apk add --no-cache ca-certificates && \ apk add --no-cache --virtual .build-deps curl && \ echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf && \ curl https://dl.minio.io/server/minio/release/linux-arm/minio > /usr/bin/minio && \ - chmod +x /usr/bin/minio && apk del .build-deps + chmod +x /usr/bin/minio && \ + chmod +x /usr/bin/docker-entrypoint.sh && \ + chmod +x /usr/bin/healthcheck.sh EXPOSE 9000 -COPY buildscripts/docker-entrypoint.sh /usr/bin/ - -RUN chmod +x /usr/bin/docker-entrypoint.sh - ENTRYPOINT ["/usr/bin/docker-entrypoint.sh"] VOLUME ["/export"] +HEALTHCHECK --interval=30s --timeout=5s \ + CMD /usr/bin/healthcheck.sh + CMD ["minio"] diff --git a/buildscripts/healthcheck.sh b/buildscripts/healthcheck.sh new file mode 100644 index 000000000..142eca50e --- /dev/null +++ b/buildscripts/healthcheck.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# +# Minio Cloud Storage, (C) 2017 Minio, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_init () { + address="http://127.0.0.1:9000" + resource="/minio/index.html" +} + +HealthCheckMain () { + # Get the http response code + http_response=$(curl -s -o /dev/null -I -w "%{http_code}" ${address}${resource}) + + # If http_repsonse is 200 - server is up. + # When MINIO_BROWSER is set to off, curl responds with 404. We assume that the the server is up + [ "$http_response" == "200" ] || [ "$http_response" == "404" ] +} + +_init && HealthCheckMain