From 71c59cfe5081fa88ef103297dc8df9f27302e42d Mon Sep 17 00:00:00 2001 From: Alex X Date: Sat, 22 Mar 2025 18:37:30 +0300 Subject: [PATCH 1/2] Add rockchip docker image --- .github/workflows/build.yml | 55 +++++++++++++++++++++++++++++++++++++ docker/rockchip.Dockerfile | 50 +++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 docker/rockchip.Dockerfile diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ef97b47a..7950004d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -223,3 +223,58 @@ jobs: labels: ${{ steps.meta-hw.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max + + docker-rockchip: + name: Build docker rockchip + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Docker meta + id: meta-rk + uses: docker/metadata-action@v5 + with: + images: | + ${{ github.repository }} + ghcr.io/${{ github.repository }} + flavor: | + suffix=-rockchip,onlatest=true + latest=auto + tags: | + type=ref,event=branch + type=semver,pattern={{version}},enable=false + type=match,pattern=v(.*),group=1 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to DockerHub + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Login to GitHub Container Registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + file: docker/rockchip.Dockerfile + platforms: linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta-rk.outputs.tags }} + labels: ${{ steps.meta-rk.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/docker/rockchip.Dockerfile b/docker/rockchip.Dockerfile new file mode 100644 index 00000000..a7a1b450 --- /dev/null +++ b/docker/rockchip.Dockerfile @@ -0,0 +1,50 @@ +# syntax=docker/dockerfile:labs + +# 0. Prepare images +ARG PYTHON_VERSION="3.13-slim-bookworm" +ARG GO_VERSION="1.24-bookworm" + + +# 1. Build go2rtc binary +FROM --platform=$BUILDPLATFORM golang:${GO_VERSION} AS build +ARG TARGETPLATFORM +ARG TARGETOS +ARG TARGETARCH + +ENV GOOS=${TARGETOS} +ENV GOARCH=${TARGETARCH} + +WORKDIR /build + +# Cache dependencies +COPY go.mod go.sum ./ +RUN --mount=type=cache,target=/root/.cache/go-build go mod download + +COPY . . +RUN --mount=type=cache,target=/root/.cache/go-build CGO_ENABLED=0 go build -ldflags "-s -w" -trimpath + + +# 2. Final image +FROM python:${PYTHON_VERSION} + +# Prepare apt for buildkit cache +RUN rm -f /etc/apt/apt.conf.d/docker-clean \ + && echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' >/etc/apt/apt.conf.d/keep-cache + +# Install ffmpeg, tini (for signal handling), +# and other common tools for the echo source. +# libasound2-plugins for ALSA support +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked --mount=type=cache,target=/var/lib/apt,sharing=locked \ + apt-get -y update && apt-get -y install tini \ + curl jq \ + libasound2-plugins && \ + apt-get clean && rm -rf /var/lib/apt/lists/* + +COPY --from=build /build/go2rtc /usr/local/bin/ +ADD --chmod=755 https://github.com/MarcA711/Rockchip-FFmpeg-Builds/releases/download/6.1-8-no_extra_dump/ffmpeg /usr/local/bin + +ENTRYPOINT ["/usr/bin/tini", "--"] +VOLUME /config +WORKDIR /config + +CMD ["go2rtc", "-config", "/config/go2rtc.yaml"] From ed5581d1d9fc056cef8db4bba7edc8ee26f01c3d Mon Sep 17 00:00:00 2001 From: Alex X Date: Sat, 22 Mar 2025 19:16:00 +0300 Subject: [PATCH 2/2] Add readme for docker --- docker/README.md | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 docker/README.md diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 00000000..b8119efc --- /dev/null +++ b/docker/README.md @@ -0,0 +1,50 @@ +## Versions + +- `alexxit/go2rtc:latest` - latest release based on `alpine` (`amd64`, `386`, `arm/v6`, `arm/v7`, `arm64`) with support hardware transcoding for Intel iGPU and Raspberry +- `alexxit/go2rtc:latest-hardware` - latest release based on `debian 13` (`amd64`) with support hardware transcoding for Intel iGPU, AMD GPU and NVidia GPU +- `alexxit/go2rtc:latest-rockchip` - latest release based on `debian 12` (`arm64`) with support hardware transcoding for Rockchip RK35xx +- `alexxit/go2rtc:master` - latest unstable version based on `alpine` +- `alexxit/go2rtc:master-hardware` - latest unstable version based on `debian 13` (`amd64`) +- `alexxit/go2rtc:master-rockchip` - latest unstable version based on `debian 12` (`arm64`) + +## Docker compose + +```yaml +services: + go2rtc: + image: alexxit/go2rtc + network_mode: host # important for WebRTC, HomeKit, UDP cameras + privileged: true # only for FFmpeg hardware transcoding + restart: unless-stopped # autorestart on fail or config change from WebUI + environment: + - TZ=Atlantic/Bermuda # timezone in logs + volumes: + - "~/go2rtc:/config" # folder for go2rtc.yaml file (edit from WebUI) +``` + +## Basic Deployment + +```bash +docker run -d \ + --name go2rtc \ + --network host \ + --privileged \ + --restart unless-stopped \ + -e TZ=Atlantic/Bermuda \ + -v ~/go2rtc:/config \ + alexxit/go2rtc +``` + +## Deployment with GPU Acceleration + +```bash +docker run -d \ + --name go2rtc \ + --network host \ + --privileged \ + --restart unless-stopped \ + -e TZ=Atlantic/Bermuda \ + --gpus all \ + -v ~/go2rtc:/config \ + alexxit/go2rtc:latest-hardware +```