Skip to content

Commit

Permalink
update: based on new addon example
Browse files Browse the repository at this point in the history
  • Loading branch information
Minims committed Jan 20, 2025
1 parent 19fa879 commit 1cca272
Show file tree
Hide file tree
Showing 23 changed files with 192 additions and 70 deletions.
30 changes: 17 additions & 13 deletions .devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,22 @@
"containerEnv": {
"WORKSPACE_DIRECTORY": "${containerWorkspaceFolder}"
},
"extensions": ["timonwong.shellcheck", "esbenp.prettier-vscode"],
"mounts": ["type=volume,target=/var/lib/docker"],
"settings": {
"terminal.integrated.profiles.linux": {
"zsh": {
"path": "/usr/bin/zsh"
"customizations": {
"vscode": {
"extensions": ["timonwong.shellcheck", "esbenp.prettier-vscode"],
"settings": {
"terminal.integrated.profiles.linux": {
"zsh": {
"path": "/usr/bin/zsh"
}
},
"terminal.integrated.defaultProfile.linux": "zsh",
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"files.trimTrailingWhitespace": true
}
},
"terminal.integrated.defaultProfile.linux": "zsh",
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"files.trimTrailingWhitespace": true
}
}
},
"mounts": ["type=volume,target=/var/lib/docker"]
}
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.github/* @minims
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
github: minims
custom: https://www.buymeacoffee.com/minims
62 changes: 62 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"rebaseWhen": "behind-base-branch",
"dependencyDashboard": true,
"labels": [
"dependencies",
"no-stale"
],
"commitMessagePrefix": "⬆️",
"commitMessageTopic": "{{depName}}",
"regexManagers": [
{
"fileMatch": [
"/Dockerfile$",
"/build.yaml$"
],
"matchStringsStrategy": "any",
"matchStrings": [
"ARG BUILD_FROM=(?<depName>.*?):(?<currentValue>.*?)\\s+",
"(aarch64|amd64|armv7):\\s[\"']?(?<depName>.*?):(?<currentValue>.*?)[\"']?\\s"
],
"datasourceTemplate": "docker"
},
{
"fileMatch": [
"/Dockerfile$"
],
"matchStringsStrategy": "any",
"matchStrings": [
"\\s\\s(?<package>[a-z0-9-]+)=(?<currentValue>[a-z0-9-_.]+)\\s+"
],
"versioningTemplate": "loose",
"datasourceTemplate": "repology",
"depNameTemplate": "alpine_3_21/{{package}}"
}
],
"packageRules": [
{
"matchDatasources": [
"repology"
],
"automerge": true
},
{
"groupName": "Add-on base image",
"matchDatasources": [
"docker"
]
},
{
"groupName": "Add-on base image",
"matchDatasources": [
"docker"
],
"matchUpdateTypes": [
"minor",
"patch"
],
"automerge": true
}
]
}
1 change: 0 additions & 1 deletion .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ jobs:
workflows:
uses: hassio-addons/workflows/.github/workflows/addon-deploy.yaml@main
secrets:
CAS_API_KEY: ${{ secrets.CAS_API_KEY }}
DISPATCH_TOKEN: ${{ secrets.DISPATCH_TOKEN }}
5 changes: 3 additions & 2 deletions MyFox2MQTT-dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# https://developers.home-assistant.io/docs/add-ons/configuration#add-on-dockerfile
ARG BUILD_FROM
FROM $BUILD_FROM
FROM $BUILD_FROM$:dev
ENV LANG C.UTF-8

# Install required packages
Expand All @@ -9,7 +10,7 @@ RUN pip3 install --no-cache-dir python-json2yaml==0.1.1

# Download source and untar
WORKDIR /usr/bin
ADD "https://github.com/Minims/MyFox2MQTT/archive/refs/heads/dev.tar.gz" dev.tar.gz
COPY "https://github.com/Minims/MyFox2MQTT/archive/refs/heads/dev.tar.gz" dev.tar.gz
RUN tar -xvf dev.tar.gz
RUN mv /usr/bin/MyFox2MQTT-dev /usr/bin/MyFox2MQTT

Expand All @@ -18,4 +19,4 @@ WORKDIR /usr/bin/MyFox2MQTT/myFox2Mqtt
RUN pip3 install --no-cache-dir -r requirements.txt

# Copy root filesystem
ADD rootfs /
COPY rootfs /
1 change: 1 addition & 0 deletions MyFox2MQTT-dev/translations/en.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
configuration:
message:
name: Message
Expand Down
10 changes: 4 additions & 6 deletions MyFox2MQTT/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
# https://developers.home-assistant.io/docs/add-ons/configuration#add-on-dockerfile
ARG VERSION=2024.9.2
ARG BUILD_FROM
FROM $BUILD_FROM
FROM $BUILD_FROM:{$VERSION}
ENV LANG C.UTF-8

# MyFox2MQTT version
ARG VERSION=2024.9.2

# Install required packages
RUN apk add --no-cache py3-pip
RUN pip3 install --no-cache-dir python-json2yaml==0.1.1

# Download source and untar
WORKDIR /usr/bin
ADD "https://github.com/Minims/MyFox2MQTT/archive/refs/tags/${VERSION}.tar.gz" ${VERSION}.tar.gz
COPY "https://github.com/Minims/MyFox2MQTT/archive/refs/tags/${VERSION}.tar.gz" ${VERSION}.tar.gz
RUN tar -xvf ${VERSION}.tar.gz
RUN mv /usr/bin/MyFox2MQTT-${VERSION} /usr/bin/MyFox2MQTT

Expand All @@ -21,4 +19,4 @@ WORKDIR /usr/bin/MyFox2MQTT/myFox2Mqtt
RUN pip3 install --no-cache-dir -r requirements.txt

# Copy root filesystem
ADD rootfs /
COPY rootfs /
1 change: 1 addition & 0 deletions MyFox2MQTT/translations/en.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
configuration:
message:
name: Message
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[!["Buy Me A Coffee"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/minims)

# Minims Home Assistant add-on repository

[![Open your Home Assistant instance and show the add add-on repository dialog with a specific repository URL pre-filled.](https://my.home-assistant.io/badges/supervisor_add_addon_repository.svg)](https://my.home-assistant.io/redirect/supervisor_add_addon_repository/?repository_url=https%3A%2F%2Fgithub.com%2FMinims%2Fhomeassistant-addons)
Expand Down
39 changes: 29 additions & 10 deletions SomfyProtect2MQTT-dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,40 @@
# https://developers.home-assistant.io/docs/add-ons/configuration#add-on-dockerfile
ARG BUILD_FROM
FROM $BUILD_FROM
FROM ${BUILD_FROM}:dev
ENV LANG C.UTF-8

# Install required packages
RUN apk add --no-cache py3-pip py3-opencv ffmpeg
RUN pip3 install --no-cache-dir python-json2yaml==0.1.1
# Copy root filesystem
COPY rootfs /

# Setup base
RUN apk add --no-cache \
build-base \
ffmpeg \
ffmpeg-dev \
libjxl \
libjxl-tools \
libsrtp \
libsrtp-dev \
libvpx \
libvpx-dev \
openssl \
openssl-dev \
opus \
opus-dev \
py3-opencv \
py3-pip \
python3 \
python3-dev \
yq

# Install python3 requirements
# RUN pip3 install --no-cache-dir python-json2yaml==0.1.1

# Download source and untar
WORKDIR /usr/bin
ADD "https://github.com/Minims/SomfyProtect2MQTT/archive/refs/heads/dev.tar.gz" dev.tar.gz
RUN tar -xvf dev.tar.gz
RUN mv /usr/bin/SomfyProtect2MQTT-dev /usr/bin/SomfyProtect2MQTT
COPY "https://github.com/Minims/SomfyProtect2MQTT/archive/refs/heads/dev.tar.gz" dev.tar.gz
RUN tar -xvf dev.tar.gz && mv /usr/bin/SomfyProtect2MQTT-dev /usr/bin/SomfyProtect2MQTT

# Install python3 requirements
WORKDIR /usr/bin/SomfyProtect2MQTT/somfyProtect2Mqtt
RUN pip3 install --no-cache-dir -r requirements/addon.txt

# Copy root filesystem
ADD rootfs /
13 changes: 7 additions & 6 deletions SomfyProtect2MQTT-dev/build.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---
# https://developers.home-assistant.io/docs/add-ons/configuration#add-on-dockerfile
build_from:
aarch64: ghcr.io/hassio-addons/base:15.0.5
amd64: ghcr.io/hassio-addons/base:15.0.5
armhf: ghcr.io/hassio-addons/base:15.0.5
armv7: ghcr.io/hassio-addons/base:15.0.5
i386: ghcr.io/hassio-addons/base:15.0.5
aarch64: ghcr.io/hassio-addons/base:17.1.0
amd64: ghcr.io/hassio-addons/base:17.1.0
armhf: ghcr.io/hassio-addons/base:17.1.0
armv7: ghcr.io/hassio-addons/base:17.1.0
i386: ghcr.io/hassio-addons/base:17.1.0
labels:
org.opencontainers.image.title: "Home Assistant Add-on: Minims add-on"
org.opencontainers.image.description: "Minims add-on to use as a blueprint for new add-ons."
org.opencontainers.image.source: "https://github.com/Minims/homeassistant-addons"
org.opencontainers.image.licenses: "Apache License 2.0"
args:
VERSION: "2024.9.0"
VERSION: "2025.2.0a"
4 changes: 2 additions & 2 deletions SomfyProtect2MQTT-dev/config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# https://developers.home-assistant.io/docs/add-ons/configuration#add-on-config
---
# https://developers.home-assistant.io/docs/add-ons/configuration#add-on-config
name: SomfyProtect2MQTT-dev
version: dev
slug: somfy-protect-2-mqtt-dev
Expand All @@ -18,7 +18,7 @@ arch:
init: false
map:
- share:rw
- config:rw
- homeassistant_config:rw
options:
somfy_protect:
username: mail@example.org
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/command/with-contenv bashio
# shellcheck shell=bash
# ==============================================================================
# Home Assistant SomfyProtect2MQTT Add-on for Home Assistant
# ==============================================================================
declare exit_code
readonly exit_code_container=$(</run/s6-linux-init-container-results/exitcode)
readonly exit_code_service="${1}"
readonly exit_code_signal="${2}"
readonly service="somfyProtect2Mqtt"

bashio::log.info \
"Service ${service} exited with code ${exit_code_service}" \
"(by signal ${exit_code_signal})"

# Received a signal
if [[ "${exit_code_service}" -eq 256 ]]; then

# The signal might be a result of another service crashing. Only
# overwrite the container exit code if it is not already set.
if [[ "${exit_code_container}" -eq 0 ]]; then
echo $((128 + $exit_code_signal)) > /run/s6-linux-init-container-results/exitcode
fi

# If the signal is SIGTERM, we should halt the container and take down
# the whole process tree.
[[ "${exit_code_signal}" -eq 15 ]] && exec /run/s6/basedir/bin/halt

# The service exited with a non-zero exit code, which means it crashed.
elif [[ "${exit_code_service}" -ne 0 ]]; then

# The service might be a result of another service crashing. Only
# overwrite the container exit code if it is not already set.
if [[ "${exit_code_container}" -eq 0 ]]; then
echo "${exit_code_service}" > /run/s6-linux-init-container-results/exitcode
fi

# We should halt the container and take down the whole process tree.
exec /run/s6/basedir/bin/halt

# The service exited with a zero exit code, which means it exited, let
# S6 supervision restart it.
else
bashio::log.info "Service ${service} restarting..."
fi
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
#!/usr/bin/with-contenv bashio
#!/command/with-contenv bashio
# shellcheck shell=bash
# ==============================================================================
# Start the example service
# s6-overlay docs: https://github.com/just-containers/s6-overlay
# Home Assistant Community Add-on: SomfyProtect2MQTT
# Runs SomfyProtect2MQTT
# ==============================================================================

# Add your code here

#!/usr/bin/env bashio

bashio::log.info "Generating config.yaml from options.json"
echo '# Generated by homeassistant, do not edit!' > /usr/bin/SomfyProtect2MQTT/somfyProtect2Mqtt/config/config.yaml.tmp
echo '# Edit configuration only at the Add-on configuration tab!' >> /usr/bin/SomfyProtect2MQTT/somfyProtect2Mqtt/config/config.yaml.tmp
json2yaml /data/options.json >> /usr/bin/SomfyProtect2MQTT/somfyProtect2Mqtt/config/config.yaml.tmp
yq -P -oy /data/options.json >> /usr/bin/SomfyProtect2MQTT/somfyProtect2Mqtt/config/config.yaml.tmp
sed 's/ -/ -/' /usr/bin/SomfyProtect2MQTT/somfyProtect2Mqtt/config/config.yaml.tmp > /usr/bin/SomfyProtect2MQTT/somfyProtect2Mqtt/config/config.yaml
bashio::log.info "Configuration :"
bashio::log.info "$(cat /usr/bin/SomfyProtect2MQTT/somfyProtect2Mqtt/config/config.yaml)"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.

This file was deleted.

3 changes: 2 additions & 1 deletion SomfyProtect2MQTT-dev/translations/en.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
configuration:
message:
name: Message
description: The message that will be printed to the log when starting this example add-on.
description: The message that will be printed to the log when starting this add-on.
10 changes: 4 additions & 6 deletions SomfyProtect2MQTT/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
# https://developers.home-assistant.io/docs/add-ons/configuration#add-on-dockerfile
ARG VERSION=2024.9.0
ARG BUILD_FROM
FROM $BUILD_FROM
FROM $BUILD_FROM$:${VERSION}
ENV LANG C.UTF-8

# SomfyProtect2MQTT version
ARG VERSION=2024.9.0

# Install required packages
RUN apk add --no-cache py3-pip py3-opencv ffmpeg

Check failure on line 8 in SomfyProtect2MQTT/Dockerfile

View workflow job for this annotation

GitHub Actions / workflows / Hadolint

DL3018 warning: Pin versions in apk add. Instead of `apk add <package>` use `apk add <package>=<version>`
RUN pip3 install --no-cache-dir python-json2yaml==0.1.1

Check failure on line 9 in SomfyProtect2MQTT/Dockerfile

View workflow job for this annotation

GitHub Actions / workflows / Hadolint

DL3059 info: Multiple consecutive `RUN` instructions. Consider consolidation.

# Download source and untar
WORKDIR /usr/bin
ADD "https://github.com/Minims/SomfyProtect2MQTT/archive/refs/tags/${VERSION}.tar.gz" ${VERSION}.tar.gz
COPY "https://github.com/Minims/SomfyProtect2MQTT/archive/refs/tags/${VERSION}.tar.gz" ${VERSION}.tar.gz
RUN tar -xvf ${VERSION}.tar.gz

Check failure on line 14 in SomfyProtect2MQTT/Dockerfile

View workflow job for this annotation

GitHub Actions / workflows / Hadolint

SC2086 info: Double quote to prevent globbing and word splitting.
RUN mv /usr/bin/SomfyProtect2MQTT-${VERSION} /usr/bin/SomfyProtect2MQTT

Check failure on line 15 in SomfyProtect2MQTT/Dockerfile

View workflow job for this annotation

GitHub Actions / workflows / Hadolint

DL3059 info: Multiple consecutive `RUN` instructions. Consider consolidation.

Check failure on line 15 in SomfyProtect2MQTT/Dockerfile

View workflow job for this annotation

GitHub Actions / workflows / Hadolint

SC2086 info: Double quote to prevent globbing and word splitting.

Expand All @@ -21,4 +19,4 @@ WORKDIR /usr/bin/SomfyProtect2MQTT/somfyProtect2Mqtt
RUN pip3 install --no-cache-dir -r requirements/addon.txt

# Copy root filesystem
ADD rootfs /
COPY rootfs /
1 change: 1 addition & 0 deletions SomfyProtect2MQTT/build.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# https://developers.home-assistant.io/docs/add-ons/configuration#add-on-dockerfile
build_from:
aarch64: ghcr.io/hassio-addons/base:15.0.5
Expand Down
Loading

0 comments on commit 1cca272

Please sign in to comment.