From 0a95aae42bd5fef585e0c757a4bd6b43c32a8a8b Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Thu, 1 Oct 2020 09:29:25 +0200 Subject: [PATCH] :tada: libsrt got packaged in community's Alpine Linux repo, FFMPEG is compiled with libsrt, so we use Alpine Linux --- .gitlab-ci.yml | 3 +-- Dockerfile | 14 ++++++-------- Dockerfile.bullseye | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+), 10 deletions(-) create mode 100644 Dockerfile.bullseye diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5c3c80c..49cff20 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,8 +6,7 @@ unit_tests: image: golang:1.15-alpine stage: test before_script: - - apk add --no-cache build-base gcc - - apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing libsrt-dev + - apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/community build-base ffmpeg gcc libsrt-dev script: - go test -v -covermode=count -coverprofile cover.cov ./... - go tool cover -func=cover.cov diff --git a/Dockerfile b/Dockerfile index 1d411ff..0724fad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,17 @@ # Install dependencies then build ghostream -FROM debian:bullseye-slim AS build_base -RUN apt-get update && \ - apt-get install -y --no-install-recommends ca-certificates \ - gcc golang libc6-dev libsrt1 libsrt-openssl-dev musl-dev +FROM golang:1.15-alpine AS build_base +RUN apk add --no-cache gcc libsrt-dev musl-dev WORKDIR /code COPY go.* ./ RUN go mod download && go get github.com/markbates/pkger/cmd/pkger COPY . . -RUN PATH=/root/go/bin:$PATH go generate && go build -o ./out/ghostream . +RUN go generate && go build -o ./out/ghostream . # Production image -FROM debian:bullseye-slim -RUN apt-get update && apt-get install -y ffmpeg libsrt1 musl +FROM alpine:3.12 +RUN apk add ffmpeg libsrt COPY --from=build_base /code/out/ghostream /app/ghostream WORKDIR /app -# 9710 (UDP) for SRT, 8080 for Web, 2112 for monitoring and 10000-10005 (UDP) for WebRTC +# 9710 for SRT, 8080 for Web, 2112 for monitoring and 10000-10005 (UDP) for WebRTC EXPOSE 9710/udp 8080 2112 10000-10005/udp CMD ["/app/ghostream"] diff --git a/Dockerfile.bullseye b/Dockerfile.bullseye new file mode 100644 index 0000000..1d411ff --- /dev/null +++ b/Dockerfile.bullseye @@ -0,0 +1,19 @@ +# Install dependencies then build ghostream +FROM debian:bullseye-slim AS build_base +RUN apt-get update && \ + apt-get install -y --no-install-recommends ca-certificates \ + gcc golang libc6-dev libsrt1 libsrt-openssl-dev musl-dev +WORKDIR /code +COPY go.* ./ +RUN go mod download && go get github.com/markbates/pkger/cmd/pkger +COPY . . +RUN PATH=/root/go/bin:$PATH go generate && go build -o ./out/ghostream . + +# Production image +FROM debian:bullseye-slim +RUN apt-get update && apt-get install -y ffmpeg libsrt1 musl +COPY --from=build_base /code/out/ghostream /app/ghostream +WORKDIR /app +# 9710 (UDP) for SRT, 8080 for Web, 2112 for monitoring and 10000-10005 (UDP) for WebRTC +EXPOSE 9710/udp 8080 2112 10000-10005/udp +CMD ["/app/ghostream"]