Skip to content

Commit ce429ef

Browse files
oliv3rFlole998
authored andcommitted
container: Add container support
This commit adds support for containizersation of TVHeadend. It adds the actual technology agnostic container file, an entry point and healthcheck for it and a github workflow component to publish it. TODO: Healthcheck script is not yet working. TODO: Add decent documetnation Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
1 parent a2ddd30 commit ce429ef

10 files changed

Lines changed: 854 additions & 2 deletions

File tree

‎.dockerignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.config.mk
2+
build.*/
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Create and publish Container image
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
tags:
8+
- 'v*'
9+
pull_request:
10+
branches:
11+
- master
12+
13+
env:
14+
REGISTRY: ghcr.io
15+
IMAGE_NAME: ${{ github.repository }}
16+
17+
jobs:
18+
build-and-push-image:
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: read
22+
packages: write
23+
strategy:
24+
matrix:
25+
include:
26+
- container: Containerfile.debian
27+
autotag: false
28+
suffix: -debian
29+
- container: Containerfile.alpine
30+
autotag: auto
31+
32+
steps:
33+
- name: Checkout repository
34+
uses: actions/checkout@v3
35+
36+
- name: Set up QEMU
37+
uses: docker/setup-qemu-action@v2
38+
39+
- name: Set up Docker Buildx
40+
uses: docker/setup-buildx-action@v2
41+
42+
- name: Login to Container registry
43+
uses: docker/login-action@v2
44+
with:
45+
registry: ${{ env.REGISTRY }}
46+
username: ${{ github.actor }}
47+
password: ${{ secrets.GITHUB_TOKEN }}
48+
49+
- name: Docker meta
50+
id: meta
51+
uses: docker/metadata-action@v4
52+
with:
53+
images: |
54+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
55+
tags: |
56+
type=ref,event=branch
57+
type=ref,event=pr
58+
type=edge
59+
type=semver,pattern={{version}}
60+
type=semver,pattern={{major}}.{{minor}}
61+
type=semver,pattern={{major}}
62+
flavor: |
63+
latest=${{ matrix.autotag }}
64+
suffix=${{ matrix.suffix }}
65+
66+
- name: Build and push
67+
uses: docker/build-push-action@v4
68+
with:
69+
platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v7,linux/arm/v6
70+
context: .
71+
file: ${{ matrix.container }}
72+
push: ${{ github.event_name != 'pull_request' }}
73+
tags: ${{ steps.meta.outputs.tags }}
74+
labels: ${{ steps.meta.outputs.labels }}

‎Containerfile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Containerfile.alpine

‎Containerfile.alpine‎

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# SPDX-License-Identifier: GPL-3.0-or-later
2+
#
3+
# Copyright (C) 2023 Olliver Schinagl <oliver@schinagl.nl>
4+
5+
ARG ALPINE_VERSION="latest"
6+
ARG TARGET_ARCH="library"
7+
8+
FROM docker.io/${TARGET_ARCH}/alpine:${ALPINE_VERSION} AS builder
9+
10+
WORKDIR /src
11+
12+
COPY . /src/
13+
14+
RUN apk add --no-cache \
15+
'avahi-dev' \
16+
'bash' \
17+
'bsd-compat-headers' \
18+
'build-base' \
19+
'cmake' \
20+
'coreutils' \
21+
'dbus-dev' \
22+
'ffmpeg4-dev' \
23+
'findutils' \
24+
'gettext-dev' \
25+
'git' \
26+
'gnu-libiconv-dev' \
27+
'libdvbcsa-dev' \
28+
'libhdhomerun-dev' \
29+
'libva-dev' \
30+
'libvpx-dev' \
31+
'linux-headers' \
32+
'musl-dev' \
33+
'openssl-dev>3' \
34+
'opus-dev' \
35+
'pngquant' \
36+
'python3' \
37+
'uriparser-dev' \
38+
'wget' \
39+
'x264-dev' \
40+
'x265-dev' \
41+
'zlib-dev' \
42+
&& \
43+
git config --global --add safe.directory '/src/data/dvb-scan' && \
44+
./configure \
45+
--prefix='/usr/local' \
46+
--disable-doc \
47+
--disable-execinfo \
48+
--disable-ffmpeg_static \
49+
--disable-hdhomerun_static \
50+
--disable-libfdkaac_static \
51+
--disable-libmfx_static \
52+
--disable-libopus_static \
53+
--disable-libtheora_static \
54+
--disable-libvorbis_static \
55+
--disable-libvpx_static \
56+
--disable-libx264_static \
57+
--disable-libx265_static \
58+
--enable-bundle \
59+
--enable-dvbcsa \
60+
--enable-hdhomerun_client \
61+
--enable-kqueue \
62+
--enable-libav \
63+
--enable-nvenc \
64+
--enable-pngquant \
65+
--enable-qsv \
66+
--python=python3 \
67+
&& \
68+
make DESTDIR='/tvheadend' -j$(($(nproc) - 1)) install
69+
70+
FROM docker.io/${TARGET_ARCH}/alpine:${ALPINE_VERSION}
71+
72+
LABEL maintainer="Olliver Schinagl <oliver@schinagl.nl>"
73+
74+
EXPOSE 9981 \
75+
9982 \
76+
9983
77+
78+
RUN apk add --no-cache \
79+
'avahi' \
80+
'dbus-libs' \
81+
'ffmpeg4' \
82+
'ffmpeg4-libavcodec' \
83+
'ffmpeg4-libavdevice' \
84+
'ffmpeg4-libavfilter' \
85+
'ffmpeg4-libavfilter' \
86+
'ffmpeg4-libavformat' \
87+
'ffmpeg4-libavutil' \
88+
'ffmpeg4-libpostproc' \
89+
'ffmpeg4-libswresample' \
90+
'ffmpeg4-libswscale' \
91+
'gnu-libiconv-libs' \
92+
'libcrypto3' \
93+
'libdvbcsa' \
94+
'libhdhomerun-libs' \
95+
'libssl3' \
96+
'liburiparser' \
97+
'libva' \
98+
'libvpx' \
99+
'mesa' \
100+
'opus' \
101+
'perl-http-entity-parser' \
102+
'pngquant' \
103+
'python3' \
104+
'tini' \
105+
'x264-libs' \
106+
'x265-libs' \
107+
'xmltv' \
108+
'zlib' \
109+
&& \
110+
[ "$(uname -m)" = 'x86'* ] && apk add --no-cache \
111+
'libva-intel-driver' \
112+
; \
113+
[ "$(uname -m)" = 'x86_64' ] && apk add --no-cache \
114+
'intel-media-driver' \
115+
; \
116+
addgroup -S 'tvheadend' && \
117+
adduser -D -G 'tvheadend' -h '/var/lib/tvheadend' -s '/bin/nologin' -S 'tvheadend' && \
118+
adduser 'tvheadend' 'audio' && \
119+
adduser 'tvheadend' 'usb' && \
120+
adduser 'tvheadend' 'video' && \
121+
install -d -m 775 -g 'tvheadend' -o 'tvheadend' '/var/lib/tvheadend/recordings' && \
122+
install -d -m 775 -g 'tvheadend' -o 'tvheadend' '/var/log/tvheadend'
123+
124+
COPY --from=builder "/tvheadend" "/"
125+
COPY "./support/container-entrypoint.sh" "/init"
126+
127+
VOLUME /var/lib/tvheadend
128+
VOLUME /var/lib/tvheadend/recordings
129+
WORKDIR /var/lib/tvheadend/
130+
USER tvheadend
131+
132+
ENTRYPOINT [ "/sbin/tini", "--", "/init" ]

‎Containerfile.debian‎

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# SPDX-License-Identifier: GPL-3.0-or-later
2+
#
3+
# Copyright (C) 2023 Olliver Schinagl <oliver@schinagl.nl>
4+
5+
ARG DEBIAN_VERSION="stable-slim"
6+
ARG TARGET_ARCH="library"
7+
8+
FROM docker.io/${TARGET_ARCH}/debian:${DEBIAN_VERSION} AS builder
9+
10+
ENV DEBIAN_FRONTEND noninteractive
11+
12+
WORKDIR /src
13+
14+
COPY . /src/
15+
16+
RUN apt-get update --yes && apt-get install --yes \
17+
'build-essential' \
18+
'bzip2' \
19+
'cmake' \
20+
'debhelper' \
21+
'gettext' \
22+
'git-core' \
23+
'libavahi-client-dev' \
24+
'libavdevice-dev' \
25+
'libdbus-1-dev' \
26+
'libdvbcsa-dev' \
27+
'libhdhomerun-dev' \
28+
'libopus-dev' \
29+
'libpcre2-dev' \
30+
'libssl-dev' \
31+
'liburiparser-dev' \
32+
'libva-dev' \
33+
'libvpx-dev' \
34+
'libx264-dev' \
35+
'libx265-dev' \
36+
'lsb-release' \
37+
'pkg-config' \
38+
'pngquant' \
39+
'python3' \
40+
'python3-distutils-extra' \
41+
'python3-requests' \
42+
'wget' \
43+
'zlib1g-dev' \
44+
&& \
45+
git config --global --add safe.directory '/src/data/dvb-scan' && \
46+
./configure \
47+
--prefix='/usr/local' \
48+
--disable-doc \
49+
--disable-execinfo \
50+
--disable-ffmpeg_static \
51+
--disable-hdhomerun_static \
52+
--disable-libfdkaac_static \
53+
--disable-libmfx_static \
54+
--disable-libopus_static \
55+
--disable-libtheora_static \
56+
--disable-libvorbis_static \
57+
--disable-libvpx_static \
58+
--disable-libx264_static \
59+
--disable-libx265_static \
60+
--enable-bundle \
61+
--enable-dvbcsa \
62+
--enable-hdhomerun_client \
63+
--enable-kqueue \
64+
--enable-libav \
65+
--enable-nvenc \
66+
--enable-pngquant \
67+
--enable-qsv \
68+
--python=python3 \
69+
&& \
70+
make DESTDIR='/tvheadend' -j$(($(nproc) - 1)) install
71+
72+
FROM docker.io/${TARGET_ARCH}/debian:${DEBIAN_VERSION}
73+
74+
ENV DEBIAN_FRONTEND noninteractive
75+
76+
LABEL maintainer="Olliver Schinagl <oliver@schinagl.nl>"
77+
78+
EXPOSE 9981 \
79+
9982 \
80+
9983
81+
82+
RUN apt-get update --yes && apt-get install --yes \
83+
'libavahi-client3' \
84+
'libavcodec59' \
85+
'libavdevice59' \
86+
'libavfilter8' \
87+
'libavfilter8' \
88+
'libavutil57' \
89+
'libdbus-1-3' \
90+
'libdvbcsa1' \
91+
'libhdhomerun4' \
92+
'libpostproc56' \
93+
'libswscale6' \
94+
'libopus0' \
95+
'libpcre2-8-0' \
96+
'libssl3' \
97+
'liburiparser1' \
98+
'libva2' \
99+
'libvpx7' \
100+
'libx264-164' \
101+
'libx265-199' \
102+
'pngquant' \
103+
'python3' \
104+
'mesa-va-drivers' \
105+
'mesa-vdpau-drivers' \
106+
'zlib1g' \
107+
'xmltv' \
108+
'tini' \
109+
&& \
110+
useradd -c 'TVHeadend' -d '/var/lib/tvheadend' -G 'audio','video' -m -r -s '/bin/false' -U 'tvheadend' && \
111+
install -d -m 775 -g 'tvheadend' -o 'tvheadend' '/var/lib/tvheadend/recordings' && \
112+
install -d -m 775 -g 'tvheadend' -o 'tvheadend' '/var/log/tvheadend'
113+
114+
COPY --from=builder "/tvheadend" "/"
115+
COPY "./support/container-entrypoint.sh" "/init"
116+
117+
VOLUME /var/lib/tvheadend
118+
VOLUME /var/lib/tvheadend/recordings
119+
WORKDIR /var/lib/tvheadend/
120+
USER tvheadend
121+
122+
ENTRYPOINT [ "/usr/bin/tini", "--", "/init" ]

‎Dockerfile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Containerfile

0 commit comments

Comments
 (0)