-
Notifications
You must be signed in to change notification settings - Fork 0
/
chronicler-worker.dockerfile
52 lines (42 loc) · 1.25 KB
/
chronicler-worker.dockerfile
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
FROM golang:alpine AS builder
# Git is required for fetching the dependencies.
RUN apk update && apk add --no-cache git build-base
# Create appuser.
ENV USER=appuser
ENV UID=10001
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
"${USER}"
WORKDIR $GOPATH/src/chronicler/worker/
COPY go.mod ./
RUN go mod download
RUN go mod verify
RUN go get -u -v github.com/mattn/go-sqlite3
COPY cmd cmd
COPY pkg pkg
COPY internal internal
# Build the binary.
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /go/bin/worker ./cmd/worker
FROM python:alpine
RUN apk update && apk add --no-cache \
ca-certificates \
ffmpeg \
&& pip3 install -U youtube-dl \
&& \
rm -rf /var/cache/apk/*
# Import the user and group files from the builder.
COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /etc/group /etc/group
# Copy our executable.
COPY --from=builder /go/bin/worker /go/bin/worker
RUN mkdir /downloads && chown -R appuser /downloads
RUN mkdir /data && chown -R appuser /data
# Use an unprivileged user.
USER appuser:appuser
WORKDIR /workdir
ENTRYPOINT ["/go/bin/worker"]