Skip to content

Commit

Permalink
New Dockerfile and update on Readme
Browse files Browse the repository at this point in the history
Signed-off-by: Hannes Schaller <admin@cyberkov.at> (github: cyberkov)
  • Loading branch information
cyberkov committed Mar 1, 2016
1 parent 7302d1d commit 2257afd
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
46 changes: 46 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# openhab image for x86
FROM ubuntu:trusty

RUN \
apt-get update && \
apt-get install -y wget unzip software-properties-common && \
rm -rf /var/lib/apt/lists/*

# Install dockerize
RUN \
wget -nv https://github.com/jwilder/dockerize/releases/download/v0.2.0/dockerize-linux-amd64-v0.2.0.tar.gz &&\
tar -C /usr/local/bin -xzvf dockerize-linux-amd64-v0.2.0.tar.gz &&\
rm dockerize-linux-amd64-v0.2.0.tar.gz

# 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 -y oracle-java8-installer && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /var/cache/oracle-jdk8-installer

ENV DOWNLOAD_URL="https://openhab.ci.cloudbees.com/job/openHAB-Distribution/lastSuccessfulBuild/artifact/distributions/openhab-online/target/openhab-online-2.0.0-SNAPSHOT.zip" \
APPDIR="/openhab"

# 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

USER 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
# Expose volume with configuration and userdata dir
VOLUME ${APPDIR}/conf ${APPDIR}/userdata
EXPOSE 8080 8443 5555
CMD dockerize -stdout ${APPDIR}/userdata/logs/openhab.log ${APPDIR}/start.sh server
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,35 @@
# openhab-docker
Repository for building docker containers for openHAB

## Usage

```
docker run \
--name openhab \
--net=host \
-v /etc/localtime:/etc/localtime:ro \
-v /opt/openhab/conf:/openhab/conf \
-v /opt/openhab/userdata:/openhab/userdata \
openhab/openhab
```

or with docker-compose.yml
```
openhab:
image: 'openhab/openhab'
net: "host"
volumes:
- '/etc/localtime:/etc/localtime:ro'
- '/opt/openhab/conf:/openhab/conf'
- '/opt/openhab/userdata:/openhab/userdata'
devices:
- '/dev/ttyUSB0'
```
then start with ```docker-compose up -d```

**Parameters**

* `-p 8080` - the port of the webinterface
* `-v /openhab/conf` - openhab configs
* `-v /openhab/userdata` - openhab userdata directory
* `--device=/dev/ttyUSB0` - attach your devices like RFXCOM or Z-Wave Sticks to the conatiner

0 comments on commit 2257afd

Please sign in to comment.