-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
47 lines (31 loc) · 1.43 KB
/
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
FROM golang:alpine AS builder
LABEL stage=gobuilder
ENV CGO_ENABLED 0
ENV GOPROXY https://goproxy.cn,direct
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
RUN apk update --no-cache && apk add --no-cache tzdata
WORKDIR /build
ADD go.mod .
ADD go.sum .
RUN go mod download
COPY . .
COPY bili-danmu-auth/api/etc /usr/local/bin/etc
RUN go build -ldflags='-s -w -extldflags "-static"' -tags osusergo,netgo,sqlite_omit_load_extensio -o /usr/local/bin/danmu-auth-api bili-danmu-auth/api/danmu-auth.go
ADD https://github.com/benbjohnson/litestream/releases/download/v0.3.8/litestream-v0.3.8-linux-amd64-static.tar.gz /tmp/litestream.tar.gz
RUN tar -C /usr/local/bin -xzf /tmp/litestream.tar.gz
# FROM scratch
FROM alpine
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/Shanghai
ENV TZ Asia/Shanghai
WORKDIR /app
COPY --from=builder /usr/local/bin/danmu-auth-api /usr/local/bin/danmu-auth-api
COPY --from=builder /usr/local/bin/etc /usr/local/bin/etc
COPY --from=builder /usr/local/bin/litestream /usr/local/bin/litestream
RUN apk add bash
EXPOSE 8888
COPY etc/litestream.yml /etc/litestream.yml
COPY script/run.sh /script/run.sh
CMD [ "/script/run.sh" ]
# RUN litestream restore -v -if-replica-exists -o /data/danmu-auth-api.db "${REPLICA_URL}"
# CMD ["./danmu-auth", "-f", "etc/danmu-auth.yaml"]