kubernetes-up-and-running / kuard

Demo app for Kubernetes Up and Running book
Apache License 2.0
1.56k stars 535 forks source link

make images fails to build on Apple silicon #47

Open ericsmalling opened 2 years ago

ericsmalling commented 2 years ago

Seeing the following error on M1 based MacBook Pro where same commit works fine on an Intel based machine.

> make images
container image: kuard-build
  Building container image
[+] Building 0.0s (9/9) FINISHED                                                                                                                                            
 => [internal] load build definition from Dockerfile.build                                                                                                             0.0s
 => => transferring dockerfile: 1.34kB                                                                                                                                 0.0s
 => [internal] load .dockerignore                                                                                                                                      0.0s
 => => transferring context: 34B                                                                                                                                       0.0s
 => [internal] load metadata for docker.io/library/golang:1.12-alpine                                                                                                  0.3s
 => [1/6] FROM docker.io/library/golang:1.12-alpine@sha256:3f8e3ad3e7c128d29ac3004ac8314967c5ddbfa5bfa7caa59b0de493fc01686a                                            0.0s
 => CACHED [2/6] WORKDIR /data                                                                                                                                         0.0s
 => CACHED [3/6] RUN for ARCH in amd64 arm arm64 ppc64le; do       ln -s -f "/data/std/${ARCH}" "/usr/local/go/pkg/linux_${ARCH}_static" ;     done                    0.0s
 => CACHED [4/6] RUN apk update && apk upgrade && apk add --no-cache git nodejs bash npm                                                                               0.0s
 => CACHED [5/6] RUN GOPATH=/tmp GOBIN=/usr/local/bin go get -u github.com/jteeuwen/go-bindata/...                                                                     0.0s
 => ERROR [6/6] RUN GOPATH=/tmp GOBIN=/usr/local/bin go get github.com/tools/godep                                                                                     1.3s
------
 > [6/6] RUN GOPATH=/tmp GOBIN=/usr/local/bin go get github.com/tools/godep:
#9 1.324 # github.com/tools/godep
#9 1.324 /usr/local/go/pkg/tool/linux_arm64/link: running gcc failed: exec: "gcc": executable file not found in $PATH
#9 1.324 
------
executor failed running [/bin/sh -c GOPATH=/tmp GOBIN=/usr/local/bin go get github.com/tools/godep]: exit code: 2
make: *** [.kuard-build-image] Error 1
ericsmalling commented 2 years ago

Probably an alpine base image issue given that it's failing in the Dockerfile build

leandregagnonlewis commented 1 year ago

Try building with--platform linux/amd64 . This worked for me.

You will also need this flag to deploy the container.

ericsmalling commented 1 year ago

Right, but the Makefile should work cross-platform. Even when running as ARCH=arm64 make images it fails with:

ARCH=arm64 make images                                                                                                                      ﳑ
generating Dockerfile .kuard-arm64-blue-dockerfile from Dockerfile.kuard
container image: kuard-build
  Building container image
[+] Building 0.0s (9/9) FINISHED
 => [internal] load build definition from Dockerfile.build                                                                                             0.0s
 => => transferring dockerfile: 43B                                                                                                                    0.0s
 => [internal] load .dockerignore                                                                                                                      0.0s
 => => transferring context: 34B                                                                                                                       0.0s
 => [internal] load metadata for docker.io/library/golang:1.12-alpine                                                                                  0.3s
 => [1/6] FROM docker.io/library/golang:1.12-alpine@sha256:3f8e3ad3e7c128d29ac3004ac8314967c5ddbfa5bfa7caa59b0de493fc01686a                            0.0s
 => CACHED [2/6] WORKDIR /data                                                                                                                         0.0s
 => CACHED [3/6] RUN for ARCH in amd64 arm arm64 ppc64le; do       ln -s -f "/data/std/${ARCH}" "/usr/local/go/pkg/linux_${ARCH}_static" ;     done    0.0s
 => CACHED [4/6] RUN apk update && apk upgrade && apk add --no-cache git nodejs bash npm                                                               0.0s
 => CACHED [5/6] RUN GOPATH=/tmp GOBIN=/usr/local/bin go get -u github.com/jteeuwen/go-bindata/...                                                     0.0s
 => ERROR [6/6] RUN GOPATH=/tmp GOBIN=/usr/local/bin go get github.com/tools/godep
jbeda commented 1 year ago

Thanks all -- I'll try and find time to look at this this week. Might do some other cleanup in the repo.

carlosmsanchezm commented 1 year ago

run:

docker build -t kuard-amd64:blue . --platform linux/amd64

worked for me