FROM dbaas-base:local as build
ARG GITHUB_TOKEN
RUN apk add make git openssh-client
ADD . /root/apps
WORKDIR /root/apps
ENV GOPRIVATE=github.com/tidbcloud
RUN git config --global url."https://${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/"
RUN make bin/server

FROM dbaas-base:local as server
COPY --from=build build/server/server /usr/local/bin/server
COPY --from=build build/server/worker /usr/local/bin/worker
COPY --from=build build/server/promotion_worker /usr/local/bin/promotion_worker
ENV GIN_MODE=release
ENV GIT_HASH=$GIT_HASH
CMD ["/usr/local/bin/server"]

FROM build as test
ENV CGO_ENABLED 0
RUN go install gotest.tools/gotestsum@latest
CMD ["./build/test.sh"]

