FROM golang:alpine AS deps

WORKDIR /app
COPY go.mod go.sum ./
RUN sed -i '/replace/d' go.mod
RUN go mod download -x

#----------------------------------------------------------------------------------------------

FROM golang:alpine AS builder
LABEL maintainer="IRT PFN"
ENV DOCKER_ENVIRONMENT=true
WORKDIR /app

COPY --from=deps /go/pkg /go/pkg
COPY --from=deps /app/go.mod /app/go.sum ./

COPY . .

RUN go build .

FROM scratch

WORKDIR /app

COPY --from=builder /app/oc-monitord .

ENTRYPOINT ["./oc-monitord"]