summaryrefslogtreecommitdiff
path: root/Dockerfile
blob: 513c7fd67c697076ebd384cf6835501bb0ff0f4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# 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 ./app/middleware/*.go ./app/middleware/
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"
ARG BUILD=""

# Build server binary
RUN make server VERSION=$VERSION COMMIT=$COMMIT BUILD=$BUILD

# Runtime
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 /

# force cgo resolver
ENV GODEBUG=netdns=cgo

COPY --from=build /src/tube /usr/local/bin/tube

COPY .dockerfiles/entrypoint.sh /init
COPY .dockerfiles/config.json /

ENTRYPOINT ["/init"]
CMD ["tube"]