From b1701e856aa9e6de1a5bad7733bb872242608af8 Mon Sep 17 00:00:00 2001 From: Sergey Krashevich Date: Tue, 28 Mar 2023 07:30:30 +0300 Subject: [PATCH] Update hardware.Dockerfile --- hardware.Dockerfile | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/hardware.Dockerfile b/hardware.Dockerfile index ccdb7fbb..f1f7630e 100644 --- a/hardware.Dockerfile +++ b/hardware.Dockerfile @@ -1,3 +1,5 @@ +# syntax=docker/dockerfile:labs + # 0. Prepare images # only debian 12 (bookworm) has latest ffmpeg ARG DEBIAN_VERSION="bookworm-slim" @@ -16,37 +18,39 @@ WORKDIR /build # Cache dependencies COPY go.mod go.sum ./ -RUN go mod download +RUN --mount=type=cache,target=/root/.cache/go-build go mod download COPY . . -RUN CGO_ENABLED=0 go build -ldflags "-s -w" -trimpath +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 -COPY --from=build /build/go2rtc /usr/local/bin/ -COPY --from=ngrok /bin/ngrok /usr/local/bin/ -COPY ./build/docker/run.sh / - +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), # and other common tools for the echo source. # non-free for Intel QSV support (not used by go2rtc, just for tests) -RUN echo 'deb http://deb.debian.org/debian bookworm non-free' > /etc/apt/sources.list.d/debian-non-free.list && \ +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 bookworm non-free' > /etc/apt/sources.list.d/debian-non-free.list && \ apt-get -y update && apt-get -y install tini ffmpeg python3 curl jq intel-media-va-driver-non-free -COPY --from=rootfs / / +COPY --link --from=rootfs / / + -RUN chmod a+x /run.sh && mkdir -p /config ENTRYPOINT ["/usr/bin/tini", "--"] - +VOLUME /config +WORKDIR /config # https://github.com/NVIDIA/nvidia-docker/wiki/Installation-(Native-GPU-Support) ENV NVIDIA_VISIBLE_DEVICES all ENV NVIDIA_DRIVER_CAPABILITIES compute,video,utility -CMD ["/run.sh"] +CMD ["go2rtc", "-config", "/config/go2rtc.yaml"]