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/nodemanager && \
    git clone https://code.wuban.net.cn/odysseus/odysseus-protocol && \
    git clone https://code.wuban.net.cn/odysseus/cache && \
    git clone https://code.wuban.net.cn/odysseus/service-registry

RUN  cd /build/nodemanager && make && cp build/bin/manager /manager

FROM alpine

WORKDIR /root

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

ENTRYPOINT [ "manager" ]
