Exit container with error message when pseudo-TTY is unallocated (#141)

Fixes #139
Fixes #140

Signed-off-by: Wouter Born <eclipse@maindrain.net>
pull/145/head
Wouter Born 2017-12-22 01:19:34 +01:00 committed by Christian Häussler
parent 4efbb04e48
commit 75ef3afb33
44 changed files with 684 additions and 347 deletions

View File

@ -11,7 +11,7 @@ before_install:
- docker run --rm --privileged multiarch/qemu-user-static:register --reset - docker run --rm --privileged multiarch/qemu-user-static:register --reset
install: install:
- docker build --build-arg VCS_REF=$TRAVIS_COMMIT --build-arg BUILD_DATE=$(date +"%Y-%m-%dT%H:%M:%SZ") --build-arg VERSION=$VERSION -t $DOCKER_REPO:$VERSION-$TARGET-$DIST $VERSION/$TARGET/$DIST - docker build --build-arg VCS_REF=$TRAVIS_COMMIT --build-arg BUILD_DATE=$(date +"%Y-%m-%dT%H:%M:%SZ") --build-arg VERSION=$VERSION -t $DOCKER_REPO:$VERSION-$TARGET-$DIST $VERSION/$TARGET/$DIST
- docker run --rm $DOCKER_REPO:$VERSION-$TARGET-$DIST uname -a - docker run --rm --tty $DOCKER_REPO:$VERSION-$TARGET-$DIST uname -a
after_success: after_success:
- docker login -e=$DOCKER_EMAIL -u=$DOCKER_USERNAME -p=$DOCKER_PASSWORD - docker login -e=$DOCKER_EMAIL -u=$DOCKER_USERNAME -p=$DOCKER_PASSWORD
- docker push $DOCKER_REPO:$VERSION-$TARGET-$DIST - docker push $DOCKER_REPO:$VERSION-$TARGET-$DIST

View File

@ -1,4 +1,12 @@
#!/bin/sh -x #!/bin/sh -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/bash -x #!/bin/bash -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/sh -x #!/bin/sh -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/bash -x #!/bin/bash -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/sh -x #!/bin/sh -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/bash -x #!/bin/bash -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/sh -x #!/bin/sh -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/bash -x #!/bin/bash -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/sh -x #!/bin/sh -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/bash -x #!/bin/bash -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/sh -x #!/bin/sh -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/bash -x #!/bin/bash -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/sh -x #!/bin/sh -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/bash -x #!/bin/bash -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/sh -x #!/bin/sh -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/bash -x #!/bin/bash -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/sh -x #!/bin/sh -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/bash -x #!/bin/bash -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/sh -x #!/bin/sh -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/bash -x #!/bin/bash -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/sh -x #!/bin/sh -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/bash -x #!/bin/bash -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/sh -x #!/bin/sh -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/bash -x #!/bin/bash -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/sh -x #!/bin/sh -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/bash -x #!/bin/bash -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/sh -x #!/bin/sh -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/bash -x #!/bin/bash -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/sh -x #!/bin/sh -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/bash -x #!/bin/bash -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/sh -x #!/bin/sh -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/bash -x #!/bin/bash -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/sh -x #!/bin/sh -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/bash -x #!/bin/bash -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/sh -x #!/bin/sh -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/bash -x #!/bin/bash -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/sh -x #!/bin/sh -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/bash -x #!/bin/bash -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/sh -x #!/bin/sh -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/bash -x #!/bin/bash -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/sh -x #!/bin/sh -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

View File

@ -1,4 +1,12 @@
#!/bin/bash -x #!/bin/bash -x
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
test -t 0
if [ $? -eq 1 ]; then
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
exit 1
fi
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'

693
update.sh
View File

@ -1,346 +1,347 @@
#!/bin/bash #!/bin/bash
set -eo pipefail set -eo pipefail
# Dockerfiles to be generated # Dockerfiles to be generated
versions="2.3.0-snapshot 2.2.0 2.1.0 2.0.0 1.8.3" versions="2.3.0-snapshot 2.2.0 2.1.0 2.0.0 1.8.3"
arches="i386 amd64 armhf arm64" arches="i386 amd64 armhf arm64"
bases="debian alpine" bases="debian alpine"
# Generate header # Generate header
print_header() { print_header() {
cat > $1 <<-EOI cat > $1 <<-EOI
# openhab image # openhab image
# #
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# NOTE: THIS DOCKERFILE IS GENERATED VIA "update.sh" # NOTE: THIS DOCKERFILE IS GENERATED VIA "update.sh"
# #
# PLEASE DO NOT EDIT IT DIRECTLY. # PLEASE DO NOT EDIT IT DIRECTLY.
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# #
EOI EOI
} }
# Print selected image # Print selected image
print_baseimage() { print_baseimage() {
# Set download url for openhab version # Set download url for openhab version
case $version in case $version in
2.3.0-snapshot) 2.3.0-snapshot)
openhab_url="https://openhab.ci.cloudbees.com/job/openHAB-Distribution/lastSuccessfulBuild/artifact/distributions/openhab/target/openhab-2.3.0-SNAPSHOT.zip" openhab_url="https://openhab.ci.cloudbees.com/job/openHAB-Distribution/lastSuccessfulBuild/artifact/distributions/openhab/target/openhab-2.3.0-SNAPSHOT.zip"
;; ;;
2.2.0) 2.2.0)
openhab_url="https://bintray.com/openhab/mvn/download_file?file_path=org%2Fopenhab%2Fdistro%2Fopenhab%2F2.2.0%2Fopenhab-2.2.0.zip" openhab_url="https://bintray.com/openhab/mvn/download_file?file_path=org%2Fopenhab%2Fdistro%2Fopenhab%2F2.2.0%2Fopenhab-2.2.0.zip"
;; ;;
2.1.0) 2.1.0)
openhab_url="https://bintray.com/openhab/mvn/download_file?file_path=org%2Fopenhab%2Fdistro%2Fopenhab%2F2.1.0%2Fopenhab-2.1.0.zip" openhab_url="https://bintray.com/openhab/mvn/download_file?file_path=org%2Fopenhab%2Fdistro%2Fopenhab%2F2.1.0%2Fopenhab-2.1.0.zip"
;; ;;
2.0.0) 2.0.0)
openhab_url="https://bintray.com/openhab/mvn/download_file?file_path=org%2Fopenhab%2Fdistro%2Fopenhab%2F2.0.0%2Fopenhab-2.0.0.zip" openhab_url="https://bintray.com/openhab/mvn/download_file?file_path=org%2Fopenhab%2Fdistro%2Fopenhab%2F2.0.0%2Fopenhab-2.0.0.zip"
;; ;;
1.8.3) 1.8.3)
openhab_url="https://bintray.com/artifact/download/openhab/bin/distribution-1.8.3-runtime.zip" openhab_url="https://bintray.com/artifact/download/openhab/bin/distribution-1.8.3-runtime.zip"
;; ;;
default) default)
openhab_url="error" openhab_url="error"
;; ;;
esac esac
# Set java download based on architecture # Set java download based on architecture
case $arch in case $arch in
i386|amd64) i386|amd64)
java_url="https://www.azul.com/downloads/zulu/zdk-8-ga-linux_x64.tar.gz" java_url="https://www.azul.com/downloads/zulu/zdk-8-ga-linux_x64.tar.gz"
;; ;;
armhf|arm64) armhf|arm64)
java_url="https://www.azul.com/downloads/zulu/zdk-8-ga-linux_aarch32hf.tar.gz" java_url="https://www.azul.com/downloads/zulu/zdk-8-ga-linux_aarch32hf.tar.gz"
;; ;;
default) default)
java_url="error" java_url="error"
;; ;;
esac esac
# Set docker base image based on distributions # Set docker base image based on distributions
case $base in case $base in
debian) debian)
base_image="debian-debootstrap:$arch-jessie" base_image="debian-debootstrap:$arch-jessie"
;; ;;
alpine) alpine)
base_image="alpine:$arch-v3.7" base_image="alpine:$arch-v3.7"
;; ;;
default) default)
base_image="error" base_image="error"
;; ;;
esac esac
cat >> $1 <<-EOI cat >> $1 <<-EOI
FROM multiarch/$base_image FROM multiarch/$base_image
# Set download urls # Set download urls
ENV \ ENV \
JAVA_URL="$java_url" \ JAVA_URL="$java_url" \
OPENHAB_URL="$openhab_url" \ OPENHAB_URL="$openhab_url" \
OPENHAB_VERSION="$version" OPENHAB_VERSION="$version"
EOI EOI
} }
# Print metadata # Print metadata
print_basemetadata() { print_basemetadata() {
cat >> $1 <<-'EOI' cat >> $1 <<-'EOI'
# Set variables and locales # Set variables and locales
ENV \ ENV \
APPDIR="/openhab" \ APPDIR="/openhab" \
EXTRA_JAVA_OPTS="" \ EXTRA_JAVA_OPTS="" \
OPENHAB_HTTP_PORT="8080" \ OPENHAB_HTTP_PORT="8080" \
OPENHAB_HTTPS_PORT="8443" \ OPENHAB_HTTPS_PORT="8443" \
LC_ALL=en_US.UTF-8 \ LC_ALL=en_US.UTF-8 \
LANG=en_US.UTF-8 \ LANG=en_US.UTF-8 \
LANGUAGE=en_US.UTF-8 LANGUAGE=en_US.UTF-8
# Set arguments on build # Set arguments on build
ARG BUILD_DATE ARG BUILD_DATE
ARG VCS_REF ARG VCS_REF
ARG VERSION ARG VERSION
# Basic build-time metadata as defined at http://label-schema.org # Basic build-time metadata as defined at http://label-schema.org
LABEL org.label-schema.build-date=$BUILD_DATE \ LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.docker.dockerfile="/Dockerfile" \ org.label-schema.docker.dockerfile="/Dockerfile" \
org.label-schema.license="EPL" \ org.label-schema.license="EPL" \
org.label-schema.name="openHAB" \ org.label-schema.name="openHAB" \
org.label-schema.vendor="openHAB Foundation e.V." \ org.label-schema.vendor="openHAB Foundation e.V." \
org.label-schema.version=$VERSION \ org.label-schema.version=$VERSION \
org.label-schema.description="An open source, technology agnostic home automation platform" \ org.label-schema.description="An open source, technology agnostic home automation platform" \
org.label-schema.url="http://www.openhab.com/" \ org.label-schema.url="http://www.openhab.com/" \
org.label-schema.vcs-ref=$VCS_REF \ org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-type="Git" \ org.label-schema.vcs-type="Git" \
org.label-schema.vcs-url="https://github.com/openhab/openhab-docker.git" \ org.label-schema.vcs-url="https://github.com/openhab/openhab-docker.git" \
maintainer="openHAB <info@openhabfoundation.org>" maintainer="openHAB <info@openhabfoundation.org>"
EOI EOI
} }
# Print basepackages for debian # Print basepackages for debian
print_basepackages() { print_basepackages() {
cat >> $1 <<-'EOI' cat >> $1 <<-'EOI'
# Install basepackages # Install basepackages
RUN apt-get update && \ RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \ DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
ca-certificates \ ca-certificates \
fontconfig \ fontconfig \
locales \ locales \
locales-all \ locales-all \
libpcap-dev \ libpcap-dev \
netbase \ netbase \
unzip \ unzip \
wget \ wget \
zip && \ zip && \
rm -rf /var/lib/apt/lists/* && \ rm -rf /var/lib/apt/lists/* && \
ln -s -f /bin/true /usr/bin/chfn ln -s -f /bin/true /usr/bin/chfn
EOI EOI
} }
# Print basepackages for alpine # Print basepackages for alpine
print_basepackages_alpine() { print_basepackages_alpine() {
cat >> $1 <<-'EOI' cat >> $1 <<-'EOI'
# Install basepackages # Install basepackages
RUN apk update && \ RUN apk update && \
apk upgrade && \ apk upgrade && \
apk add --no-cache \ apk add --no-cache \
ca-certificates \ ca-certificates \
fontconfig \ fontconfig \
ttf-dejavu \ ttf-dejavu \
libpcap-dev \ libpcap-dev \
unzip \ unzip \
dpkg \ dpkg \
gnupg \ gnupg \
wget \ wget \
bash \ bash \
shadow \ shadow \
openjdk8 \ openjdk8 \
zip \ zip \
su-exec && \ su-exec && \
rm -rf /var/cache/apk/* rm -rf /var/cache/apk/*
EOI EOI
} }
# Print 32-bit for arm64 arch # Print 32-bit for arm64 arch
print_lib32_support_arm64() { print_lib32_support_arm64() {
cat >> $1 <<-'EOI' cat >> $1 <<-'EOI'
RUN dpkg --add-architecture armhf && \ RUN dpkg --add-architecture armhf && \
apt-get update && \ apt-get update && \
apt-get install --no-install-recommends -y \ apt-get install --no-install-recommends -y \
libc6:armhf && \ libc6:armhf && \
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*
EOI EOI
} }
# Install gosu # Install gosu
print_gosu() { print_gosu() {
cat >> $1 <<-'EOI' cat >> $1 <<-'EOI'
# Install gosu # Install gosu
ENV GOSU_VERSION 1.10 ENV GOSU_VERSION 1.10
RUN set -x \ RUN set -x \
&& dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')" \ && dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')" \
&& wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch" \ && wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch" \
&& wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc" \ && wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc" \
&& export GNUPGHOME \ && export GNUPGHOME \
&& GNUPGHOME="$(mktemp -d)" \ && GNUPGHOME="$(mktemp -d)" \
&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \ && gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \
&& gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \ && gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \
&& rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc \ && rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc \
&& chmod +x /usr/local/bin/gosu && chmod +x /usr/local/bin/gosu
EOI EOI
} }
# Install java for debian # Install java for debian
print_java() { print_java() {
cat >> $1 <<-'EOI' cat >> $1 <<-'EOI'
# Install java # Install java
ENV JAVA_HOME='/usr/lib/java-8' ENV JAVA_HOME='/usr/lib/java-8'
RUN wget -nv -O /tmp/java.tar.gz ${JAVA_URL} && \ RUN wget -nv -O /tmp/java.tar.gz ${JAVA_URL} && \
mkdir ${JAVA_HOME} && \ mkdir ${JAVA_HOME} && \
tar -xvf /tmp/java.tar.gz --strip-components=1 -C ${JAVA_HOME} && \ tar -xvf /tmp/java.tar.gz --strip-components=1 -C ${JAVA_HOME} && \
rm /tmp/java.tar.gz && \ rm /tmp/java.tar.gz && \
update-alternatives --install /usr/bin/java java ${JAVA_HOME}/bin/java 50 && \ update-alternatives --install /usr/bin/java java ${JAVA_HOME}/bin/java 50 && \
update-alternatives --install /usr/bin/javac javac ${JAVA_HOME}/bin/javac 50 update-alternatives --install /usr/bin/javac javac ${JAVA_HOME}/bin/javac 50
RUN cd /tmp \ RUN cd /tmp \
&& wget https://cdn.azul.com/zcek/bin/ZuluJCEPolicies.zip \ && wget https://cdn.azul.com/zcek/bin/ZuluJCEPolicies.zip \
&& unzip -jo -d ${JAVA_HOME}/jre/lib/security /tmp/ZuluJCEPolicies.zip \ && unzip -jo -d ${JAVA_HOME}/jre/lib/security /tmp/ZuluJCEPolicies.zip \
&& rm /tmp/ZuluJCEPolicies.zip && rm /tmp/ZuluJCEPolicies.zip
EOI EOI
} }
# Install openhab for 2.0.0 and newer # Install openhab for 2.0.0 and newer
print_openhab_install() { print_openhab_install() {
cat >> $1 <<-'EOI' cat >> $1 <<-'EOI'
# Install openhab # Install openhab
# Set permissions for openhab. Export TERM variable. See issue #30 for details! # Set permissions for openhab. Export TERM variable. See issue #30 for details!
RUN wget -nv -O /tmp/openhab.zip ${OPENHAB_URL} && \ RUN wget -nv -O /tmp/openhab.zip ${OPENHAB_URL} && \
unzip -q /tmp/openhab.zip -d ${APPDIR} && \ unzip -q /tmp/openhab.zip -d ${APPDIR} && \
rm /tmp/openhab.zip && \ rm /tmp/openhab.zip && \
mkdir -p ${APPDIR}/userdata/logs && \ mkdir -p ${APPDIR}/userdata/logs && \
touch ${APPDIR}/userdata/logs/openhab.log && \ touch ${APPDIR}/userdata/logs/openhab.log && \
cp -a ${APPDIR}/userdata ${APPDIR}/userdata.dist && \ cp -a ${APPDIR}/userdata ${APPDIR}/userdata.dist && \
cp -a ${APPDIR}/conf ${APPDIR}/conf.dist && \ cp -a ${APPDIR}/conf ${APPDIR}/conf.dist && \
echo "export TERM=dumb" | tee -a ~/.bashrc echo "export TERM=dumb" | tee -a ~/.bashrc
EOI EOI
} }
# Install openhab for 1.8.3 # Install openhab for 1.8.3
print_openhab_install_old() { print_openhab_install_old() {
cat >> $1 <<-'EOI' cat >> $1 <<-'EOI'
# Install openhab # Install openhab
RUN wget -nv -O /tmp/openhab.zip ${OPENHAB_URL} && \ RUN wget -nv -O /tmp/openhab.zip ${OPENHAB_URL} && \
unzip -q /tmp/openhab.zip -d ${APPDIR} && \ unzip -q /tmp/openhab.zip -d ${APPDIR} && \
rm /tmp/openhab.zip && \ rm /tmp/openhab.zip && \
cp -a ${APPDIR}/configurations ${APPDIR}/configurations.dist && \ cp -a ${APPDIR}/configurations ${APPDIR}/configurations.dist && \
echo "export TERM=dumb" | tee -a ~/.bashrc echo "export TERM=dumb" | tee -a ~/.bashrc
EOI EOI
} }
# Add volumes for 2.0.0 and newer # Add volumes for 2.0.0 and newer
print_volumes() { print_volumes() {
cat >> $1 <<-'EOI' cat >> $1 <<-'EOI'
# Expose volume with configuration and userdata dir # Expose volume with configuration and userdata dir
VOLUME ${APPDIR}/conf ${APPDIR}/userdata ${APPDIR}/addons VOLUME ${APPDIR}/conf ${APPDIR}/userdata ${APPDIR}/addons
EOI EOI
} }
# Add volumes for 1.8.3 # Add volumes for 1.8.3
print_volumes_old() { print_volumes_old() {
cat >> $1 <<-'EOI' cat >> $1 <<-'EOI'
# Expose volume with configuration and userdata dir # Expose volume with configuration and userdata dir
VOLUME ${APPDIR}/configurations ${APPDIR}/addons VOLUME ${APPDIR}/configurations ${APPDIR}/addons
EOI EOI
} }
# Set working directory, expose and entrypoint # Set working directory, expose and entrypoint
print_entrypoint() { print_entrypoint() {
cat >> $1 <<-'EOI' cat >> $1 <<-'EOI'
# Set working directory, expose and entrypoint # Set working directory, expose and entrypoint
WORKDIR ${APPDIR} WORKDIR ${APPDIR}
EXPOSE 8080 8443 5555 EXPOSE 8080 8443 5555
COPY entrypoint.sh / COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"] ENTRYPOINT ["/entrypoint.sh"]
# Execute command # Execute command
EOI EOI
} }
# Set command # Set command
print_command() { print_command() {
case $base in case $base in
debian) debian)
cat >> $1 <<-'EOI' cat >> $1 <<-'EOI'
CMD ["gosu", "openhab", "./start.sh"] CMD ["gosu", "openhab", "./start.sh"]
EOI EOI
;; ;;
alpine) alpine)
cat >> $1 <<-'EOI' cat >> $1 <<-'EOI'
CMD ["su-exec", "openhab", "./start.sh"] CMD ["su-exec", "openhab", "./start.sh"]
EOI EOI
;; ;;
default) default)
cat >> $1 <<-'EOI' cat >> $1 <<-'EOI'
CMD ["./start.sh"] CMD ["./start.sh"]
EOI EOI
;; ;;
esac esac
} }
# Build the Dockerfiles # Build the Dockerfiles
for version in $versions for version in $versions
do do
for base in $bases for base in $bases
do do
for arch in $arches for arch in $arches
do do
file=$version/$arch/$base/Dockerfile file=$version/$arch/$base/Dockerfile
mkdir -p `dirname $file` 2>/dev/null mkdir -p $(dirname $file) 2>/dev/null
echo -n "Writing $file..." echo -n "Writing $file..."
print_header $file; print_header $file;
print_baseimage $file; print_baseimage $file;
print_basemetadata $file; print_basemetadata $file;
if [ "$base" == "alpine" ]; then if [ "$base" == "alpine" ]; then
print_basepackages_alpine $file; print_basepackages_alpine $file;
else else
print_basepackages $file; print_basepackages $file;
print_java $file; print_java $file;
print_gosu $file; print_gosu $file;
fi fi
if [ "$arch" == "arm64" ] && [ "$base" == "debian" ]; then if [ "$arch" == "arm64" ] && [ "$base" == "debian" ]; then
print_lib32_support_arm64 $file; print_lib32_support_arm64 $file;
fi fi
if [ "$version" == "1.8.3" ]; then if [ "$version" == "1.8.3" ]; then
print_openhab_install_old $file; print_openhab_install_old $file;
print_volumes_old $file print_volumes_old $file
else else
print_openhab_install $file; print_openhab_install $file;
print_volumes $file print_volumes $file
fi fi
print_entrypoint $file print_entrypoint $file
print_command $file print_command $file
dstFile=$version/$arch/$base/entrypoint.sh dstFile=$version/$arch/$base/entrypoint.sh
if [ "$base" == "alpine" ]; then if [ "$base" == "alpine" ]; then
cp entrypoint_alpine.sh $dstFile cp entrypoint_alpine.sh $dstFile
# remove bug fix for version 2 from entrypoint_alpine.sh # remove bug fix for version 2 from entrypoint_alpine.sh
if [ "$version" == "1.8.3" ]; then if [ "$version" == "1.8.3" ]; then
line=$(sed "/rm -f \/openhab\/userdata\/tmp\/instances\/instance.properties/=; d" entrypoint_alpine.sh) line=$(sed "/rm -f \/openhab\/userdata\/tmp\/instances\/instance.properties/=; d" entrypoint_alpine.sh)
sed -i "$((line-7)),${line}"d $dstFile sed -i "$((line-7)),${line}"d $dstFile
fi fi
else else
cp entrypoint_debian.sh $dstFile cp entrypoint_debian.sh $dstFile
fi fi
echo "done" echo "done"
done done
done done
done done