Initial commit.

This commit is contained in:
2025-04-14 08:24:11 +02:00
commit a6e5ebb157
3 changed files with 193 additions and 0 deletions

View File

@@ -0,0 +1,78 @@
name: Build vzlogger image
on:
push:
branches: [ master ]
schedule:
# Run every Sunday at midnight
- cron: '0 0 * * 0'
env:
IMAGE: /home/vzlogger
jobs:
Build-and-release-image:
runs-on: ubuntu-latest
container:
image: catthehacker/ubuntu:act-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USER }}
password: ${{ vars.DOCKERHUB_TOKEN }}
- name: Log into CS registry
uses: docker/login-action@v3
with:
registry: ${{ vars.CS_REGISTRY_URL }}
username: ${{ vars.CS_REGISTRY_USER }}
password: ${{ vars.CS_REGISTRY_PASS }}
- name: Log into local registry
uses: docker/login-action@v3
with:
registry: ${{ vars.LOCAL_REGISTRY_URL }}
username: ${{ vars.LOCAL_REGISTRY_USER }}
password: ${{ vars.LOCAL_REGISTRY_PASS }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ secrets.REGISTRY_URL }}${{ env.IMAGE }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
env:
ACTIONS_RUNTIME_TOKEN: ''
with:
tags: ${{ vars.LOCAL_REGISTRY_URL }}${{ env.IMAGE }}:latest
push: true
- name: Scan image
uses: anchore/scan-action@v6
id: scan
with:
image: ${{ vars.LOCAL_REGISTRY_URL }}${{ env.IMAGE }}:latest
fail-build: false
output-format: table
severity-cutoff: critical
registry-username: ${{ vars.LOCAL_REGISTRY_USER }}
registry-password: ${{ vars.LOCAL_REGISTRY_PASS }}
grype-version: 'v0.90.0'
- name: Inspect file
run: cat ${{ steps.scan.outputs.table }}
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: scan-result
path: ${{ steps.scan.outputs.table }}

82
Dockerfile Normal file
View File

@@ -0,0 +1,82 @@
############################
# STEP 1 build executable binary
############################
FROM alpine:latest AS builder
RUN apk add --no-cache \
gcc \
g++ \
libc-dev \
linux-headers \
git \
make \
cmake \
curl-dev \
gnutls-dev \
cyrus-sasl-dev \
# for libuuid
util-linux-dev \
libtool \
libgcrypt-dev \
libmicrohttpd-dev \
json-c-dev \
mosquitto-dev \
libunistring-dev \
automake \
autoconf \
gtest-dev
WORKDIR /vzlogger
RUN git clone https://github.com/volkszaehler/libsml.git --depth 1 \
&& make install -C libsml/sml
RUN git clone https://github.com/rscada/libmbus.git --depth 1 \
&& cd libmbus \
&& ./build.sh \
&& make install
COPY . /vzlogger
ARG build_test=off
RUN cmake -DBUILD_TEST=${build_test} \
&& make -j $(nproc --all || echo 1) \
&& make install \
&& if [ "$build_test" != "off" ]; then make test; fi
#############################
## STEP 2 build a small image
#############################
FROM alpine:latest
LABEL Description="vzlogger"
RUN apk add --no-cache \
libcurl \
gnutls \
libsasl \
libuuid \
libgcrypt \
libmicrohttpd \
json-c \
libatomic \
mosquitto-libs \
libunistring \
libstdc++ \
libgcc
# libsml is linked statically => no need to copy
COPY --from=builder /usr/local/bin/vzlogger /usr/local/bin/vzlogger
COPY --from=builder /usr/local/lib/libmbus.so* /usr/local/lib/
COPY ./vzlogger.conf /cfg
# without running a user context, no exec is possible and without the dialout group no access to usb ir reader possible
RUN adduser -S vz -G dialout
RUN vzlogger --version
USER vz
CMD ["vzlogger", "--foreground"]

33
vzlogger.conf Normal file
View File

@@ -0,0 +1,33 @@
{
"retry": 0, /* sleep between failed requests (seconds) */
"daemon": true, /* run as deamon*/
"verbosity": 2, /* Loglevel between 0 (nothing) and 15 (higest) */
"log": "/var/log/vzlogger.log", /* logfile path */
"local": {
"enabled": false, /* Enable / Disable local HTTP-Server for serving live readings */
"port": 8080, /* TCP port for the local HTTP-Server */
"index": true, /* Provide a index listing of available channels */
"timeout": 30, /* timeout for long polling requests (seconds) */
"buffer": 600 /* Buffer reading for the local interface (seconds) */
},
"meters": [
{
"enabled": true, /* disable or enable meter */
"protocol": "sml", /* use 'vzlogger -h' for available protocols */
"device": "/dev/ttyUSB0", /* Serial Port of Photodiod */
"channels": [
{
"uuid": "ac9dc6a0-dbfc-11ee-8e1d-2bb051f0ef2a", /* UUID von dem angelegten Channel für 1.8.0 */
"middleware": "http://localhost/middleware.php", /* Server Adresse der Middleware, läuft bei uns auf dem RasPi mit */
"identifier": "1-0:1.8.0" /* Die OBIS Kennzahl welche an den Channel gesendet wird - hier Bezug Tarif 1 */
},
{
"uuid": "27260d00-dbfc-11ee-af9d-594b1762c0d0",
"middleware": "http://localhost/middleware.php",
"identifier": "1-0:16.7.0" /* Aktuelle Leistung */
}
]
}
]
}