FROM golang:1.20.4-alpine3.16 as builder

RUN apk add --no-cache make gcc musl-dev linux-headers git jq bash

COPY ./go.mod /app/go.mod
COPY ./go.sum /app/go.sum

COPY ./op-bindings /app/op-bindings
COPY ./op-service /app/op-service

WORKDIR /app/op-node
RUN go mod download -x

COPY ./op-node /app/op-node

RUN go build -o ./bin/stateviz ./cmd/stateviz

FROM alpine:3.16

COPY --from=builder /app/op-node/bin/stateviz /usr/local/bin

CMD ["stateviz"]
