mirror of
https://github.com/AlexxIT/go2rtc.git
synced 2026-04-22 23:57:20 +08:00
60 lines
1.7 KiB
Docker
60 lines
1.7 KiB
Docker
# syntax=docker/dockerfile:labs
|
|
|
|
# 0. Prepare images
|
|
ARG PYTHON_VERSION="3.13-slim-bookworm"
|
|
ARG GO_VERSION="1.26-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. Download CDN dependencies for offline web UI
|
|
FROM alpine AS download-cdn
|
|
RUN apk add --no-cache wget
|
|
COPY www/ /web/
|
|
COPY docker/download_cdn.sh /tmp/
|
|
RUN sh /tmp/download_cdn.sh /web
|
|
|
|
|
|
# 3. 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
|
|
COPY --from=download-cdn /web /var/www/go2rtc
|
|
COPY --chmod=755 docker/entrypoint.sh /usr/local/bin/
|
|
|
|
EXPOSE 1984 8554 8555 8555/udp
|
|
ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/entrypoint.sh"]
|
|
VOLUME /config
|
|
WORKDIR /config
|