Skip to content

Commit

Permalink
test docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
testuser7 committed Feb 22, 2024
1 parent 097f91f commit a39cb43
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 20 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build_debian.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Build Debian package
on:
push:
branches:
- master
pull_request:

jobs:
Expand Down
54 changes: 38 additions & 16 deletions .github/workflows/build_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,25 @@ name: Build docker
on:
push:
branches:
- 'master'
- 'dev'
tags:
- '[0-9]+\.[0-9]+\.[0-9]+'
- '[0-9]+\.[0-9]+\.[0-9]+-RC[0-9]+'

env:
DOCKERHUB_IMAGE: ${{ github.repository }}
#HUB_IMAGE: testuser07/${{ github.event.repository.name }}
#GHCR_IMAGE: ghcr.io/${{ github.repository }}
IMAGE_NAME: ghcr.io/${{ github.repository }}
IMAGE_TAG: |
${{ github.ref_type == 'tag' && (contains(github.ref_name, '-RC') &&
join('candidate-', github.ref_name) || join('release-', github.ref_name)) || 'latest' }}
join(('candidate-' github.ref_name)) || join(('release-' github.ref_name))) || 'test' }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
Expand All @@ -41,16 +46,23 @@ jobs:
tags: |
${{ env.IMAGE_TAG }}
images: |
${{ env.DOCKERHUB_IMAGE }}
${{ env.IMAGE_NAME }}
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to DockerHub
#-
# name: Login to Docker Hub
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_PASSWORD }}
-
name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PAT }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v5
Expand All @@ -60,7 +72,7 @@ jobs:
platforms: ${{ matrix.platform }}
provenance: false
outputs: |
type=image,name=${{ env.DOCKERHUB_IMAGE }},push-by-digest=true,name-canonical=true,push=true
type=image,name=${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
-
name: Export digest
run: |
Expand All @@ -78,6 +90,9 @@ jobs:

merge:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs:
- build
steps:
Expand All @@ -99,20 +114,27 @@ jobs:
tags: |
${{ env.IMAGE_TAG }}
images: |
${{ env.DOCKERHUB_IMAGE }}
-
name: Login to DockerHub
${{ env.IMAGE_NAME }}
#-
# name: Login to Docker Hub
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_PASSWORD }}
-
name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PAT }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
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 ' *)
$(printf '${{ env.IMAGE_NAME }}@sha256:%s ' *)
-
name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.DOCKERHUB_IMAGE }}:${{ steps.meta.outputs.version }}
docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}
2 changes: 2 additions & 0 deletions .github/workflows/build_ubuntu.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Build Ubuntu
on:
push:
branches:
- master
pull_request:

jobs:
Expand Down
6 changes: 3 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM alpine AS build
RUN apk add --no-cache alpine-sdk gcc linux-headers libxml2-dev cmake libusb-dev bash samurai

ADD https://api.github.com/repos/wmbusmeters/wmbusmeters/git/refs/heads/master version.json
ADD https://api.github.com/repos/testuser7/wmbusmeters/git/refs/heads/master version.json
RUN git clone https://github.com/steve-m/librtlsdr.git && \
git clone https://github.com/wmbusmeters/wmbusmeters.git && \
git clone https://github.com/testuser7/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/ED6E0F17/rtl_reset.git
Expand All @@ -27,7 +27,7 @@ WORKDIR /rtl_reset
RUN make

FROM alpine as scratch
RUN apk add --no-cache mosquitto-clients libstdc++ curl libusb libxml2 netcat-openbsd
RUN apk add --no-cache mosquitto-clients libstdc++ curl libusb libxml2 netcat-openbsd bash
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
Expand Down
2 changes: 1 addition & 1 deletion docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

[ ! -d /wmbusmeters_data/logs/meter_readings ] && mkdir -p /wmbusmeters_data/logs/meter_readings
[ ! -d /wmbusmeters_data/etc/wmbusmeters.d ] && mkdir -p /wmbusmeters_data/etc/wmbusmeters.d
Expand Down

0 comments on commit a39cb43

Please sign in to comment.