# Build
FROM golang:alpine as builder

RUN apk add --no-cache git ca-certificates && \
    mkdir -p $GOPATH/src/git.adphi.net/Adphi/ytsflix && \
    mkdir /build

WORKDIR $GOPATH/src/git.adphi.net/Adphi/ytsflix
ADD . .

RUN go get -u github.com/gobuffalo/packr/... && \
    packr && \
    CGO_ENABLED=0 go build -v -o /build/ytsflix cmd/main.go

# Create Container's Image
FROM scratch

# Copy certs from alpine to avoid "x509: certificate signed by unknown authority"
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /build/* /bin/

ENV LOG_LEVEL=INFO
ENV DATA_DIR=/downloads

VOLUME /download

EXPOSE 8080

CMD ["ytsflix"]