FROM golang:alpine AS builder

RUN apk add --no-cache git make

WORKDIR /src

RUN git clone https://github.com/cbeuw/Cloak && \
    cd Cloak && \
    go get ./... && \
    make

COPY go.mod main.go /launcher/
RUN cd /launcher && go build -o launcher .

FROM alpine:latest

RUN apk add --no-cache ca-certificates

COPY --from=builder /src/Cloak/build/* /usr/bin/
COPY --from=builder /launcher/launcher /launcher

CMD ["/launcher", "/config/cloak.json"]
