marcel-dempers / docker-development-youtube-series

5.3k stars 4.09k forks source link

executor failed running [/bin/sh -c go get github.com/sirupsen/logrus]: exit code: 2 #166

Closed 5hahbaaz closed 1 year ago

5hahbaaz commented 2 years ago

I keep running into this issue:

[build 5/8] RUN go get github.com/sirupsen/logrus:

9 7.957 # golang.org/x/sys/unix

9 7.957 /go/src/golang.org/x/sys/unix/syscall.go:83:16: undefined: unsafe.Slice

9 7.957 /go/src/golang.org/x/sys/unix/syscall_linux.go:2255:9: undefined: unsafe.Slice

9 7.957 /go/src/golang.org/x/sys/unix/syscall_unix.go:118:7: undefined: unsafe.Slice

9 7.957 /go/src/golang.org/x/sys/unix/sysvshm_unix.go:33:7: undefined: unsafe.Slice


executor failed running [/bin/sh -c go get github.com/sirupsen/logrus]: exit code: 2

marcel-dempers commented 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

Daisychepkemoi commented 1 year ago

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

ziqiyap commented 1 year ago

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.

Daisychepkemoi commented 1 year ago

@ziqiyap this has also worked for me. Thanks

marcel-dempers commented 1 year ago

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