From c9d6366b3b723387cdf572e3463b5ddc1ed7559b Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Sat, 26 Sep 2020 00:44:43 -0700 Subject: [PATCH] Create release docker image without shipping source and go toolchain. (#188) * Create release docker image without shipping source and go toolchain. Closes #185 * Explicitly add ca-certificates to image * Combine apk run commands * Update scripts/Dockerfile-build Co-authored-by: Aaron Ogle Co-authored-by: Aaron Ogle --- scripts/Dockerfile-build | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/scripts/Dockerfile-build b/scripts/Dockerfile-build index 8b829f9dc..ef2d22e56 100644 --- a/scripts/Dockerfile-build +++ b/scripts/Dockerfile-build @@ -1,9 +1,9 @@ -FROM golang:alpine +# Perform a build +FROM golang:alpine AS build EXPOSE 8080 1935 -RUN mkdir /app -ADD . /app -WORKDIR /app -RUN apk add --no-cache ffmpeg ffmpeg-libs +RUN mkdir /build +ADD . /build +WORKDIR /build RUN apk update && apk add --no-cache gcc build-base linux-headers ARG VERSION @@ -15,5 +15,15 @@ ENV NAME=${NAME} RUN CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -ldflags "-extldflags \"-static\" -s -w -X main.GitCommit=$GIT_COMMIT -X main.BuildVersion=$VERSION -X main.BuildType=$NAME" -o owncast . +# Create the image by copying the result of the build into a new alpine image +FROM alpine +RUN apk update && apk add --no-cache ffmpeg ffmpeg-libs ca-certificates && update-ca-certificates + +# Copy owncast assets WORKDIR /app +COPY --from=build /build/owncast /app/owncast +COPY --from=build /build/config.yaml /app/config.yaml +COPY --from=build /build/webroot /app/webroot +COPY --from=build /build/static /app/static + CMD ["/app/owncast"]