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 <geekgonecrazy@users.noreply.github.com>

Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com>
This commit is contained in:
Gabe Kangas
2020-09-26 00:44:43 -07:00
committed by GitHub
parent ec9f8ba004
commit c9d6366b3b

View File

@@ -1,9 +1,9 @@
FROM golang:alpine # Perform a build
FROM golang:alpine AS build
EXPOSE 8080 1935 EXPOSE 8080 1935
RUN mkdir /app RUN mkdir /build
ADD . /app ADD . /build
WORKDIR /app WORKDIR /build
RUN apk add --no-cache ffmpeg ffmpeg-libs
RUN apk update && apk add --no-cache gcc build-base linux-headers RUN apk update && apk add --no-cache gcc build-base linux-headers
ARG VERSION 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 . 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 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"] CMD ["/app/owncast"]