Skip to content

Commit 0e49a06

Browse files
committed
Docker files refactoring
1 parent fcb786c commit 0e49a06

File tree

4 files changed

+13
-32
lines changed

4 files changed

+13
-32
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ jobs:
156156
uses: docker/build-push-action@v5
157157
with:
158158
context: .
159+
file: docker/Dockerfile
159160
platforms: |
160161
linux/amd64
161162
linux/386
@@ -215,7 +216,7 @@ jobs:
215216
uses: docker/build-push-action@v5
216217
with:
217218
context: .
218-
file: hardware.Dockerfile
219+
file: docker/hardware.Dockerfile
219220
platforms: linux/amd64
220221
push: ${{ github.event_name != 'pull_request' }}
221222
tags: ${{ steps.meta-hw.outputs.tags }}

.github/workflows/test.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ jobs:
7979
uses: docker/build-push-action@v5
8080
with:
8181
context: .
82+
file: docker/Dockerfile
8283
platforms: linux/${{ matrix.platform }}
8384
push: false
8485
load: true
@@ -92,7 +93,7 @@ jobs:
9293
uses: docker/build-push-action@v5
9394
with:
9495
context: .
95-
file: hardware.Dockerfile
96+
file: docker/hardware.Dockerfile
9697
platforms: linux/amd64
9798
push: false
9899
load: true

Dockerfile renamed to docker/Dockerfile

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,7 @@ ARG PYTHON_VERSION="3.11"
55
ARG GO_VERSION="1.24"
66

77

8-
# 1. Download ngrok binary (for support arm/v6)
9-
FROM alpine AS ngrok
10-
ARG TARGETARCH
11-
ARG TARGETOS
12-
13-
ADD https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-${TARGETOS}-${TARGETARCH}.tgz /
14-
RUN tar -xzf /ngrok-v3-stable-${TARGETOS}-${TARGETARCH}.tgz -C /bin
15-
16-
17-
# 2. Build go2rtc binary
8+
# 1. Build go2rtc binary
189
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine AS build
1910
ARG TARGETPLATFORM
2011
ARG TARGETOS
@@ -35,7 +26,7 @@ COPY . .
3526
RUN --mount=type=cache,target=/root/.cache/go-build CGO_ENABLED=0 go build -ldflags "-s -w" -trimpath
3627

3728

38-
# 3. Final image
29+
# 2. Final image
3930
FROM python:${PYTHON_VERSION}-alpine AS base
4031

4132
# Install ffmpeg, tini (for signal handling),
@@ -55,7 +46,6 @@ RUN if [ "${TARGETARCH}" = "amd64" ]; then apk add --no-cache libva-intel-driver
5546
# RUN libva-vdpau-driver mesa-vdpau-gallium (+150MB total)
5647

5748
COPY --from=build /build/go2rtc /usr/local/bin/
58-
COPY --from=ngrok /bin/ngrok /usr/local/bin/
5949

6050
ENTRYPOINT ["/sbin/tini", "--"]
6151
VOLUME /config

hardware.Dockerfile renamed to docker/hardware.Dockerfile

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,10 @@
55
# https://packages.debian.org/trixie/ffmpeg
66
ARG DEBIAN_VERSION="trixie-slim"
77
ARG GO_VERSION="1.24-bookworm"
8-
ARG NGROK_VERSION="3"
9-
10-
FROM debian:${DEBIAN_VERSION} AS base
11-
FROM golang:${GO_VERSION} AS go
12-
FROM ngrok/ngrok:${NGROK_VERSION} AS ngrok
138

149

1510
# 1. Build go2rtc binary
16-
FROM --platform=$BUILDPLATFORM go AS build
11+
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION} AS build
1712
ARG TARGETPLATFORM
1813
ARG TARGETOS
1914
ARG TARGETARCH
@@ -31,34 +26,28 @@ COPY . .
3126
RUN --mount=type=cache,target=/root/.cache/go-build CGO_ENABLED=0 go build -ldflags "-s -w" -trimpath
3227

3328

34-
# 2. Collect all files
35-
FROM scratch AS rootfs
36-
37-
COPY --link --from=build /build/go2rtc /usr/local/bin/
38-
COPY --link --from=ngrok /bin/ngrok /usr/local/bin/
29+
# 2. Final image
30+
FROM debian:${DEBIAN_VERSION}
3931

40-
# 3. Final image
41-
FROM base
4232
# Prepare apt for buildkit cache
4333
RUN rm -f /etc/apt/apt.conf.d/docker-clean \
4434
&& echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' >/etc/apt/apt.conf.d/keep-cache
45-
# Install ffmpeg, bash (for run.sh), tini (for signal handling),
35+
36+
# Install ffmpeg, tini (for signal handling),
4637
# and other common tools for the echo source.
4738
# non-free for Intel QSV support (not used by go2rtc, just for tests)
4839
# mesa-va-drivers for AMD APU
4940
# libasound2-plugins for ALSA support
5041
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked --mount=type=cache,target=/var/lib/apt,sharing=locked \
5142
echo 'deb http://deb.debian.org/debian trixie non-free' > /etc/apt/sources.list.d/debian-non-free.list && \
52-
apt-get -y update && apt-get -y install tini ffmpeg \
43+
apt-get -y update && apt-get -y install ffmpeg tini \
5344
python3 curl jq \
5445
intel-media-va-driver-non-free \
5546
mesa-va-drivers \
5647
libasound2-plugins && \
5748
apt-get clean && rm -rf /var/lib/apt/lists/*
5849

59-
COPY --link --from=rootfs / /
60-
61-
50+
COPY --from=build /build/go2rtc /usr/local/bin/
6251

6352
ENTRYPOINT ["/usr/bin/tini", "--"]
6453
VOLUME /config

0 commit comments

Comments
 (0)