From 8234beef958eacf2d20e364656ea46004c37c4dd Mon Sep 17 00:00:00 2001 From: Marcio Granzotto Date: Fri, 26 Mar 2021 11:43:58 -0300 Subject: [PATCH 1/7] Add a devcontainer for better development on Windows --- .devcontainer/Dockerfile | 20 ++++++++++++++++++ .devcontainer/devcontainer.json | 37 +++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..e3bb5ce --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,20 @@ +#------------------------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. +#------------------------------------------------------------------------------------------------------------- + +# Update the VARIANT arg in devcontainer.json to pick an Ubuntu version: focal (or ubuntu-20.04), bionic (or ubuntu-18.04) +# To fully customize the contents of this image, use the following Dockerfile instead: +# https://github.com/microsoft/vscode-dev-containers/tree/v0.128.0/containers/ubuntu/.devcontainer/base.Dockerfile +ARG VARIANT="focal" +FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT} + +# ** [Optional] Uncomment this section to install additional packages. ** +# +# RUN apt-get update \ +# && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends + +ARG HADOLINT_VERSION=v1.17.6 +RUN wget -O /usr/local/bin/hadolint https://github.com/hadolint/hadolint/releases/download/${HADOLINT_VERSION}/hadolint-Linux-x86_64 \ + && chmod +x /usr/local/bin/hadolint \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..d6e3850 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,37 @@ +// For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.128.0/containers/ubuntu +{ + "name": "Ubuntu", + "build": { + "dockerfile": "Dockerfile", + // Update 'VARIANT' to pick an Ubuntu version. Rebuild the container if it already + // exists to update. Available variants: focal (or ubuntu-20.04), bionic (or ubuntu-18.04) + "args": { "VARIANT": "focal" } + }, + + // Set *default* container specific settings.json values on container create. + "settings": { + "terminal.integrated.shell.linux": "/bin/bash" + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "exiasr.hadolint", + "omartawfik.github-actions-vscode" + ], + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "git config --global core.autocrlf true" + + // Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker. + // "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ], + + // Uncomment when using a ptrace-based debugger like C++, Go, and Rust + // "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ], + + // Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root. + // "remoteUser": "vscode" +} \ No newline at end of file From f5c0f239f4d240d7cfd0249e88b1c124f08e4ec1 Mon Sep 17 00:00:00 2001 From: Marcio Granzotto Date: Fri, 26 Mar 2021 11:44:50 -0300 Subject: [PATCH 2/7] Migrate project to a hassio add-on --- .gitattributes | 3 + .yamllint | 64 +++++++++++++++++++ Dockerfile | 27 -------- docker-compose.yml | 23 ------- lovelace-kindle-screensaver/Dockerfile | 50 +++++++++++++++ lovelace-kindle-screensaver/build.json | 11 ++++ lovelace-kindle-screensaver/config.json | 59 +++++++++++++++++ .../rootfs/app/config.js | 0 .../rootfs/app/index.js | 0 .../rootfs/app/package-lock.json | 0 .../rootfs/app/package.json | 0 .../rootfs/etc/services.d/node/finish | 0 .../rootfs/etc/services.d/node/run | 20 ++++++ .../lovelace-eink-theme.yml | 0 14 files changed, 207 insertions(+), 50 deletions(-) create mode 100644 .gitattributes create mode 100644 .yamllint delete mode 100644 Dockerfile delete mode 100644 docker-compose.yml create mode 100644 lovelace-kindle-screensaver/Dockerfile create mode 100644 lovelace-kindle-screensaver/build.json create mode 100644 lovelace-kindle-screensaver/config.json rename config.js => lovelace-kindle-screensaver/rootfs/app/config.js (100%) rename index.js => lovelace-kindle-screensaver/rootfs/app/index.js (100%) rename package-lock.json => lovelace-kindle-screensaver/rootfs/app/package-lock.json (100%) rename package.json => lovelace-kindle-screensaver/rootfs/app/package.json (100%) create mode 100644 lovelace-kindle-screensaver/rootfs/etc/services.d/node/finish create mode 100644 lovelace-kindle-screensaver/rootfs/etc/services.d/node/run rename lovelace-eink-theme.yml => theme/lovelace-eink-theme.yml (100%) diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..5dc46e6 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +* text=auto eol=lf +*.{cmd,[cC][mM][dD]} text eol=crlf +*.{bat,[bB][aA][tT]} text eol=crlf \ No newline at end of file diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..0a2a889 --- /dev/null +++ b/.yamllint @@ -0,0 +1,64 @@ +--- +rules: + braces: + level: error + min-spaces-inside: 0 + max-spaces-inside: 1 + min-spaces-inside-empty: -1 + max-spaces-inside-empty: -1 + brackets: + level: error + min-spaces-inside: 0 + max-spaces-inside: 0 + min-spaces-inside-empty: -1 + max-spaces-inside-empty: -1 + colons: + level: error + max-spaces-before: 0 + max-spaces-after: 1 + commas: + level: error + max-spaces-before: 0 + min-spaces-after: 1 + max-spaces-after: 1 + comments: + level: error + require-starting-space: true + min-spaces-from-content: 2 + comments-indentation: + level: error + document-end: + level: error + present: false + document-start: + level: error + present: true + empty-lines: + level: error + max: 1 + max-start: 0 + max-end: 1 + hyphens: + level: error + max-spaces-after: 1 + indentation: + level: error + spaces: 2 + indent-sequences: true + check-multi-line-strings: false + key-duplicates: + level: error + line-length: + level: warning + max: 120 + allow-non-breakable-words: true + allow-non-breakable-inline-mappings: true + new-line-at-end-of-file: + level: error + new-lines: + level: error + type: unix + trailing-spaces: + level: error + truthy: + level: error diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 0dc7297..0000000 --- a/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ -FROM node:12-alpine - -WORKDIR /app - -RUN apk add --no-cache \ - chromium \ - nss \ - freetype \ - freetype-dev \ - harfbuzz \ - ca-certificates \ - ttf-freefont \ - imagemagick - -ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \ - PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser \ - USE_IMAGE_MAGICK=true - -COPY package*.json ./ - -RUN npm ci - -COPY . . - -EXPOSE 5000 - -CMD ["npm", "start"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 1da0140..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,23 +0,0 @@ -version: "3.8" - -services: - app: - image: sibbl/hass-lovelace-kindle-screensaver:latest - environment: - - HA_BASE_URL=https://your-path-to-home-assistant:8123 - - HA_SCREENSHOT_URL=/lovelace?kiosk - - HA_ACCESS_TOKEN=eyJ0... - - CRON_JOB=* * * * * - - RENDERING_TIMEOUT=30000 - - RENDERING_DELAY=0 - - RENDERING_SCREEN_HEIGHT=800 - - RENDERING_SCREEN_WIDTH=600 - - GRAYSCALE_DEPTH=8 - - OUTPUT_PATH=/output/cover.png - - LANGUAGE=en - - ROTATION=0 - - SCALING=1 - ports: - - 5000:5000 - volumes: - - ./output/:/output diff --git a/lovelace-kindle-screensaver/Dockerfile b/lovelace-kindle-screensaver/Dockerfile new file mode 100644 index 0000000..c52d68f --- /dev/null +++ b/lovelace-kindle-screensaver/Dockerfile @@ -0,0 +1,50 @@ +ARG BUILD_FROM +# hadolint ignore=DL3006 +FROM ${BUILD_FROM} + +WORKDIR /app + +RUN apk add --no-cache \ + chromium=86.0.4240.111-r0 \ + nss=3.60.1-r0 \ + freetype=2.10.4-r1 \ + freetype-dev=2.10.4-r1 \ + harfbuzz=2.7.4-r1 \ + ca-certificates=20191127-r5 \ + ttf-freefont=20120503-r1 \ + imagemagick=7.0.10.57-r0 \ + nodejs=14.16.0-r0 \ + npm=14.16.0-r0 + +ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \ + PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser \ + USE_IMAGE_MAGICK=true + +# Copy root filesystem +COPY rootfs / + +RUN npm ci + +# Build arugments +ARG BUILD_ARCH +ARG BUILD_DATE +ARG BUILD_REF +ARG BUILD_VERSION + +# Labels +LABEL \ + io.hass.name="Lovelace Kindle Screensaver" \ + io.hass.description="Display a lovelace page as a screensaver on a jailbroken Kindle" \ + io.hass.arch="${BUILD_ARCH}" \ + io.hass.type="addon" \ + io.hass.version=${BUILD_VERSION} \ + maintainer="Marcio Granzotto " \ + org.opencontainers.image.title="Transmission" \ + org.opencontainers.image.description="Display a lovelace page as a screensaver on a jailbroken Kindle" \ + org.opencontainers.image.vendor="Marcio Granzotto" \ + org.opencontainers.image.authors="Marcio Granzotto " \ + org.opencontainers.image.source="https://github.com/sibbl/hass-lovelace-kindle-screensaver" \ + org.opencontainers.image.documentation="https://github.com/sibbl/hass-lovelace-kindle-screensaver/blob/master/README.md" \ + org.opencontainers.image.created=${BUILD_DATE} \ + org.opencontainers.image.revision=${BUILD_REF} \ + org.opencontainers.image.version=${BUILD_VERSION} diff --git a/lovelace-kindle-screensaver/build.json b/lovelace-kindle-screensaver/build.json new file mode 100644 index 0000000..b3f736c --- /dev/null +++ b/lovelace-kindle-screensaver/build.json @@ -0,0 +1,11 @@ +{ + "squash": false, + "build_from": { + "aarch64": "ghcr.io/hassio-addons/base/aarch64:9.1.5", + "amd64": "ghcr.io/hassio-addons/base/amd64:9.1.5", + "armhf": "ghcr.io/hassio-addons/base/armhf:9.1.5", + "armv7": "ghcr.io/hassio-addons/base/armv7:9.1.5", + "i386": "ghcr.io/hassio-addons/base/i386:9.1.5" + }, + "args": {} +} diff --git a/lovelace-kindle-screensaver/config.json b/lovelace-kindle-screensaver/config.json new file mode 100644 index 0000000..0ec8d09 --- /dev/null +++ b/lovelace-kindle-screensaver/config.json @@ -0,0 +1,59 @@ +{ + "name": "Lovelace Kindle Screensaver", + "version": "1.0.0", + "slug": "lovelace-kindle-screensaver", + "description": "Display a lovelace page as a screensaver on a jailbroken Kindle", + "url": "https://github.com/sibbl/hass-lovelace-kindle-screensaver", + "webui": "http://[HOST]:[PORT:5000]/output/cover.png", + "image": "sibbl/addon-lovelace-kindle-screensaver-{arch}", + "startup": "application", + "arch": ["armhf", "armv7", "aarch64", "amd64", "i386"], + "map": [ + "media:rw", + "config:rw", + "share:rw", + "ssl" + ], + "boot": "auto", + "ports": { + "5000/tcp": 5000 + }, + "ports_description": { + "5000/tcp": "Webserver that hosts the screensaver image" + }, + "privileged": [ + "SYS_ADMIN","DAC_READ_SEARCH" + ], + "hassio_api": true, + "hassio_role": "default", + "homeassistant_api": false, + "host_network": false, + "options": { + "screenshot_path": "/lovelace?kiosk", + "cron_job": "* * * * *", + "rendering_timeout": 30000, + "rendering_delay": 0, + "rendering_screen_height": 800, + "rendering_screen_width": 600, + "grayscale_depth": 8, + "language": "en", + "rotation": 0, + "scaling": 1 + }, + "schema": { + "screenshot_path": "str", + "cron_job": "str", + "rendering_timeout": "int", + "rendering_delay": "int", + "rendering_screen_height": "int", + "rendering_screen_width": "int", + "grayscale_depth": "int", + "language": "str", + "rotation": "int", + "scaling": "int" + }, + "environment": { + "LOG_FORMAT": "{LEVEL}: {MESSAGE}", + "OUTPUT_PATH": "/output/cover.png" + } + } diff --git a/config.js b/lovelace-kindle-screensaver/rootfs/app/config.js similarity index 100% rename from config.js rename to lovelace-kindle-screensaver/rootfs/app/config.js diff --git a/index.js b/lovelace-kindle-screensaver/rootfs/app/index.js similarity index 100% rename from index.js rename to lovelace-kindle-screensaver/rootfs/app/index.js diff --git a/package-lock.json b/lovelace-kindle-screensaver/rootfs/app/package-lock.json similarity index 100% rename from package-lock.json rename to lovelace-kindle-screensaver/rootfs/app/package-lock.json diff --git a/package.json b/lovelace-kindle-screensaver/rootfs/app/package.json similarity index 100% rename from package.json rename to lovelace-kindle-screensaver/rootfs/app/package.json diff --git a/lovelace-kindle-screensaver/rootfs/etc/services.d/node/finish b/lovelace-kindle-screensaver/rootfs/etc/services.d/node/finish new file mode 100644 index 0000000..e69de29 diff --git a/lovelace-kindle-screensaver/rootfs/etc/services.d/node/run b/lovelace-kindle-screensaver/rootfs/etc/services.d/node/run new file mode 100644 index 0000000..8feeaec --- /dev/null +++ b/lovelace-kindle-screensaver/rootfs/etc/services.d/node/run @@ -0,0 +1,20 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Runs the node server +# ============================================================================== +bashio::log.info "Starting Node server..." + +HA_BASE_URL=$(bashio::config 'ha_base_url') +HA_SCREENSHOT_URL=$(bashio::config 'ha_screenshot_url') +HA_ACCESS_TOKEN=$(bashio::config 'ha_access_token') +CRON_JOB=$(bashio::config 'cron_job') +RENDERING_TIMEOUT=$(bashio::config 'rendering_timeout') +RENDERING_DELAY=$(bashio::config 'rendering_delay') +RENDERING_SCREEN_HEIGHT=$(bashio::config 'rendering_screen_height') +RENDERING_SCREEN_WIDTH=$(bashio::config 'rendering_screen_width') +GRAYSCALE_DEPTH=$(bashio::config 'grayscale_depth') +LANGUAGE=$(bashio::config 'language') +ROTATION=$(bashio::config 'rotation') +SCALING=$(bashio::config 'scaling') + +exec /usr/bin/npm start \ No newline at end of file diff --git a/lovelace-eink-theme.yml b/theme/lovelace-eink-theme.yml similarity index 100% rename from lovelace-eink-theme.yml rename to theme/lovelace-eink-theme.yml From 889f78fbfdd7ca4ba1faed981665b21c33d1e0c8 Mon Sep 17 00:00:00 2001 From: Marcio Granzotto Date: Fri, 26 Mar 2021 11:45:06 -0300 Subject: [PATCH 3/7] Add github test workflow --- .github/workflows/test.yml | 87 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..515ce73 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,87 @@ +name: Test Docker build + +on: [pull_request] + +jobs: + dockerlint: + name: Dockerfile linter + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: hadolint + run: docker run --rm -i hadolint/hadolint < lovelace-kindle-screensaver/Dockerfile + build-amd64: + name: Build amd64 image + runs-on: ubuntu-latest + needs: [dockerlint] + steps: + - uses: actions/checkout@v2 + - name: Patch files + uses: onlyutkarsh/patch-files-action@v1.0.1 + with: + files: | + lovelace-kindle-screensaver/config.json + patch-syntax: | + = /version => "${{ github.run_number }}" + - name: build amd64 image + run: docker run --rm --privileged -v /var/run/docker.sock:/var/run/docker.sock -v ~/.docker:/root/.docker -v "$(pwd)":/data homeassistant/amd64-builder -t lovelace-kindle-screensaver --amd64 --test + build-armv7: + name: Build armv7 image + runs-on: ubuntu-latest + needs: [dockerlint] + steps: + - uses: actions/checkout@v2 + - name: Patch files + uses: onlyutkarsh/patch-files-action@v1.0.1 + with: + files: | + lovelace-kindle-screensaver/config.json + patch-syntax: | + = /version => "${{ github.run_number }}" + - name: build armv7 image + run: docker run --rm --privileged -v /var/run/docker.sock:/var/run/docker.sock -v ~/.docker:/root/.docker -v "$(pwd)":/data homeassistant/amd64-builder -t lovelace-kindle-screensaver --armv7 --test + build-aarch64: + name: Build aarch64 image + runs-on: ubuntu-latest + needs: [dockerlint] + steps: + - uses: actions/checkout@v2 + - name: Patch files + uses: onlyutkarsh/patch-files-action@v1.0.1 + with: + files: | + lovelace-kindle-screensaver/config.json + patch-syntax: | + = /version => "${{ github.run_number }}" + - name: build aarch64 image + run: docker run --rm --privileged -v /var/run/docker.sock:/var/run/docker.sock -v ~/.docker:/root/.docker -v "$(pwd)":/data homeassistant/amd64-builder -t lovelace-kindle-screensaver --aarch64 --test + build-i386: + name: Build i386 image + runs-on: ubuntu-latest + needs: [dockerlint] + steps: + - uses: actions/checkout@v2 + - name: Patch files + uses: onlyutkarsh/patch-files-action@v1.0.1 + with: + files: | + lovelace-kindle-screensaver/config.json + patch-syntax: | + = /version => "${{ github.run_number }}" + - name: build i386 image + run: docker run --rm --privileged -v /var/run/docker.sock:/var/run/docker.sock -v ~/.docker:/root/.docker -v "$(pwd)":/data homeassistant/amd64-builder -t lovelace-kindle-screensaver --i386 --test + build-armhf: + name: Build armhf image + runs-on: ubuntu-latest + needs: [dockerlint] + steps: + - uses: actions/checkout@v2 + - name: Patch files + uses: onlyutkarsh/patch-files-action@v1.0.1 + with: + files: | + lovelace-kindle-screensaver/config.json + patch-syntax: | + = /version => "${{ github.run_number }}" + - name: build armhf image + run: docker run --rm --privileged -v /var/run/docker.sock:/var/run/docker.sock -v ~/.docker:/root/.docker -v "$(pwd)":/data homeassistant/amd64-builder -t lovelace-kindle-screensaver --armhf --test From 79f6a5a174fe23a7e7e37191b3b55272d5b8c11a Mon Sep 17 00:00:00 2001 From: Marcio Granzotto Date: Fri, 26 Mar 2021 14:06:39 -0300 Subject: [PATCH 4/7] Fix build for other archs --- lovelace-kindle-screensaver/Dockerfile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lovelace-kindle-screensaver/Dockerfile b/lovelace-kindle-screensaver/Dockerfile index c52d68f..0cea5c6 100644 --- a/lovelace-kindle-screensaver/Dockerfile +++ b/lovelace-kindle-screensaver/Dockerfile @@ -4,8 +4,13 @@ FROM ${BUILD_FROM} WORKDIR /app +# hadolint ignore=DL3018 +RUN apk add --no-cache \ + chromium \ + --repository=https://mirror.fsmg.org.nz/alpine/v3.9/community \ + --repository=https://mirror.fsmg.org.nz/alpine/v3.9/main + RUN apk add --no-cache \ - chromium=86.0.4240.111-r0 \ nss=3.60.1-r0 \ freetype=2.10.4-r1 \ freetype-dev=2.10.4-r1 \ From 2b5c8a6f6620b0a2e341f8c1f2383c642c0de893 Mon Sep 17 00:00:00 2001 From: Marcio Granzotto Date: Fri, 26 Mar 2021 14:18:25 -0300 Subject: [PATCH 5/7] Remove unsupported archs --- .github/workflows/test.yml | 30 ------------------------- lovelace-kindle-screensaver/build.json | 4 +--- lovelace-kindle-screensaver/config.json | 2 +- 3 files changed, 2 insertions(+), 34 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 515ce73..50669f7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -55,33 +55,3 @@ jobs: = /version => "${{ github.run_number }}" - name: build aarch64 image run: docker run --rm --privileged -v /var/run/docker.sock:/var/run/docker.sock -v ~/.docker:/root/.docker -v "$(pwd)":/data homeassistant/amd64-builder -t lovelace-kindle-screensaver --aarch64 --test - build-i386: - name: Build i386 image - runs-on: ubuntu-latest - needs: [dockerlint] - steps: - - uses: actions/checkout@v2 - - name: Patch files - uses: onlyutkarsh/patch-files-action@v1.0.1 - with: - files: | - lovelace-kindle-screensaver/config.json - patch-syntax: | - = /version => "${{ github.run_number }}" - - name: build i386 image - run: docker run --rm --privileged -v /var/run/docker.sock:/var/run/docker.sock -v ~/.docker:/root/.docker -v "$(pwd)":/data homeassistant/amd64-builder -t lovelace-kindle-screensaver --i386 --test - build-armhf: - name: Build armhf image - runs-on: ubuntu-latest - needs: [dockerlint] - steps: - - uses: actions/checkout@v2 - - name: Patch files - uses: onlyutkarsh/patch-files-action@v1.0.1 - with: - files: | - lovelace-kindle-screensaver/config.json - patch-syntax: | - = /version => "${{ github.run_number }}" - - name: build armhf image - run: docker run --rm --privileged -v /var/run/docker.sock:/var/run/docker.sock -v ~/.docker:/root/.docker -v "$(pwd)":/data homeassistant/amd64-builder -t lovelace-kindle-screensaver --armhf --test diff --git a/lovelace-kindle-screensaver/build.json b/lovelace-kindle-screensaver/build.json index b3f736c..60cffec 100644 --- a/lovelace-kindle-screensaver/build.json +++ b/lovelace-kindle-screensaver/build.json @@ -3,9 +3,7 @@ "build_from": { "aarch64": "ghcr.io/hassio-addons/base/aarch64:9.1.5", "amd64": "ghcr.io/hassio-addons/base/amd64:9.1.5", - "armhf": "ghcr.io/hassio-addons/base/armhf:9.1.5", - "armv7": "ghcr.io/hassio-addons/base/armv7:9.1.5", - "i386": "ghcr.io/hassio-addons/base/i386:9.1.5" + "armv7": "ghcr.io/hassio-addons/base/armv7:9.1.5" }, "args": {} } diff --git a/lovelace-kindle-screensaver/config.json b/lovelace-kindle-screensaver/config.json index 0ec8d09..e03b871 100644 --- a/lovelace-kindle-screensaver/config.json +++ b/lovelace-kindle-screensaver/config.json @@ -7,7 +7,7 @@ "webui": "http://[HOST]:[PORT:5000]/output/cover.png", "image": "sibbl/addon-lovelace-kindle-screensaver-{arch}", "startup": "application", - "arch": ["armhf", "armv7", "aarch64", "amd64", "i386"], + "arch": ["armv7", "aarch64", "amd64"], "map": [ "media:rw", "config:rw", From 48c0799820d32ac997a6b9f3da1865bb2cffe467 Mon Sep 17 00:00:00 2001 From: Marcio Granzotto Date: Fri, 26 Mar 2021 14:18:35 -0300 Subject: [PATCH 6/7] fix run script --- lovelace-kindle-screensaver/rootfs/etc/services.d/node/run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lovelace-kindle-screensaver/rootfs/etc/services.d/node/run b/lovelace-kindle-screensaver/rootfs/etc/services.d/node/run index 8feeaec..c41f403 100644 --- a/lovelace-kindle-screensaver/rootfs/etc/services.d/node/run +++ b/lovelace-kindle-screensaver/rootfs/etc/services.d/node/run @@ -17,4 +17,4 @@ LANGUAGE=$(bashio::config 'language') ROTATION=$(bashio::config 'rotation') SCALING=$(bashio::config 'scaling') -exec /usr/bin/npm start \ No newline at end of file +exec cd /app && /usr/bin/npm start \ No newline at end of file From d87455880f07a5ee76b801051a8281940c0315b3 Mon Sep 17 00:00:00 2001 From: Marcio Granzotto Date: Fri, 9 Apr 2021 17:22:49 -0300 Subject: [PATCH 7/7] Fix add-on --- .github/workflows/ci.yml | 35 --------- .github/workflows/publish.yml | 74 +++++++++++++++++++ lovelace-kindle-screensaver/Dockerfile | 12 +-- lovelace-kindle-screensaver/config.json | 15 ++-- .../rootfs/etc/services.d/node/run | 31 ++++---- 5 files changed, 108 insertions(+), 59 deletions(-) delete mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/publish.yml mode change 100644 => 100755 lovelace-kindle-screensaver/rootfs/etc/services.d/node/run diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 5645fa7..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: ci - -on: - push: - branches: main - -jobs: - multi: - runs-on: ubuntu-latest - steps: - - - name: Checkout - uses: actions/checkout@v2 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to DockerHub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and push - uses: docker/build-push-action@v2 - with: - context: . - file: ./Dockerfile - platforms: linux/amd64,linux/arm/v7,linux/arm64 - push: true - tags: | - sibbl/hass-lovelace-kindle-screensaver:latest diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..556b32f --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,74 @@ +name: Docker build and publish + +on: + release: + types: [published] + +jobs: + build-amd64: + name: Build and publish amd64 image + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Get version + env: + TAG_NAME: ${{ github.event.release.tag_name }} + run: echo "VERSION=${TAG_NAME#v}" >> $GITHUB_ENV + - name: Patch files + uses: onlyutkarsh/patch-files-action@v1.0.1 + with: + files: | + lovelace-kindle-screensaver/config.json + patch-syntax: | + = /version => "${{ env.VERSION }}" + - name: publish amd64 docker files + if: github.event_name != 'pull_request' + run: docker run --rm --privileged -v /var/run/docker.sock:/var/run/docker.sock -v ~/.docker:/root/.docker -v "$(pwd)":/data homeassistant/amd64-builder -t lovelace-kindle-screensaver --amd64 --release-tag --docker-user marciogranzotto --docker-password ${{ secrets.DOCKER_PASSWORD }} + build-armv7: + name: Build and publish armv7 image + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Get version + env: + TAG_NAME: ${{ github.event.release.tag_name }} + run: echo "VERSION=${TAG_NAME#v}" >> $GITHUB_ENV + - name: Patch files + uses: onlyutkarsh/patch-files-action@v1.0.1 + with: + files: | + lovelace-kindle-screensaver/config.json + patch-syntax: | + = /version => "${{ env.VERSION }}" + - name: publish armv7 docker files + if: github.event_name != 'pull_request' + run: docker run --rm --privileged -v /var/run/docker.sock:/var/run/docker.sock -v ~/.docker:/root/.docker -v "$(pwd)":/data homeassistant/amd64-builder -t lovelace-kindle-screensaver --armv7 --release-tag --docker-user marciogranzotto --docker-password ${{ secrets.DOCKER_PASSWORD }} + build-aarch64: + name: Build and publish aarch64 image + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Get version + env: + TAG_NAME: ${{ github.event.release.tag_name }} + run: echo "VERSION=${TAG_NAME#v}" >> $GITHUB_ENV + - name: Patch files + uses: onlyutkarsh/patch-files-action@v1.0.1 + with: + files: | + lovelace-kindle-screensaver/config.json + patch-syntax: | + = /version => "${{ env.VERSION }}" + + - name: publish aarch64 docker files + if: github.event_name != 'pull_request' + run: docker run --rm --privileged -v /var/run/docker.sock:/var/run/docker.sock -v ~/.docker:/root/.docker -v "$(pwd)":/data homeassistant/amd64-builder -t lovelace-kindle-screensaver --aarch64 --release-tag --docker-user marciogranzotto --docker-password ${{ secrets.DOCKER_PASSWORD }} + update-main-repo: + needs: [build-amd64, build-armv7, build-aarch64, build-i386, build-armhf] + name: Update addons repository + runs-on: ubuntu-latest + container: + image: hassioaddons/repository-updater:latest + steps: + - name: upload + run: repository-updater --token ${{ secrets.GIT_TOKEN }} --repository marciogranzotto/addons-repository --addon lovelace-kindle-screensaver diff --git a/lovelace-kindle-screensaver/Dockerfile b/lovelace-kindle-screensaver/Dockerfile index 0cea5c6..65d86e1 100644 --- a/lovelace-kindle-screensaver/Dockerfile +++ b/lovelace-kindle-screensaver/Dockerfile @@ -11,15 +11,15 @@ RUN apk add --no-cache \ --repository=https://mirror.fsmg.org.nz/alpine/v3.9/main RUN apk add --no-cache \ - nss=3.60.1-r0 \ + nss=3.63-r0 \ freetype=2.10.4-r1 \ freetype-dev=2.10.4-r1 \ harfbuzz=2.7.4-r1 \ ca-certificates=20191127-r5 \ ttf-freefont=20120503-r1 \ imagemagick=7.0.10.57-r0 \ - nodejs=14.16.0-r0 \ - npm=14.16.0-r0 + nodejs=14.16.1-r0 \ + npm=14.16.1-r0 ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \ PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser \ @@ -44,12 +44,12 @@ LABEL \ io.hass.type="addon" \ io.hass.version=${BUILD_VERSION} \ maintainer="Marcio Granzotto " \ - org.opencontainers.image.title="Transmission" \ + org.opencontainers.image.title="Lovelace Kindle Screensaver" \ org.opencontainers.image.description="Display a lovelace page as a screensaver on a jailbroken Kindle" \ org.opencontainers.image.vendor="Marcio Granzotto" \ org.opencontainers.image.authors="Marcio Granzotto " \ - org.opencontainers.image.source="https://github.com/sibbl/hass-lovelace-kindle-screensaver" \ - org.opencontainers.image.documentation="https://github.com/sibbl/hass-lovelace-kindle-screensaver/blob/master/README.md" \ + org.opencontainers.image.source="https://github.com/marciogranzotto/hass-lovelace-kindle-screensaver" \ + org.opencontainers.image.documentation="https://github.com/marciogranzotto/hass-lovelace-kindle-screensaver/blob/master/README.md" \ org.opencontainers.image.created=${BUILD_DATE} \ org.opencontainers.image.revision=${BUILD_REF} \ org.opencontainers.image.version=${BUILD_VERSION} diff --git a/lovelace-kindle-screensaver/config.json b/lovelace-kindle-screensaver/config.json index e03b871..3ce1a0c 100644 --- a/lovelace-kindle-screensaver/config.json +++ b/lovelace-kindle-screensaver/config.json @@ -3,9 +3,9 @@ "version": "1.0.0", "slug": "lovelace-kindle-screensaver", "description": "Display a lovelace page as a screensaver on a jailbroken Kindle", - "url": "https://github.com/sibbl/hass-lovelace-kindle-screensaver", + "url": "https://github.com/marciogranzotto/hass-lovelace-kindle-screensaver", "webui": "http://[HOST]:[PORT:5000]/output/cover.png", - "image": "sibbl/addon-lovelace-kindle-screensaver-{arch}", + "image": "marciogranzotto/addon-lovelace-kindle-screensaver-{arch}", "startup": "application", "arch": ["armv7", "aarch64", "amd64"], "map": [ @@ -24,11 +24,13 @@ "privileged": [ "SYS_ADMIN","DAC_READ_SEARCH" ], + "auth_api": true, "hassio_api": true, "hassio_role": "default", - "homeassistant_api": false, + "homeassistant_api": true, "host_network": false, "options": { + "ha_token": "!secret kindle_ha_token", "screenshot_path": "/lovelace?kiosk", "cron_job": "* * * * *", "rendering_timeout": 30000, @@ -38,9 +40,11 @@ "grayscale_depth": 8, "language": "en", "rotation": 0, - "scaling": 1 + "scaling": 1, + "log_level": "info" }, "schema": { + "ha_token": "str", "screenshot_path": "str", "cron_job": "str", "rendering_timeout": "int", @@ -50,7 +54,8 @@ "grayscale_depth": "int", "language": "str", "rotation": "int", - "scaling": "int" + "scaling": "int", + "log_level": "list(trace|debug|info|notice|warning|error|fatal)?" }, "environment": { "LOG_FORMAT": "{LEVEL}: {MESSAGE}", diff --git a/lovelace-kindle-screensaver/rootfs/etc/services.d/node/run b/lovelace-kindle-screensaver/rootfs/etc/services.d/node/run old mode 100644 new mode 100755 index c41f403..7f49e57 --- a/lovelace-kindle-screensaver/rootfs/etc/services.d/node/run +++ b/lovelace-kindle-screensaver/rootfs/etc/services.d/node/run @@ -4,17 +4,22 @@ # ============================================================================== bashio::log.info "Starting Node server..." -HA_BASE_URL=$(bashio::config 'ha_base_url') -HA_SCREENSHOT_URL=$(bashio::config 'ha_screenshot_url') -HA_ACCESS_TOKEN=$(bashio::config 'ha_access_token') -CRON_JOB=$(bashio::config 'cron_job') -RENDERING_TIMEOUT=$(bashio::config 'rendering_timeout') -RENDERING_DELAY=$(bashio::config 'rendering_delay') -RENDERING_SCREEN_HEIGHT=$(bashio::config 'rendering_screen_height') -RENDERING_SCREEN_WIDTH=$(bashio::config 'rendering_screen_width') -GRAYSCALE_DEPTH=$(bashio::config 'grayscale_depth') -LANGUAGE=$(bashio::config 'language') -ROTATION=$(bashio::config 'rotation') -SCALING=$(bashio::config 'scaling') +bashio::log.debug "$(bashio::api.supervisor GET '/core/api/discovery_info' true)" -exec cd /app && /usr/bin/npm start \ No newline at end of file +export HA_BASE_URL="$(bashio::jq "$(bashio::api.supervisor GET '/core/api/discovery_info' true)" ".base_url")" +export HA_ACCESS_TOKEN="$(bashio::config 'ha_token')" +export HA_SCREENSHOT_URL=$(bashio::config 'screenshot_path') +export CRON_JOB=$(bashio::config 'cron_job') +export RENDERING_TIMEOUT=$(bashio::config 'rendering_timeout') +export RENDERING_DELAY=$(bashio::config 'rendering_delay') +export RENDERING_SCREEN_HEIGHT=$(bashio::config 'rendering_screen_height') +export RENDERING_SCREEN_WIDTH=$(bashio::config 'rendering_screen_width') +export GRAYSCALE_DEPTH=$(bashio::config 'grayscale_depth') +export LANGUAGE=$(bashio::config 'language') +export ROTATION=$(bashio::config 'rotation') +export SCALING=$(bashio::config 'debug') + +bashio::log.info "Using base_url: ${HA_BASE_URL}" + +cd /app +exec /usr/bin/npm start \ No newline at end of file