From 35217febfc2c5d6a7e5d5d2b0b3c10a168fb2ed1 Mon Sep 17 00:00:00 2001 From: James Mills Date: Mon, 1 Aug 2022 03:22:17 +0000 Subject: Add support for multi-arch binary and docker image releases (#20) Reviewed-on: https://git.mills.io/prologic/tube/pulls/20 --- Dockerfile | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 63 insertions(+), 7 deletions(-) (limited to 'Dockerfile') diff --git a/Dockerfile b/Dockerfile index 1257ed1..2049e14 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,70 @@ # Build -FROM prologic/go-builder:latest AS build +FROM golang:alpine AS build + +RUN apk add --no-cache -U build-base git make ffmpeg-dev + +RUN mkdir -p /src + +WORKDIR /src + +# Copy Makefile +COPY Makefile ./ + +# Install deps +RUN make deps + +# Copy go.mod and go.sum and install and cache dependencies +COPY go.mod . +COPY go.sum . + +# Copy static assets +COPY ./static/* ./static/ + +# Copy templates + +COPY ./templates/* ./templates/ + +# Copy sources +COPY *.go ./ +COPY ./app/*.go ./app/ +COPY ./importers/*.go ./importers/ +COPY ./media/*.go ./media/ +COPY ./utils/*.go ./utils/ + +# Version/Commit (there there is no .git in Docker build context) +# NOTE: This is fairly low down in the Dockerfile instructions so +# we don't break the Docker build cache just be changing +# unrelated files that actually haven't changed but caused the +# COMMIT value to change. +ARG VERSION="0.0.0" +ARG COMMIT="HEAD" + +# Build server binary +RUN make server VERSION=$VERSION COMMIT=$COMMIT # Runtime -FROM golang:alpine +FROM alpine:latest + +RUN apk --no-cache -U add su-exec shadow ca-certificates tzdata ffmpeg + +ENV PUID=1000 +ENV PGID=1000 + +RUN addgroup -g "${PGID}" tube && \ + adduser -D -H -G tube -h /var/empty -u "${PUID}" tube && \ + mkdir -p /data && chown -R tube:tube /data + +VOLUME /data + +WORKDIR / -RUN apk --no-cache -U add git build-base ffmpeg ffmpeg-dev +# force cgo resolver +ENV GODEBUG=netdns=cgo -RUN go install github.com/mutschler/mt@latest +COPY --from=build /src/tube /usr/local/bin/tube -COPY --from=build /src/tube /tube +COPY .dockerfiles/entrypoint.sh /init +COPY .dockerfiles/config.json / -ENTRYPOINT ["/tube"] -CMD [""] +ENTRYPOINT ["/init"] +CMD ["tube"] -- cgit v1.2.3