This repository has been archived by the owner on Feb 24, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move docker build to this repo (#473)
* dockerfile * docker build workflow * dev is built from master latest is from most recent tag * reduced platform builds * tags are prefixed with 'v' * combine latest and tag steps * move docker-compose file over * add k8s resources * mount the ozw database in k8s * update readme * hardcode the docker repo to avoid ambiguity
- Loading branch information
Showing
10 changed files
with
283 additions
and
15 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.git | ||
.github | ||
*.md | ||
docs | ||
.vscode | ||
.nyc_output | ||
.coverage | ||
pkg | ||
test |
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 |
---|---|---|
@@ -1,16 +1,50 @@ | ||
name: Trigger Docker Build | ||
name: Docker Build | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'master' | ||
branches: | ||
- master | ||
pull_request: | ||
release: | ||
types: | ||
- created | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Repository Dispatch | ||
uses: peter-evans/repository-dispatch@v1 | ||
with: | ||
token: ${{ secrets.DOCKER_REPO_TOKEN }} | ||
repository: robertsLando/Zwave2Mqtt-docker | ||
event-type: build | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Just build on PR | ||
if: ${{ github.event_name == 'pull_request' }} | ||
run: docker build . | ||
|
||
- name: Login to dockerhub | ||
if: ${{ github.event_name != 'pull_request' }} | ||
run: | | ||
docker login --username $DOCKER_USERNAME --password $DOCKER_PASSWORD | ||
env: | ||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | ||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- uses: crazy-max/ghaction-docker-buildx@v1 | ||
if: ${{ github.event_name != 'pull_request' }} | ||
|
||
- name: Dev | ||
if: ${{ github.ref == 'git/refs/heads/master'}} | ||
run: | | ||
docker buildx build \ | ||
--platform linux/arm64/v8,linux/amd64,linux/arm/v6,linux/arm/v7,linux/386 \ | ||
-t openzwave/zwave2mqtt:latest \ | ||
--push \ | ||
. | ||
- name: Latest & tag | ||
if: ${{ github.event_name == 'release' }} | ||
run: | | ||
docker buildx build \ | ||
--platform linux/arm64/v8,linux/amd64,linux/arm/v6,linux/arm/v7,linux/386 \ | ||
-t openzwave/zwave2mqtt:$(echo ${GITHUB_REF} | sed "s/git\/refs\/tags\/v//") \ | ||
-t openzwave/zwave2mqtt:latest \ | ||
--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,66 @@ | ||
# ---------------- | ||
# STEP 1: | ||
FROM node:erbium-alpine AS build | ||
|
||
ARG OPENZWAVE_GIT_SHA1=master | ||
|
||
# Install required dependencies | ||
RUN apk --no-cache add \ | ||
eudev-dev \ | ||
coreutils \ | ||
linux-headers \ | ||
alpine-sdk \ | ||
python \ | ||
openssl | ||
|
||
WORKDIR /root | ||
|
||
# need to get the full repo so that the build can reference git sha etc | ||
RUN git clone https://github.com/OpenZWave/open-zwave.git | ||
|
||
WORKDIR /root/open-zwave | ||
RUN git checkout ${OPENZWAVE_GIT_SHA1} | ||
RUN make install | ||
|
||
WORKDIR /root/Zwave2Mqtt | ||
COPY . . | ||
RUN npm config set unsafe-perm true | ||
RUN npm install | ||
RUN npm run build | ||
RUN npm prune --production | ||
RUN rm -rf \ | ||
build \ | ||
index.html \ | ||
package-lock.json \ | ||
package.sh \ | ||
src \ | ||
static \ | ||
stylesheets \ | ||
views | ||
|
||
# ---------------- | ||
# STEP 2: | ||
FROM node:erbium-alpine | ||
|
||
LABEL maintainer="robertsLando" | ||
|
||
RUN apk add --no-cache \ | ||
libstdc++ \ | ||
libgcc \ | ||
libusb \ | ||
tzdata \ | ||
eudev | ||
|
||
# Copy files from previous build stage | ||
COPY --from=build /root/open-zwave/libopenzwave.so* /lib/ | ||
COPY --from=build /root/open-zwave/config /usr/local/etc/openzwave | ||
COPY --from=build /root/Zwave2Mqtt /usr/src/app | ||
|
||
# Set enviroment | ||
ENV LD_LIBRARY_PATH /lib | ||
|
||
WORKDIR /usr/src/app | ||
|
||
EXPOSE 8091 | ||
|
||
CMD ["node", "bin/www"] |
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,22 @@ | ||
version: "3.7" | ||
services: | ||
zwave2mqtt: | ||
container_name: zwave2mqtt | ||
image: openzwave/zwave2mqtt:latest | ||
restart: always | ||
tty: true | ||
stop_signal: SIGINT | ||
networks: | ||
- zwave | ||
devices: | ||
- "/dev/ttyACM0:/dev/ttyACM0" | ||
volumes: | ||
- ./store:/usr/src/app/store | ||
ports: | ||
- "8091:8091" | ||
networks: | ||
zwave: | ||
# volumes: | ||
# zwave2mqtt: | ||
# name: zwave2mqtt | ||
|
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,71 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: zwave | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
name: zwave | ||
template: | ||
metadata: | ||
labels: | ||
name: zwave | ||
spec: | ||
containers: | ||
- name: zwave | ||
image: openzwave/zwave2mqtt:latest | ||
livenessProbe: | ||
failureThreshold: 12 | ||
httpGet: | ||
httpHeaders: | ||
- name: Accept | ||
value: text/plain | ||
path: /health | ||
port: http | ||
initialDelaySeconds: 30 | ||
periodSeconds: 10 | ||
successThreshold: 1 | ||
timeoutSeconds: 2 | ||
ports: | ||
- containerPort: 8091 | ||
name: http | ||
protocol: TCP | ||
resources: | ||
limits: | ||
cpu: "1" | ||
memory: 512Mi | ||
requests: | ||
cpu: "1" | ||
memory: 400Mi | ||
securityContext: | ||
allowPrivilegeEscalation: true | ||
privileged: true | ||
volumeMounts: | ||
- mountPath: /dev/ttyUSB1 | ||
name: zwavestick | ||
- mountPath: /usr/src/app/store | ||
name: data | ||
# - mountPath: /usr/local/etc/openzwave | ||
# name: ozwdatabase | ||
# - mountPath: /usr/src/app/store/settings.json <-- if putting your settings.json in a secret | ||
# name: config | ||
# readOnly: true | ||
# subPath: settings.json | ||
# nodeSelector: | ||
# kubernetes.io/hostname: stick1 #<--- the name of your cluster node that the zwave usb stick in | ||
volumes: | ||
# - name: config <-- if putting your settings.json in a secret | ||
# secret: | ||
# defaultMode: 420 | ||
# secretName: zwave2mqtt | ||
- name: zwavestick | ||
hostPath: | ||
path: /dev/ttyACM0 | ||
type: File | ||
- name: data | ||
hostPath: | ||
path: /zwave/data | ||
# - name: ozwdatabase | ||
# hostPath: | ||
# path: /zwave/database |
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,12 @@ | ||
apiVersion: extensions/v1beta1 | ||
kind: Ingress | ||
metadata: | ||
name: zwave | ||
spec: | ||
rules: | ||
- host: zwave.example.com | ||
http: | ||
paths: | ||
- backend: | ||
serviceName: zwave | ||
servicePort: http |
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,4 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: zwave |
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,11 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: zwave | ||
spec: | ||
ports: | ||
- name: http | ||
port: 80 | ||
targetPort: http | ||
selector: | ||
name: zwave |
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,10 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
|
||
resources: | ||
- kubernetes/namespace.yaml | ||
- kubernetes/deployment.yaml | ||
- kubernetes/service.yaml | ||
- kubernetes/ingress.yaml | ||
|
||
namespace: zwave |