Dockerfile 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # syntax=docker/dockerfile:labs
  2. # 0. Prepare images
  3. ARG PYTHON_VERSION="3.11"
  4. ARG GO_VERSION="1.22"
  5. # 1. Download ngrok binary (for support arm/v6)
  6. FROM alpine AS ngrok
  7. ARG TARGETARCH
  8. ARG TARGETOS
  9. ADD https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-${TARGETOS}-${TARGETARCH}.tgz /
  10. RUN tar -xzf /ngrok-v3-stable-${TARGETOS}-${TARGETARCH}.tgz -C /bin
  11. # 2. Build go2rtc binary
  12. FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine AS build
  13. ARG TARGETPLATFORM
  14. ARG TARGETOS
  15. ARG TARGETARCH
  16. ENV GOOS=${TARGETOS}
  17. ENV GOARCH=${TARGETARCH}
  18. WORKDIR /build
  19. RUN apk add git
  20. # Cache dependencies
  21. COPY go.mod go.sum ./
  22. RUN --mount=type=cache,target=/root/.cache/go-build go mod download
  23. COPY . .
  24. RUN --mount=type=cache,target=/root/.cache/go-build CGO_ENABLED=0 go build -ldflags "-s -w" -trimpath
  25. # 3. Final image
  26. FROM python:${PYTHON_VERSION}-alpine AS base
  27. # Install ffmpeg, tini (for signal handling),
  28. # and other common tools for the echo source.
  29. # alsa-plugins-pulse for ALSA support (+0MB)
  30. # font-droid for FFmpeg drawtext filter (+2MB)
  31. RUN apk add --no-cache tini ffmpeg bash curl jq alsa-plugins-pulse font-droid
  32. # Hardware Acceleration for Intel CPU (+50MB)
  33. ARG TARGETARCH
  34. RUN if [ "${TARGETARCH}" = "amd64" ]; then apk add --no-cache libva-intel-driver intel-media-driver; fi
  35. # Hardware: AMD and NVidia VAAPI (not sure about this)
  36. # RUN libva-glx mesa-va-gallium
  37. # Hardware: AMD and NVidia VDPAU (not sure about this)
  38. # RUN libva-vdpau-driver mesa-vdpau-gallium (+150MB total)
  39. COPY --from=build /build/go2rtc /usr/local/bin/
  40. COPY --from=ngrok /bin/ngrok /usr/local/bin/
  41. ENTRYPOINT ["/sbin/tini", "--"]
  42. VOLUME /config
  43. WORKDIR /config
  44. CMD ["go2rtc", "-config", "/config/go2rtc.yaml"]