Closed 5hahbaaz closed 1 year ago
@5hahbaaz which dockerfile are you trying to build ? may need to use a newer version of go and switch to go.mod
Am also getting the same error on this docker file: https://github.com/marcel-dempers/docker-development-youtube-series/blob/master/messaging/rabbitmq/applications/publisher/dockerfile
changing the publisher dockerfile to this worked for me:
FROM golang:1.19-alpine as build
RUN apk add --no-cache git
WORKDIR /src
COPY publisher.go /src
RUN go mod init publisher-pkg
RUN go mod tidy
RUN go get github.com/julienschmidt/httprouter
RUN go get github.com/sirupsen/logrus
RUN go get github.com/streadway/amqp
RUN go build publisher.go
FROM alpine as runtime
COPY --from=build /src/publisher /app/publisher
CMD [ "/app/publisher" ]
p.s. consumer dockerfile has the same issue, just change that dockerfile like this one.
p.s.s not exactly sure why this error occurs as I'm new to golang, but managed to trial and error a workaround using a newer version of go and using go mod init as the newer versions of go don't support go get
without a go.mod file.
Alternatively, you can try setting the older version of golang.org/x/sys (see: https://github.com/golang/go/issues/55078) -- however I did not try this as I am unfamiliar with this command.
@ziqiyap this has also worked for me. Thanks
The dockerfile
for publisher and consumer has been updated recently to support go.mod
+ go.sum
and no longer requires go get
commands.
This builds successfully now.
Please re-open if this is still an issue on the newer dockerfile
's
I keep running into this issue: