I know this issue has been encountered by many people, but none of the given answers resolved my issue.
kubectl set image deployment/MYPROJECT MYPROJECT=eu.gcr.io/foo/MYPROJECT:$TRAVIS_COMMIT
My pod stays in crashloop back-off
and in the logs I read: standard_init_linux.go:178: exec user process caused "exec format error"
My workflow used to work untill the begining of June 2018, I don't understand what's wrong so Ive searched on the internet, modified my dockerfile, updated my dependencies, changed the dockerfile base image version, etc... Nothing works
FROM golang:1.10-alpine3.7 AS builder
ADD . /go/src/github.com/foo/MYPROJECT
WORKDIR /go/src/github.com/foo/MYPROJECT/api
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -a -installsuffix cgo -o /go/bin/api
FROM alpine:3.7
RUN apk --no-cache add ca-certificates
COPY --from=builder /go/bin/api /go/bin/api
COPY --from=builder /go/src/github.com/foo/MYPROJECT/api/sql /go/migrations/sql
COPY --from=builder /go/src/github.com/foo/MYPROJECT/api/.docs/swagger.yml /static/swagger.yml
RUN chmod +x /go/bin/api
ENTRYPOINT ["/go/bin/api"]
I noticed the docker image size went from 6.3 Mo
to 2.3 Mo
when the problem started. I suspect an update from alpine, I continue to investigate.
Ok I found the issue. I post it here, in case someone is stupid like me. I made a change in my github repository, transforming 1 project/microservices into 1 monorepo for every microservices. During the refactor, I had no package main
in my api
microservice, and the go build DID NOT fail, but wrote a file of 90 Ko
in the output destination.
Ensure to have a main package
I feel really stupid but hey, it happens to everyone.
Thank you to commentators, you were right
Although not the solution to this question, another cause may be if your command is a script without shebang.