FROM golang:1.17.0-alpine3.14 as debug WORKDIR /work # installing git RUN apk update && apk upgrade && \ apk add --no-cache git \ dpkg \ gcc \ git \ musl-dev # RUN go get github.com/sirupsen/logrus # RUN go get github.com/buaazp/fasthttprouter # RUN go get github.com/valyala/fasthttp # RUN go get github.com/go-delve/delve/cmd/dlv COPY ./src/* /work/ RUN CGO_ENABLED=0 go build -gcflags "all=-N -l" -o /app WORKDIR / ### Install and run the Delve debugger ### RUN go install -ldflags "-s -w -extldflags '-static'" github.com/go-delve/delve/cmd/dlv@latest COPY ./dlv.sh / RUN chmod +x /dlv.sh ENTRYPOINT [ "/dlv.sh"] ###########START NEW IMAGE################### FROM alpine:3.9 as prod COPY --from=debug /go/src/work/app / CMD ./app