2020-03-21 01:20:16 +03:00
|
|
|
# Build
|
2022-08-01 06:22:17 +03:00
|
|
|
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/
|
2022-11-08 02:16:05 +03:00
|
|
|
COPY ./app/middleware/*.go ./app/middleware/
|
2022-08-01 06:22:17 +03:00
|
|
|
COPY ./importers/*.go ./importers/
|
|
|
|
COPY ./media/*.go ./media/
|
|
|
|
COPY ./utils/*.go ./utils/
|
2023-01-21 04:26:31 +03:00
|
|
|
COPY ./cmd/tube/*.go ./tube/yarnd/
|
2022-08-01 06:22:17 +03:00
|
|
|
|
|
|
|
# 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"
|
2023-01-21 04:25:30 +03:00
|
|
|
ARG BUILD=""
|
2022-08-01 06:22:17 +03:00
|
|
|
|
|
|
|
# Build server binary
|
2023-01-21 04:25:30 +03:00
|
|
|
RUN make server VERSION=$VERSION COMMIT=$COMMIT BUILD=$BUILD
|
2020-03-21 01:20:16 +03:00
|
|
|
|
|
|
|
# Runtime
|
2022-08-01 06:22:17 +03:00
|
|
|
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 /
|
2020-03-21 04:03:00 +03:00
|
|
|
|
2022-08-01 06:22:17 +03:00
|
|
|
# force cgo resolver
|
|
|
|
ENV GODEBUG=netdns=cgo
|
2020-03-21 04:03:00 +03:00
|
|
|
|
2022-08-01 06:22:17 +03:00
|
|
|
COPY --from=build /src/tube /usr/local/bin/tube
|
2020-03-21 01:20:16 +03:00
|
|
|
|
2022-08-01 06:22:17 +03:00
|
|
|
COPY .dockerfiles/entrypoint.sh /init
|
|
|
|
COPY .dockerfiles/config.json /
|
2020-03-21 01:20:16 +03:00
|
|
|
|
2022-08-01 06:22:17 +03:00
|
|
|
ENTRYPOINT ["/init"]
|
|
|
|
CMD ["tube"]
|