From 4590bd674be67c7b961abac624ed81cfc52b8c1d Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Sat, 22 May 2021 03:18:42 +0200 Subject: [PATCH] feat: use multi-stage-builds for Docker (#1003) --- Dockerfile | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 01120ceff..635e09a25 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,18 @@ -FROM golang:alpine -EXPOSE 8080 1935 +FROM golang:alpine AS build +RUN apk add --no-cache gcc build-base linux-headers + +WORKDIR /build +COPY . /build +RUN CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o owncast . + + +FROM alpine +RUN apk add --no-cache ffmpeg ffmpeg-libs + WORKDIR /app -ADD . . -RUN set -ex && \ - apk add --no-cache ffmpeg ffmpeg-libs && \ - apk add --no-cache gcc build-base linux-headers && \ - CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o owncast . +COPY webroot /app/webroot +COPY static /app/static +COPY --from=build /build/owncast /app/owncast + +EXPOSE 8080 1935 CMD ["/app/owncast"]