-
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from cyberkov/dockerize-openhab
New Dockerfile and update on Readme
- Loading branch information
Showing
7 changed files
with
245 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ release.properties | |
dependency-reduced-pom.xml | ||
buildNumber.properties | ||
.mvn/timing.properties | ||
/tmp-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
sudo: required | ||
language: bash | ||
branches: | ||
only: | ||
- master | ||
services: | ||
- docker | ||
before_install: | ||
- docker info | ||
- docker run --rm --privileged multiarch/qemu-user-static:register --reset | ||
- docker login -e="$DOCKER_EMAIL" -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" | ||
env: | ||
#global: | ||
# - DOCKER_REPO=openhab/openhab | ||
# Encrypted: | ||
# - DOCKER_EMAIL | ||
# - DOCKER_USERNAME | ||
# - DOCKER_PASSWORD | ||
matrix: | ||
- TARGET=amd64 FLAVOR=online | ||
- TARGET=amd64 FLAVOR=offline | ||
- TARGET=armhf FLAVOR=online | ||
- TARGET=armhf FLAVOR=offline | ||
- TARGET=arm64 FLAVOR=online | ||
- TARGET=arm64 FLAVOR=offline | ||
matrix: | ||
fast_finish: true | ||
script: | ||
- make build && (make push || (sleep 15; make push) || (sleep 15; make push)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# openhab image | ||
FROM multiarch/ubuntu-debootstrap:amd64-wily | ||
#FROM multiarch/ubuntu-debootstrap:armhf-wily # arch=armhf | ||
#FROM multiarch/ubuntu-debootstrap:arm64-wily # arch=arm64 | ||
ARG ARCH=amd64 | ||
|
||
ARG DOWNLOAD_URL="https://openhab.ci.cloudbees.com/job/openHAB-Distribution/lastSuccessfulBuild/artifact/distributions/openhab-online/target/openhab-online-2.0.0-SNAPSHOT.zip" | ||
ENV APPDIR="/openhab" OPENHAB_HTTP_PORT='8080' OPENHAB_HTTPS_PORT='8443' EXTRA_JAVA_OPTS='' | ||
|
||
# Install Basepackages | ||
RUN \ | ||
apt-get update && \ | ||
apt-get install --no-install-recommends -y \ | ||
software-properties-common \ | ||
sudo \ | ||
unzip \ | ||
wget \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Install Oracle Java | ||
RUN \ | ||
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && \ | ||
add-apt-repository -y ppa:webupd8team/java && \ | ||
apt-get update && \ | ||
apt-get install --no-install-recommends -y oracle-java8-installer && \ | ||
rm -rf /var/lib/apt/lists/* && \ | ||
rm -rf /var/cache/oracle-jdk8-installer | ||
ENV JAVA_HOME /usr/lib/jvm/java-8-oracle | ||
|
||
# Add openhab user | ||
RUN adduser --disabled-password --gecos '' --home ${APPDIR} openhab &&\ | ||
adduser openhab sudo &&\ | ||
adduser openhab dialout &&\ | ||
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/openhab | ||
|
||
WORKDIR ${APPDIR} | ||
|
||
RUN \ | ||
wget -nv -O /tmp/openhab.zip ${DOWNLOAD_URL} &&\ | ||
unzip -q /tmp/openhab.zip -d ${APPDIR} &&\ | ||
rm /tmp/openhab.zip | ||
|
||
RUN mkdir -p ${APPDIR}/userdata/logs && touch ${APPDIR}/userdata/logs/openhab.log | ||
|
||
# Copy directories for host volumes | ||
RUN cp -a /openhab/userdata /openhab/userdata.dist && \ | ||
cp -a /openhab/conf /openhab/conf.dist | ||
COPY files/entrypoint.sh / | ||
ENTRYPOINT ["/entrypoint.sh"] | ||
|
||
RUN chown -R openhab:openhab ${APPDIR} | ||
USER openhab | ||
# Expose volume with configuration and userdata dir | ||
VOLUME ${APPDIR}/conf ${APPDIR}/userdata ${APPDIR}/addons | ||
EXPOSE 8080 8443 5555 | ||
CMD server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
TARGET ?= amd64 | ||
ARCHS ?= amd64 armhf arm64 | ||
BASE_ARCH ?= amd64 | ||
DOCKER_REPO ?= openhab/openhab | ||
GIT_REPO ?= openhab/openhab-docker | ||
GIT_BRANCH ?= master | ||
FLAVOR ?= online | ||
TRAVIS_TOKEN ?= secretsecret | ||
|
||
ifeq ($(FLAVOR),offline) | ||
DOWNLOAD_URL="https://openhab.ci.cloudbees.com/job/openHAB-Distribution/lastSuccessfulBuild/artifact/distributions/openhab-offline/target/openhab-offline-2.0.0-SNAPSHOT.zip" | ||
else | ||
DOWNLOAD_URL="https://openhab.ci.cloudbees.com/job/openHAB-Distribution/lastSuccessfulBuild/artifact/distributions/openhab-online/target/openhab-online-2.0.0-SNAPSHOT.zip" | ||
endif | ||
|
||
build: tmp-$(TARGET)/Dockerfile | ||
docker build --build-arg ARCH=$(TARGET) --build-arg DOWNLOAD_URL=$(DOWNLOAD_URL) -t $(DOCKER_REPO):$(TARGET)-$(FLAVOR) tmp-$(TARGET) | ||
docker run --rm $(DOCKER_REPO):$(TARGET)-$(FLAVOR) uname -a | ||
|
||
tmp-$(TARGET)/Dockerfile: Dockerfile $(shell find files) | ||
rm -rf tmp-$(TARGET) | ||
mkdir tmp-$(TARGET) | ||
cp Dockerfile $@ | ||
cp -rf files tmp-$(TARGET)/ | ||
for arch in $(ARCHS); do \ | ||
if [ "$$arch" != "$(TARGET)" ]; then \ | ||
sed -i "/arch=$$arch/d" $@; \ | ||
fi; \ | ||
done | ||
sed -i '/#[[:space:]]*arch=$(TARGET)/s/^#//' $@ | ||
sed -i 's/#[[:space:]]*arch=$(TARGET)//g' $@ | ||
cat $@ | ||
|
||
test: | ||
env IMAGE="$(DOCKER_REPO):$(TARGET)-$(FLAVOR)" \ | ||
bundle exec rspec | ||
|
||
clean: | ||
for arch in $(ARCHS); do \ | ||
rm -rf tmp-$$arch; \ | ||
done | ||
|
||
push: | ||
docker push $(DOCKER_REPO):$(TARGET)-$(FLAVOR) | ||
|
||
trigger: | ||
@curl -s -X POST \ | ||
-H "Content-Type: application/json" \ | ||
-H "Accept: application/json" \ | ||
-H "Travis-API-Version: 3" \ | ||
-H "Authorization: token $(TRAVIS_TOKEN)" \ | ||
-d '{ "request": { "branch":"$(GIT_BRANCH)", "token": "$(TRAVIS_TOKEN)" }}' \ | ||
https://api.travis-ci.org/repo/$(subst /,%2F,$(GIT_REPO))/requests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
openHAB - a vendor and technology agnostic open source automation software for your home. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash -x | ||
set -euo pipefail | ||
IFS=$'\n\t' | ||
|
||
# Initialize empty host volumes | ||
if [ -z "$(ls -A "${APPDIR}/userdata")" ]; then | ||
# Copy userdata dir | ||
echo "No userdata found... initializing." | ||
sudo cp -av "${APPDIR}/userdata.dist/." "${APPDIR}/userdata/" | ||
fi | ||
|
||
if [ -z "$(ls -A "${APPDIR}/conf")" ]; then | ||
# Copy userdata dir | ||
echo "No configuration found... initializing." | ||
sudo cp -av "${APPDIR}/conf.dist/. ${APPDIR}/conf/" | ||
fi | ||
|
||
# Prettier interface | ||
if [ "$1" = 'server' ] || [ "$1" = 'openhab' ]; then | ||
eval "${APPDIR}/start.sh" | ||
elif [ "$1" = 'debug' ]; then | ||
eval "${APPDIR}/start_debug.sh" | ||
else | ||
exec "$@" | ||
fi | ||
|