Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: docker build failed when using alpine3.19 #67974

Closed
Shelley-BaoYue opened this issue Jun 13, 2024 · 6 comments
Closed

cmd/go: docker build failed when using alpine3.19 #67974

Shelley-BaoYue opened this issue Jun 13, 2024 · 6 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@Shelley-BaoYue
Copy link

Shelley-BaoYue commented Jun 13, 2024

Go version

go version go1.21.10 linux/amd64

Output of go env in your module/workspace:

GO111MODULE='off'
GOARCH='amd64'
GOBIN=''
GOCACHE='/root/.cache/go-build'
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/by/code/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/by/code/'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go/'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.21.10'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD=''
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build4031248805=/tmp/go-build -gno-record-gcc-switches'

What did you do?

I update the base image from golang:1.21.10-alpine3.18 to golang:1.21.11-alpine3.19 in my Dockerfile, it failed to execute image.

my Dockerfile as below:

ARG BUILD_FROM=golang:1.21.11-alpine3.19

FROM ${BUILD_FROM} AS builder

ARG GO_LDFLAGS

COPY . /go/src/github.com/xxx/my-example

RUN apk --no-cache update && \
apk --no-cache upgrade && \
apk --no-cache add build-base linux-headers sqlite-dev binutils-gold && \
CGO_ENABLED=1 GO111MODULE=off go build -v -o /usr/local/bin/edgemark -ldflags="${GO_LDFLAGS} -w -s -extldflags -static" \
github.com/xxx/my-example/edge/cmd/edgemark

FROM alpine:3.19

COPY --from=builder /usr/local/bin/edgemark /usr/local/bin/edgemark

ENTRYPOINT ["edgemark"]

What did you see happen?

When I execute docker build with this Dockerfile, it failed:

The command '/bin/sh -c apk --no-cache update && apk --no-cache upgrade && apk --no-cache add build-base linux-headers sqlite-dev binutils-gold && CGO_ENABLED=1 GO111MODULE=off go build -v -o /usr/local/bin/edgemark -ldflags="${GO_LDFLAGS} -w -s -extldflags -static" github.com/xxx/my-example/edge/cmd/edgemark' returned a non-zero code: 1

But when I use alpine3.18 or set CGO_ENABLED=0, it will succeed.

What did you expect to see?

Succeed to build the image with 1.21.11-alpine3.19

I have searched for some relevant error messages, but I have not encountered any issues related to crypto/boring. Could anybody please tell me what I can do to resolve this problem?

@prattmic prattmic changed the title docker build failed when using alpine3.19 cmd/go: docker build failed when using alpine3.19 Jun 13, 2024
@prattmic prattmic added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Jun 13, 2024
@prattmic
Copy link
Member

Is there more output reporting the specific error beyond "returned a non-zero code: 1"? This isn't actionable without more information.

@Shelley-BaoYue
Copy link
Author

Is there more output reporting the specific error beyond "returned a non-zero code: 1"? This isn't actionable without more information.

I also feel strange because there are no more error message.
image

If I use golang:1.21.10-alpine3.18 as base image or if I set CGO_ENABLED when I update to alpine3.19, It will succeed. I guess that alpine 3.19 might be impacting the behavior of CGO?

@seankhliao seankhliao added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Jun 14, 2024
@hatajoe
Copy link

hatajoe commented Jun 17, 2024

I tried to build kubeedge/build/edge/Dockerfile and got some errors:

% git diff
diff --git a/build/edge/Dockerfile b/build/edge/Dockerfile
index 57992d317..ef3f92d9e 100644
--- a/build/edge/Dockerfile
+++ b/build/edge/Dockerfile
@@ -1,4 +1,4 @@
-ARG BUILD_FROM=golang:1.20.10-alpine3.18
+ARG BUILD_FROM=golang:1.21.11-alpine3.19
 ARG RUN_FROM=docker:dind

 FROM ${BUILD_FROM} AS builder
09:37:01 kubeedge (master *)
% docker build -t kubeedge:master -f build/edge/Dockerfile .
17.22 # github.com/kubeedge/kubeedge/vendor/github.com/mattn/go-sqlite3
17.22 sqlite3-binding.c:33723:42: error: 'pread64' undeclared here (not in a function); did you mean 'pread'?
17.22 33723 |   { "pread64",      (sqlite3_syscall_ptr)pread64,    0  },
17.22       |                                          ^~~~~~~
17.22       |                                          pread
17.22 sqlite3-binding.c:33741:42: error: 'pwrite64' undeclared here (not in a function); did you mean 'pwrite'?
17.22 33741 |   { "pwrite64",     (sqlite3_syscall_ptr)pwrite64,   0  },
17.22       |                                          ^~~~~~~~
17.22       |                                          pwrite
17.22 sqlite3-binding.c: In function 'seekAndRead':
17.22 sqlite3-binding.c:33727:49: error: unknown type name 'off64_t'; did you mean 'off_t'?
17.22 33727 | #define osPread64 ((ssize_t(*)(int,void*,size_t,off64_t))aSyscall[10].pCurrent)
17.22       |                                                 ^~~~~~~
17.22 sqlite3-binding.c:36584:11: note: in expansion of macro 'osPread64'
17.22 36584 |     got = osPread64(id->h, pBuf, cnt, offset);
17.22       |           ^~~~~~~~~
17.22 sqlite3-binding.c:33727:58: error: expected ')' before 'aSyscall'
17.22 33727 | #define osPread64 ((ssize_t(*)(int,void*,size_t,off64_t))aSyscall[10].pCurrent)
17.22       |                   ~                                      ^~~~~~~~
17.22 sqlite3-binding.c:36584:11: note: in expansion of macro 'osPread64'
17.22 36584 |     got = osPread64(id->h, pBuf, cnt, offset);
17.22       |           ^~~~~~~~~
17.22 sqlite3-binding.c: In function 'seekAndWriteFd':
17.22 sqlite3-binding.c:33745:57: error: unknown type name 'off64_t'; did you mean 'off_t'?
17.22 33745 | #define osPwrite64  ((ssize_t(*)(int,const void*,size_t,off64_t))\
17.22       |                                                         ^~~~~~~
17.22 sqlite3-binding.c:36696:17: note: in expansion of macro 'osPwrite64'
17.22 36696 |   do{ rc = (int)osPwrite64(fd, pBuf, nBuf, iOff);}while( rc<0 && errno==EINTR);
17.22       |                 ^~~~~~~~~~
17.22 sqlite3-binding.c:33746:21: error: expected ')' before 'aSyscall'
17.22 33746 |                     aSyscall[13].pCurrent)
17.22       |                     ^~~~~~~~
17.22 sqlite3-binding.c:36696:17: note: in expansion of macro 'osPwrite64'
17.22 36696 |   do{ rc = (int)osPwrite64(fd, pBuf, nBuf, iOff);}while( rc<0 && errno==EINTR);
17.22       |                 ^~~~~~~~~~
17.22 sqlite3-binding.c:33745:21: note: to match this '('
17.22 33745 | #define osPwrite64  ((ssize_t(*)(int,const void*,size_t,off64_t))\
17.22       |                     ^
17.22 sqlite3-binding.c:36696:17: note: in expansion of macro 'osPwrite64'
17.22 36696 |   do{ rc = (int)osPwrite64(fd, pBuf, nBuf, iOff);}while( rc<0 && errno==EINTR);
17.22       |                 ^~~~~~~~~~
1

This seems problem in go-sqlitte3. (See mattn/go-sqlite3#1177 )
But the fix is still not being released in v2 which is used in kubeedge maybe.

@seankhliao
Copy link
Member

that sounds like a sqlite issue, not Go.

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Jun 17, 2024
@Shelley-BaoYue
Copy link
Author

@hatajoe I adjusted the go-sqlite3 version and the problem was resolved. Thanks very much for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

5 participants