diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 739c4e17..ef97b47a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -156,6 +156,7 @@ jobs: uses: docker/build-push-action@v5 with: context: . + file: docker/Dockerfile platforms: | linux/amd64 linux/386 @@ -215,7 +216,7 @@ jobs: uses: docker/build-push-action@v5 with: context: . - file: hardware.Dockerfile + file: docker/hardware.Dockerfile platforms: linux/amd64 push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta-hw.outputs.tags }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f2089dec..5d9e7e25 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -79,6 +79,7 @@ jobs: uses: docker/build-push-action@v5 with: context: . + file: docker/Dockerfile platforms: linux/${{ matrix.platform }} push: false load: true @@ -92,7 +93,7 @@ jobs: uses: docker/build-push-action@v5 with: context: . - file: hardware.Dockerfile + file: docker/hardware.Dockerfile platforms: linux/amd64 push: false load: true diff --git a/Dockerfile b/docker/Dockerfile similarity index 79% rename from Dockerfile rename to docker/Dockerfile index ba436825..34a96757 100644 --- a/Dockerfile +++ b/docker/Dockerfile @@ -5,16 +5,7 @@ ARG PYTHON_VERSION="3.11" ARG GO_VERSION="1.24" -# 1. Download ngrok binary (for support arm/v6) -FROM alpine AS ngrok -ARG TARGETARCH -ARG TARGETOS - -ADD https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-${TARGETOS}-${TARGETARCH}.tgz / -RUN tar -xzf /ngrok-v3-stable-${TARGETOS}-${TARGETARCH}.tgz -C /bin - - -# 2. Build go2rtc binary +# 1. Build go2rtc binary FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine AS build ARG TARGETPLATFORM ARG TARGETOS @@ -35,7 +26,7 @@ COPY . . RUN --mount=type=cache,target=/root/.cache/go-build CGO_ENABLED=0 go build -ldflags "-s -w" -trimpath -# 3. Final image +# 2. Final image FROM python:${PYTHON_VERSION}-alpine AS base # Install ffmpeg, tini (for signal handling), @@ -55,7 +46,6 @@ RUN if [ "${TARGETARCH}" = "amd64" ]; then apk add --no-cache libva-intel-driver # RUN libva-vdpau-driver mesa-vdpau-gallium (+150MB total) COPY --from=build /build/go2rtc /usr/local/bin/ -COPY --from=ngrok /bin/ngrok /usr/local/bin/ ENTRYPOINT ["/sbin/tini", "--"] VOLUME /config diff --git a/hardware.Dockerfile b/docker/hardware.Dockerfile similarity index 75% rename from hardware.Dockerfile rename to docker/hardware.Dockerfile index e75a97cd..03b7d496 100644 --- a/hardware.Dockerfile +++ b/docker/hardware.Dockerfile @@ -5,15 +5,10 @@ # https://packages.debian.org/trixie/ffmpeg ARG DEBIAN_VERSION="trixie-slim" ARG GO_VERSION="1.24-bookworm" -ARG NGROK_VERSION="3" - -FROM debian:${DEBIAN_VERSION} AS base -FROM golang:${GO_VERSION} AS go -FROM ngrok/ngrok:${NGROK_VERSION} AS ngrok # 1. Build go2rtc binary -FROM --platform=$BUILDPLATFORM go AS build +FROM --platform=$BUILDPLATFORM golang:${GO_VERSION} AS build ARG TARGETPLATFORM ARG TARGETOS ARG TARGETARCH @@ -31,34 +26,28 @@ COPY . . RUN --mount=type=cache,target=/root/.cache/go-build CGO_ENABLED=0 go build -ldflags "-s -w" -trimpath -# 2. Collect all files -FROM scratch AS rootfs +# 2. Final image +FROM debian:${DEBIAN_VERSION} -COPY --link --from=build /build/go2rtc /usr/local/bin/ -COPY --link --from=ngrok /bin/ngrok /usr/local/bin/ - -# 3. Final image -FROM base # 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, bash (for run.sh), tini (for signal handling), + +# Install ffmpeg, tini (for signal handling), # and other common tools for the echo source. # non-free for Intel QSV support (not used by go2rtc, just for tests) # mesa-va-drivers for AMD APU # libasound2-plugins for ALSA support RUN --mount=type=cache,target=/var/cache/apt,sharing=locked --mount=type=cache,target=/var/lib/apt,sharing=locked \ echo 'deb http://deb.debian.org/debian trixie non-free' > /etc/apt/sources.list.d/debian-non-free.list && \ - apt-get -y update && apt-get -y install tini ffmpeg \ + apt-get -y update && apt-get -y install ffmpeg tini \ python3 curl jq \ intel-media-va-driver-non-free \ mesa-va-drivers \ libasound2-plugins && \ apt-get clean && rm -rf /var/lib/apt/lists/* -COPY --link --from=rootfs / / - - +COPY --from=build /build/go2rtc /usr/local/bin/ ENTRYPOINT ["/usr/bin/tini", "--"] VOLUME /config