Skip to content

Commit

Permalink
Merge pull request wmbusmeters#1167 from testuser7/rtl_reset
Browse files Browse the repository at this point in the history
Update docker image, add rtl_reset, rtl_sdr
  • Loading branch information
weetmuts authored Feb 13, 2024
2 parents 4b55407 + 97f2082 commit c3d1b6f
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 32 deletions.
105 changes: 80 additions & 25 deletions .github/workflows/build_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,28 @@ on:
- '[0-9]+\.[0-9]+\.[0-9]+'
- '[0-9]+\.[0-9]+\.[0-9]+-RC[0-9]+'

env:
DOCKERHUB_IMAGE: ${{ github.repository }}
IMAGE_TAG: |
${{ github.ref_type == 'tag' && (contains(github.ref_name, '-RC') &&
join('candidate-', github.ref_name) || join('release-', github.ref_name)) || 'latest' }}
jobs:
docker:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm/v7
- linux/arm64
steps:
-
name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
-
name: Checkout
uses: actions/checkout@v4
Expand All @@ -20,11 +38,10 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
images: wmbusmeters/wmbusmeters
tags: type=ref,event=tag
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
tags: |
${{ env.IMAGE_TAG }}
images: |
${{ env.DOCKERHUB_IMAGE }}
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -35,29 +52,67 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PAT }}
-
name: Build and push not tagged release
if: ${{ !steps.meta.outputs.tags }}
name: Build and push
uses: docker/build-push-action@v5
id: docker_build
with:
context: docker/
platforms: linux/amd64,linux/arm64,linux/armhf
push: true
tags: wmbusmeters/wmbusmeters:latest
platforms: ${{ matrix.platform }}
provenance: false
outputs: |
type=image,name=${{ env.DOCKERHUB_IMAGE }},push-by-digest=true,name-canonical=true,push=true
-
name: Build and push candidate
if: ${{ steps.meta.outputs.tags && contains(steps.meta.outputs.tags, '-RC') }}
uses: docker/build-push-action@v5
name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.docker_build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
-
name: Upload digest
uses: actions/upload-artifact@v4
with:
context: docker/
platforms: linux/amd64,linux/arm64,linux/armhf
push: true
tags: wmbusmeters/wmbusmeters:candidate-${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
name: digests-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

merge:
runs-on: ubuntu-latest
needs:
- build
steps:
-
name: Build and push tagged release
if: ${{ steps.meta.outputs.tags && !contains(steps.meta.outputs.tags, '-RC') }}
uses: docker/build-push-action@v5
name: Download digests
uses: actions/download-artifact@v4
with:
context: docker/
platforms: linux/amd64,linux/arm64,linux/armhf
push: true
tags: wmbusmeters/wmbusmeters:release-${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
path: /tmp/digests
pattern: digests-*
merge-multiple: true
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
tags: |
${{ env.IMAGE_TAG }}
images: |
${{ env.DOCKERHUB_IMAGE }}
-
name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PAT }}
-
name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.DOCKERHUB_IMAGE }}@sha256:%s ' *)
-
name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.DOCKERHUB_IMAGE }}:${{ steps.meta.outputs.version }}
31 changes: 24 additions & 7 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,39 @@
FROM asymworks/multiarch-alpine:${TARGETARCH}${TARGETVARIANT}-latest-stable AS build
RUN apk add --no-cache alpine-sdk gcc linux-headers librtlsdr-dev libxml2-dev cmake libusb-dev bash
RUN git clone https://github.com/wmbusmeters/wmbusmeters.git && \
FROM alpine AS build
RUN apk add --no-cache alpine-sdk gcc linux-headers librtlsdr-dev libxml2-dev cmake libusb-dev bash samurai
RUN git clone https://github.com/steve-m/librtlsdr.git && \
git clone https://github.com/wmbusmeters/wmbusmeters.git && \
git clone https://github.com/weetmuts/rtl-wmbus.git && \
git clone https://github.com/merbanan/rtl_433.git
git clone https://github.com/merbanan/rtl_433.git && \
git clone https://github.com/ED6E0F17/rtl_reset.git
WORKDIR /librtlsdr
RUN cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE=MinSizeRel \
-DCMAKE_INSTALL_PREFIX:PATH=/usr \
-DDETACH_KERNEL_DRIVER=ON \
-Wno-dev && \
cmake --build build && \
cmake --install build
WORKDIR /wmbusmeters
RUN make
WORKDIR /rtl-wmbus
RUN make release && chmod 755 build/rtl_wmbus
WORKDIR /rtl_433
RUN mkdir build && cd build && cmake ../ && make
RUN cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE=MinSizeRel && \
cmake --build build
WORKDIR /rtl_reset
RUN make

FROM asymworks/multiarch-alpine:${TARGETARCH}${TARGETVARIANT}-latest-stable as scratch
ENV QEMU_EXECVE=1
FROM alpine as scratch
RUN apk add --no-cache mosquitto-clients libstdc++ curl libusb rtl-sdr libxml2 netcat-openbsd
WORKDIR /wmbusmeters
COPY --from=build /librtlsdr/build/src/librtlsdr.so.* /usr/lib/
COPY --from=build /librtlsdr/rtl-sdr.rules /usr/lib/udev/rules.d/rtl-sdr.rules
COPY --from=build /librtlsdr/build/src/rtl_* /usr/bin/
COPY --from=build /wmbusmeters/build/wmbusmeters /wmbusmeters/wmbusmeters
COPY --from=build /rtl-wmbus/build/rtl_wmbus /usr/bin/rtl_wmbus
COPY --from=build /rtl_433/build/src/rtl_433 /usr/bin/rtl_433
COPY --from=build /rtl_reset/rtl_reset /usr/bin/rtl_reset
COPY --from=build /wmbusmeters/docker/docker-entrypoint.sh /wmbusmeters/docker-entrypoint.sh
VOLUME /wmbusmeters_data/
CMD ["sh", "/wmbusmeters/docker-entrypoint.sh"]

0 comments on commit c3d1b6f

Please sign in to comment.