Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(docker): update Dockerfiles to use ENTRYPOINT instead of CMD #1016

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
11 changes: 6 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# syntax=docker/dockerfile:labs
# syntax=docker/dockerfile:1.4

# 0. Prepare images
ARG PYTHON_VERSION="3.11"
Expand Down Expand Up @@ -32,7 +32,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build CGO_ENABLED=0 go build -ldfl
FROM scratch AS rootfs

COPY --from=build /build/go2rtc /usr/local/bin/
COPY --from=ngrok /bin/ngrok /usr/local/bin/
COPY --link --from=ngrok /bin/ngrok /usr/local/bin/


# 3. Final image
Expand All @@ -54,10 +54,11 @@ RUN if [ "${TARGETARCH}" = "amd64" ]; then apk add --no-cache libva-intel-driver
# Hardware: AMD and NVidia VDPAU (not sure about this)
# RUN libva-vdpau-driver mesa-vdpau-gallium (+150MB total)

COPY --from=rootfs / /
COPY --link --from=rootfs / /

ENTRYPOINT ["/sbin/tini", "--"]
COPY --chmod=755 entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/sbin/tini", "--", "/entrypoint.sh"]
VOLUME /config
WORKDIR /config

CMD ["go2rtc", "-config", "/config/go2rtc.yaml"]
10 changes: 10 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

CONFIG_PATH=${CONFIG_PATH:-/config/go2rtc.yaml}
PORT=${PORT:-1984}

if [ ! -f "$CONFIG_PATH" ]; then
mkdir -p "$(dirname "$CONFIG_PATH")"
fi

exec go2rtc -config "{ api: { listen: \":$PORT\" } }" -config "$CONFIG_PATH" "$@"
16 changes: 6 additions & 10 deletions hardware.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# syntax=docker/dockerfile:labs
# syntax=docker/dockerfile:1.4

# 0. Prepare images
# only debian 13 (trixie) has latest ffmpeg
Expand All @@ -7,9 +7,9 @@ ARG DEBIAN_VERSION="trixie-slim"
ARG GO_VERSION="1.21-bookworm"
ARG NGROK_VERSION="3"

FROM debian:${DEBIAN_VERSION} AS base
FROM --platform=linux/amd64 debian:${DEBIAN_VERSION} AS base
FROM golang:${GO_VERSION} AS go
FROM ngrok/ngrok:${NGROK_VERSION} AS ngrok
FROM --platform=linux/amd64 ngrok/ngrok:${NGROK_VERSION} AS ngrok


# 1. Build go2rtc binary
Expand All @@ -30,7 +30,6 @@ 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. Collect all files
FROM scratch AS rootfs

Expand All @@ -57,14 +56,11 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked --mount=type=cache,t
apt-get clean && rm -rf /var/lib/apt/lists/*

COPY --link --from=rootfs / /
COPY --chmod=755 entrypoint.sh /entrypoint.sh



ENTRYPOINT ["/usr/bin/tini", "--"]
ENTRYPOINT ["/usr/bin/tini", "--", "/entrypoint.sh"]
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 ["go2rtc", "-config", "/config/go2rtc.yaml"]
ENV NVIDIA_DRIVER_CAPABILITIES compute,video,utility