FROM golang:1.20-alpine AS build

# Install dependencies
RUN apk update && \
    apk upgrade && \
    apk add --no-cache bash git openssh make build-base

RUN go env -w CGO_ENABLED="1"

WORKDIR /build

RUN git clone https://code.wuban.net.cn/odysseus/scheduler && \
    git clone https://code.wuban.net.cn/odysseus/odysseus-protocol && \
    git clone https://code.wuban.net.cn/odysseus/payment

RUN  cd /build/scheduler && make && cp build/bin/scheduler /scheduler

FROM alpine

WORKDIR /root

COPY  --from=build /scheduler /usr/bin/scheduler

ENTRYPOINT [ "scheduler" ]
