-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docker: Add official local docker support
Lets add our own docker container and use github actions to build and push it. For now, only the alpine container is built and pushed, but we can very easily add a matrix entry for a debian container if there's enough demand. Best to reduce the amount of configurations we offer, as it also means more that can break. Signed-off-by: Olliver Schinagl <[email protected]>
- Loading branch information
Showing
6 changed files
with
183 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
examples/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
name: Create and publish Container image | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
tags: | ||
- '[0-9]+.[0-9]+*' | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
build-and-push-image: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
strategy: | ||
matrix: | ||
include: | ||
- container: ./dist/Containerfile | ||
autotag: auto | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to Container registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: | | ||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
tags: | | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
type=edge | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{major}} | ||
flavor: | | ||
latest=${{ matrix.autotag }} | ||
suffix=${{ matrix.suffix }} | ||
- name: Build and push | ||
uses: docker/build-push-action@v6 | ||
with: | ||
platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v7,linux/arm/v6 | ||
context: . | ||
file: ${{ matrix.container }} | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# SPDX-License-Identifier: GPL-2.0-or-later | ||
# | ||
# Copyright (C) 2024 Olliver Schinagl <[email protected]> | ||
|
||
ARG ALPINE_VERSION="latest" | ||
ARG TARGET_ARCH="library" | ||
|
||
FROM docker.io/${TARGET_ARCH}/alpine:${ALPINE_VERSION} AS builder | ||
|
||
WORKDIR /src | ||
|
||
COPY . /src/ | ||
|
||
RUN apk add --no-cache \ | ||
'build-base' \ | ||
'cmake' \ | ||
'git' \ | ||
'librtlsdr-dev' \ | ||
'libusb-dev' \ | ||
'ninja' \ | ||
'openssl-dev>3' \ | ||
'soapy-sdr-dev' \ | ||
&& \ | ||
cmake -B '.build' -GNinja \ | ||
-DFORCE_COLORED_BUILD:BOOL=ON \ | ||
-DCMAKE_BUILD_TYPE=Release \ | ||
-DCMAKE_INSTALL_PREFIX='/usr' \ | ||
-DCMAKE_INSTALL_SYSCONFDIR='/etc' \ | ||
-DENABLE_OPENSSL=ON \ | ||
&& \ | ||
cmake --build '.build' -j $(($(nproc) -1 )) && \ | ||
DESTDIR='/rtl_433' cmake --build '.build' --target install && \ | ||
rm -f -r '/rtl_433/include' && \ | ||
rm -f -r '/rtl_433/usr/share' | ||
|
||
FROM docker.io/${TARGET_ARCH}/alpine:${ALPINE_VERSION} | ||
|
||
LABEL maintainer="Olliver Schinagl <[email protected]>" | ||
|
||
RUN apk add --no-cache \ | ||
'librtlsdr' \ | ||
'libusb' \ | ||
'openssl' \ | ||
'soapy-sdr-libs' \ | ||
'tini' \ | ||
'tzdata' \ | ||
; | ||
|
||
COPY --from=builder "/rtl_433" "/" | ||
COPY "dist/container-entrypoint.sh" "/init" | ||
|
||
ENTRYPOINT [ "/sbin/tini", "--", "/init" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/sh | ||
# SPDX-License-Identifier: GPL-2.0-or-later | ||
# | ||
# Copyright (C) 2024 Olliver Schinagl <[email protected]> | ||
# | ||
# A beginning user should be able to docker run image bash (or sh) without | ||
# needing to learn about --entrypoint | ||
# https://github.com/docker-library/official-images#consistency | ||
|
||
set -eu | ||
if [ -n "${DEBUG_TRACE_SH:-}" ] && \ | ||
[ "${DEBUG_TRACE_SH:-}" != "${DEBUG_TRACE_SH#*"$(basename "${0}")"*}" ] || \ | ||
[ "${DEBUG_TRACE_SH:-}" = 'all' ]; then | ||
set -x | ||
fi | ||
|
||
bin='rtl_433' | ||
|
||
# Prefix args with $bin if $1 is not a valid command | ||
if ! command -v -- "${1:-}" > '/dev/null' 2>&1; then | ||
set -- "${bin:?}" "${@}" | ||
fi | ||
exec "${@}" | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters