Skip to content

Commit 7d8ed6e

Browse files
committed
Adding OH 2.3.0 dockerfile
1 parent 6c4dc08 commit 7d8ed6e

File tree

8 files changed

+666
-0
lines changed

8 files changed

+666
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# openhab image
2+
#
3+
# ------------------------------------------------------------------------------
4+
# NOTE: THIS DOCKERFILE IS GENERATED VIA "update.sh"
5+
#
6+
# PLEASE DO NOT EDIT IT DIRECTLY.
7+
# ------------------------------------------------------------------------------
8+
#
9+
FROM multiarch/alpine:arm64-v3.7
10+
11+
# Set download urls
12+
ENV JAVA_URL="https://www.azul.com/downloads/zulu/zdk-8-ga-linux_aarch32hf.tar.gz" OPENHAB_URL="https://openhab.ci.cloudbees.com/job/openHAB-Distribution/lastSuccessfulBuild/artifact/distributions/openhab/target/openhab-2.3.0-SNAPSHOT.zip" OPENHAB_VERSION="2.3.0-snapshot"
13+
14+
# Set variables and locales
15+
ENV \
16+
APPDIR="/openhab" \
17+
EXTRA_JAVA_OPTS="" \
18+
OPENHAB_HTTP_PORT="8080" \
19+
OPENHAB_HTTPS_PORT="8443" \
20+
LC_ALL=en_US.UTF-8 \
21+
LANG=en_US.UTF-8 \
22+
LANGUAGE=en_US.UTF-8
23+
24+
# Set arguments on build
25+
ARG BUILD_DATE
26+
ARG VCS_REF
27+
ARG VERSION
28+
29+
# Basic build-time metadata as defined at http://label-schema.org
30+
LABEL org.label-schema.build-date=$BUILD_DATE \
31+
org.label-schema.docker.dockerfile="/Dockerfile" \
32+
org.label-schema.license="EPL" \
33+
org.label-schema.name="openHAB" \
34+
org.label-schema.vendor="openHAB Foundation e.V." \
35+
org.label-schema.version=$VERSION \
36+
org.label-schema.description="An open source, technology agnostic home automation platform" \
37+
org.label-schema.url="http://www.openhab.com/" \
38+
org.label-schema.vcs-ref=$VCS_REF \
39+
org.label-schema.vcs-type="Git" \
40+
org.label-schema.vcs-url="https://github.com/openhab/openhab-docker.git" \
41+
maintainer="openHAB <info@openhabfoundation.org>"
42+
43+
# Install basepackages
44+
RUN apk update && \
45+
apk upgrade && \
46+
apk add --no-cache \
47+
ca-certificates \
48+
fontconfig \
49+
ttf-dejavu \
50+
libpcap-dev \
51+
unzip \
52+
dpkg \
53+
gnupg \
54+
wget \
55+
bash \
56+
shadow \
57+
openjdk8 \
58+
zip \
59+
su-exec && \
60+
rm -rf /var/cache/apk/*
61+
62+
# Install openhab
63+
# Set permissions for openhab. Export TERM variable. See issue #30 for details!
64+
RUN wget -nv -O /tmp/openhab.zip ${OPENHAB_URL} && \
65+
unzip -q /tmp/openhab.zip -d ${APPDIR} && \
66+
rm /tmp/openhab.zip && \
67+
mkdir -p ${APPDIR}/userdata/logs && \
68+
touch ${APPDIR}/userdata/logs/openhab.log && \
69+
cp -a ${APPDIR}/userdata ${APPDIR}/userdata.dist && \
70+
cp -a ${APPDIR}/conf ${APPDIR}/conf.dist && \
71+
echo "export TERM=dumb" | tee -a ~/.bashrc
72+
73+
# Expose volume with configuration and userdata dir
74+
VOLUME ${APPDIR}/conf ${APPDIR}/userdata ${APPDIR}/addons
75+
76+
# Set working directory, expose and entrypoint
77+
WORKDIR ${APPDIR}
78+
EXPOSE 8080 8443 5555
79+
COPY entrypoint.sh /
80+
RUN chmod +x /entrypoint.sh
81+
ENTRYPOINT ["/entrypoint.sh"]
82+
83+
# Execute command
84+
#CMD ["/entrypoint.sh", "su-exec", "openhab", "./start.sh"]
85+
CMD ["su-exec", "openhab", "./start.sh"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/sh -x
2+
# It was like this: !/bin/sh -x
3+
4+
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
5+
test -t 0
6+
if [ $? -eq 1 ]; then
7+
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
8+
exit 1
9+
fi
10+
11+
set -euo pipefail
12+
IFS=$'\n\t'
13+
14+
# Deleting instance.properties to avoid karaf PID conflict on restart
15+
# See: https://github.com/openhab/openhab-docker/issues/99
16+
rm -f /openhab/runtime/instances/instance.properties
17+
18+
# The instance.properties file in OH2.x is installed in the tmp
19+
# directory
20+
rm -f /openhab/userdata/tmp/instances/instance.properties
21+
22+
# Add openhab user & handle possible device groups for different host systems
23+
# Container base image puts dialout on group id 20, uucp on id 10
24+
# GPIO Group for RPI access
25+
NEW_USER_ID=${USER_ID:-9001}
26+
echo "Starting with openhab user id: $NEW_USER_ID"
27+
if ! id -u openhab >/dev/null 2>&1; then
28+
echo "Create user openhab with id 9001"
29+
adduser -u $NEW_USER_ID -D -g '' -h ${APPDIR} openhab
30+
fi
31+
32+
# Copy initial files to host volume
33+
case ${OPENHAB_VERSION} in
34+
1.8.3)
35+
if [ -z "$(ls -A "${APPDIR}/configurations")" ]; then
36+
# Copy userdata dir for version 1.8.3
37+
echo "No configuration found... initializing."
38+
cp -av "${APPDIR}/configurations.dist/." "${APPDIR}/configurations/"
39+
fi
40+
;;
41+
2.0.0|2.1.0|2.2.0|2.3.0-snapshot)
42+
# Initialize empty host volumes
43+
if [ -z "$(ls -A "${APPDIR}/userdata")" ]; then
44+
# Copy userdata dir for version 2.0.0
45+
echo "No userdata found... initializing."
46+
cp -av "${APPDIR}/userdata.dist/." "${APPDIR}/userdata/"
47+
fi
48+
49+
if [ -z "$(ls -A "${APPDIR}/conf")" ]; then
50+
# Copy userdata dir for version 2.0.0
51+
echo "No configuration found... initializing."
52+
cp -av "${APPDIR}/conf.dist/." "${APPDIR}/conf/"
53+
fi
54+
;;
55+
*)
56+
echo openHAB version ${OPENHAB_VERSION} not supported!
57+
;;
58+
esac
59+
60+
# Set openhab folder permission
61+
chown -R openhab:openhab ${APPDIR}
62+
63+
exec "$@"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# openhab image
2+
#
3+
# ------------------------------------------------------------------------------
4+
# NOTE: THIS DOCKERFILE IS GENERATED VIA "update.sh"
5+
#
6+
# PLEASE DO NOT EDIT IT DIRECTLY.
7+
# ------------------------------------------------------------------------------
8+
#
9+
FROM multiarch/debian-debootstrap:arm64-jessie
10+
11+
# Set download urls
12+
ENV JAVA_URL="https://www.azul.com/downloads/zulu/zdk-8-ga-linux_aarch32hf.tar.gz" OPENHAB_URL="https://openhab.ci.cloudbees.com/job/openHAB-Distribution/lastSuccessfulBuild/artifact/distributions/openhab/target/openhab-2.3.0-SNAPSHOT.zip" OPENHAB_VERSION="2.3.0-snapshot"
13+
14+
# Set variables and locales
15+
ENV \
16+
APPDIR="/openhab" \
17+
EXTRA_JAVA_OPTS="" \
18+
OPENHAB_HTTP_PORT="8080" \
19+
OPENHAB_HTTPS_PORT="8443" \
20+
LC_ALL=en_US.UTF-8 \
21+
LANG=en_US.UTF-8 \
22+
LANGUAGE=en_US.UTF-8
23+
24+
# Set arguments on build
25+
ARG BUILD_DATE
26+
ARG VCS_REF
27+
ARG VERSION
28+
29+
# Basic build-time metadata as defined at http://label-schema.org
30+
LABEL org.label-schema.build-date=$BUILD_DATE \
31+
org.label-schema.docker.dockerfile="/Dockerfile" \
32+
org.label-schema.license="EPL" \
33+
org.label-schema.name="openHAB" \
34+
org.label-schema.vendor="openHAB Foundation e.V." \
35+
org.label-schema.version=$VERSION \
36+
org.label-schema.description="An open source, technology agnostic home automation platform" \
37+
org.label-schema.url="http://www.openhab.com/" \
38+
org.label-schema.vcs-ref=$VCS_REF \
39+
org.label-schema.vcs-type="Git" \
40+
org.label-schema.vcs-url="https://github.com/openhab/openhab-docker.git" \
41+
maintainer="openHAB <info@openhabfoundation.org>"
42+
43+
# Install basepackages
44+
RUN apt-get update && \
45+
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
46+
ca-certificates \
47+
fontconfig \
48+
locales \
49+
locales-all \
50+
libpcap-dev \
51+
netbase \
52+
unzip \
53+
wget \
54+
zip && \
55+
rm -rf /var/lib/apt/lists/* && \
56+
ln -s -f /bin/true /usr/bin/chfn
57+
58+
# Install java
59+
ENV JAVA_HOME='/usr/lib/java-8'
60+
RUN wget -nv -O /tmp/java.tar.gz ${JAVA_URL} && \
61+
mkdir ${JAVA_HOME} && \
62+
tar -xvf /tmp/java.tar.gz --strip-components=1 -C ${JAVA_HOME} && \
63+
rm /tmp/java.tar.gz && \
64+
update-alternatives --install /usr/bin/java java ${JAVA_HOME}/bin/java 50 && \
65+
update-alternatives --install /usr/bin/javac javac ${JAVA_HOME}/bin/javac 50
66+
RUN cd /tmp \
67+
&& wget https://cdn.azul.com/zcek/bin/ZuluJCEPolicies.zip \
68+
&& unzip -jo -d ${JAVA_HOME}/jre/lib/security /tmp/ZuluJCEPolicies.zip \
69+
&& rm /tmp/ZuluJCEPolicies.zip
70+
71+
# Install gosu
72+
ENV GOSU_VERSION 1.10
73+
RUN set -x \
74+
&& dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')" \
75+
&& wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch" \
76+
&& wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc" \
77+
&& export GNUPGHOME \
78+
&& GNUPGHOME="$(mktemp -d)" \
79+
&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \
80+
&& gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \
81+
&& rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc \
82+
&& chmod +x /usr/local/bin/gosu
83+
84+
RUN dpkg --add-architecture armhf && \
85+
apt-get update && \
86+
apt-get install --no-install-recommends -y \
87+
libc6:armhf && \
88+
rm -rf /var/lib/apt/lists/*
89+
90+
# Install openhab
91+
# Set permissions for openhab. Export TERM variable. See issue #30 for details!
92+
RUN wget -nv -O /tmp/openhab.zip ${OPENHAB_URL} && \
93+
unzip -q /tmp/openhab.zip -d ${APPDIR} && \
94+
rm /tmp/openhab.zip && \
95+
mkdir -p ${APPDIR}/userdata/logs && \
96+
touch ${APPDIR}/userdata/logs/openhab.log && \
97+
cp -a ${APPDIR}/userdata ${APPDIR}/userdata.dist && \
98+
cp -a ${APPDIR}/conf ${APPDIR}/conf.dist && \
99+
echo "export TERM=dumb" | tee -a ~/.bashrc
100+
101+
# Expose volume with configuration and userdata dir
102+
VOLUME ${APPDIR}/conf ${APPDIR}/userdata ${APPDIR}/addons
103+
104+
# Set working directory, expose and entrypoint
105+
WORKDIR ${APPDIR}
106+
EXPOSE 8080 8443 5555
107+
COPY entrypoint.sh /
108+
RUN chmod +x /entrypoint.sh
109+
ENTRYPOINT ["/entrypoint.sh"]
110+
111+
# Execute command
112+
CMD ["gosu", "openhab", "./start.sh"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/bash -x
2+
3+
# Karaf needs a pseudo-TTY so exit and instruct user to allocate one when necessary
4+
test -t 0
5+
if [ $? -eq 1 ]; then
6+
echo "Please start the openHAB container with a pseudo-TTY using the -t option or 'tty: true' with docker compose"
7+
exit 1
8+
fi
9+
10+
set -euo pipefail
11+
IFS=$'\n\t'
12+
13+
# Deleting instance.properties to avoid karaf PID conflict on restart
14+
# See: https://github.com/openhab/openhab-docker/issues/99
15+
rm -f /openhab/runtime/instances/instance.properties
16+
17+
# The instance.properties file in OH2.x is installed in the tmp
18+
# directory
19+
rm -f /openhab/userdata/tmp/instances/instance.properties
20+
21+
# Add openhab user & handle possible device groups for different host systems
22+
# Container base image puts dialout on group id 20, uucp on id 10
23+
# GPIO Group for RPI access
24+
NEW_USER_ID=${USER_ID:-9001}
25+
NEW_GROUP_ID=${GROUP_ID:-$NEW_USER_ID}
26+
echo "Starting with openhab user id: $NEW_USER_ID and group id: $NEW_GROUP_ID"
27+
if ! id -u openhab >/dev/null 2>&1; then
28+
echo "Create group openhab with id ${NEW_GROUP_ID}"
29+
groupadd -g $NEW_GROUP_ID openhab
30+
echo "Create user openhab with id ${NEW_USER_ID}"
31+
adduser -u $NEW_USER_ID --disabled-password --gecos '' --home ${APPDIR} --gid $NEW_GROUP_ID openhab
32+
groupadd -g 14 uucp2
33+
groupadd -g 16 dialout2
34+
groupadd -g 18 dialout3
35+
groupadd -g 32 uucp3
36+
groupadd -g 997 gpio
37+
adduser openhab dialout
38+
adduser openhab uucp
39+
adduser openhab uucp2
40+
adduser openhab dialout2
41+
adduser openhab dialout3
42+
adduser openhab uucp3
43+
adduser openhab gpio
44+
fi
45+
46+
# Copy initial files to host volume
47+
case ${OPENHAB_VERSION} in
48+
1.8.3)
49+
if [ -z "$(ls -A "${APPDIR}/configurations")" ]; then
50+
# Copy userdata dir for version 1.8.3
51+
echo "No configuration found... initializing."
52+
cp -av "${APPDIR}/configurations.dist/." "${APPDIR}/configurations/"
53+
fi
54+
;;
55+
2.0.0|2.1.0|2.2.0|2.3.0-snapshot)
56+
# Initialize empty host volumes
57+
if [ -z "$(ls -A "${APPDIR}/userdata")" ]; then
58+
# Copy userdata dir for version 2.0.0
59+
echo "No userdata found... initializing."
60+
cp -av "${APPDIR}/userdata.dist/." "${APPDIR}/userdata/"
61+
fi
62+
63+
if [ -z "$(ls -A "${APPDIR}/conf")" ]; then
64+
# Copy userdata dir for version 2.0.0
65+
echo "No configuration found... initializing."
66+
cp -av "${APPDIR}/conf.dist/." "${APPDIR}/conf/"
67+
fi
68+
;;
69+
*)
70+
echo openHAB version ${OPENHAB_VERSION} not supported!
71+
;;
72+
esac
73+
74+
# Set openhab folder permission
75+
chown -R openhab:openhab ${APPDIR}
76+
77+
exec "$@"

0 commit comments

Comments
 (0)