FROM golang:1-alpine AS go_build
LABEL stage=buildgo

ADD . /acfunlive-src
WORKDIR /acfunlive-src

ENV GO111MODULE=on \
    GOPROXY="https://goproxy.cn" \
    CGO_ENABLED=0

RUN go build

FROM alpine

ENV BINFILE="/acfunlive/acfunlive" \
    CONFIGDIR="/acfunlive/config" \
    RECORDDIR="/acfunlive/record"

RUN mkdir -p $CONFIGDIR && \
    mkdir -p $RECORDDIR && \
    sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories && \
    apk update && \
    apk upgrade && \
    apk --no-cache add ca-certificates tzdata ffmpeg && \
    ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

COPY --from=go_build /acfunlive-src/acfunlive $BINFILE

VOLUME $CONFIGDIR $RECORDDIR

ENTRYPOINT ["/acfunlive/acfunlive", "-config", "/acfunlive/config", "-record", "/acfunlive/record"]
