Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
npm-debug.log
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM node:16

# Create app directory
WORKDIR /usr/src/app

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./

RUN npm install
# If you are building your code for production
# RUN npm ci --only=production

# Bundle app source (see .dockerignore for skipped files)
COPY . .

EXPOSE 8091

CMD [ "node", "index.js" ]


35 changes: 35 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
```text
Developed and tested with:
pi4 running Raspbian bullseye
docker version: 20.10.12 (community)
docker-compose version: 1.29.2

```

## Instructions:

### Build the docker image:
> docker-compose build

### Deploy the server in your docker environment:
> IPADDRESS=192.168.X.X ./start.sh


Replace 192.168.X.X with the IP Address that is used to reach the docker host from your Hub.

Since the docker-compose file uses the default bridge networking and the server needs to be able to tell
the Hub how to contact it, IPAddressOverride is used to set the address reported by the server.


### Stop the server:
> docker-compose down

### View server logs:
> docker-compose logs


### Additional Notes:

After building the image, you can move/copy the files from this directory to any location you wish.
The data directory will be mounted in the container and used to persist data between restarts.

1 change: 1 addition & 0 deletions docker/data/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Echo speaks server will use this directory for persistent data
16 changes: 16 additions & 0 deletions docker/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
services:
echo-speaks-server:
image: echo-speaks-server:2.7.2
build:
context: ../
container_name: echo-speaks-server
restart: always

ports:
- "8091:8091"
env_file:
- './env.echo-speaks-server'
volumes:
# Data persistency
- ./data:/mnt/es-data

Empty file added docker/env.echo-speaks-server
Empty file.
3 changes: 3 additions & 0 deletions docker/env.echo-speaks-server.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
hubPlatform=Hubitat
IPAddressOverride=IPADDRESS_TO_CHANGE
HOME=/mnt/es-data
14 changes: 14 additions & 0 deletions docker/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

if [[ (-z "${IPADDRESS}") ]]; then
echo "Please set IPADDRESS environment variables"
echo "example: IPADDRESS=192.168.1.100 ./start.sh"
exit 1
fi

if [ $(grep -c "IPADDRESS_TO_CHANGE" env.echo-speaks-server.dist) -ne 0 ]; then
sed "s/IPADDRESS_TO_CHANGE/$IPADDRESS/g" env.echo-speaks-server.dist > env.echo-speaks-server
fi

echo "Starting docker-compose"
docker-compose up -d
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,10 @@ function getCookiesFromEndpoint(url) {
********************************************************************************/

function getIPAddress() {
if (process.env.IPAddressOverride) {
return process.env.IPAddressOverride;
}

let interfaces = os.networkInterfaces();
for (const devName in interfaces) {
let iface = interfaces[devName];
Expand Down