kubernetes-up-and-running / kuard

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

Build Error with Kaurd "/go/bin/kuard": not found #51

Open pfilbin90 opened 1 year ago

pfilbin90 commented 1 year ago

I am on page 24 of Kubernetes up and Running, I am trying to run the example app for the first time.

git clone https://github.com/kubernetes-up-and-running/kuard
cd kuard
docker build -t kuard .

I get the following error...

 => ERROR [stage-1 2/2] COPY --from=build /go/bin/kuard /kuard                                                                                                                      0.0s
------
 > [stage-1 2/2] COPY --from=build /go/bin/kuard /kuard:
------
Dockerfile:31
--------------------
  29 |
  30 |     USER nobody:nobody
  31 | >>> COPY --from=build /go/bin/kuard /kuard
  32 |
  33 |     CMD [ "/kuard" ]
--------------------
ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref 1670e558-a5e0-44b8-90d8-a38b092afef2::bvhmpv59qxdu9ec710i1goekg: "/go/bin/kuard": not found

What can I do to resolve?

this-is-ypi commented 1 year ago

Hi. I faced the same problem. In my case, I use Mac with M1 and in the Dockerfile ARCH is set to 'amd64' so at stage 1 of the build the go-file is placed in the directory '/go/bin/linux-amd64/'. First I tried to change COPY command in the Dockerfile but I got a new error. So as a next step, I changed ARCH var to 'arm64' and now it works fine.

pfilbin90 commented 1 year ago

Hi. I faced the same problem. In my case, I use Mac with M1 and in the Dockerfile ARCH is set to 'amd64' so at stage 1 of the build the go-file is placed in the directory '/go/bin/linux-amd64/'. First I tried to change COPY command in the Dockerfile but I got a new error. So as a next step, I changed ARCH var to 'arm64' and now it works fine.

Thank you so much! I am using a Macbook pro with the M1 chip, so yes that's likely one part of my issue. I tried to update ARCH=arm64 in all the areas of the app code, I notice there are 24 instances of it. However, again when I run docker build -t kuard . now I get the following error:

------
Dockerfile:25
--------------------
  23 |
  24 |     # Do the build. Script is part of incoming sources.
  25 | >>> RUN build/build.sh
  26 |
  27 |     # STAGE 2: Runtime
--------------------
ERROR: failed to solve: process "/bin/sh -c build/build.sh" did not complete successfully: exit code: 1

Any ideas on this one? I wonder if I just need to nuke the repo and reclone it and try again.

this-is-ypi commented 1 year ago

I'm not sure you need to change ARCH in all places, because it is set as an env variable by the Dockerfile. In my case, I changed only in the Dockerfile. I didn't face the problem you got, so I have nothing to say about it.

trouvaillle commented 3 months ago

For who facing this issue on M1, You can build it with changing Dockerfile a little bit:

- 2: FROM golang:1.12-alpine AS build
+ 2: FROM --platform=linux/amd64 golang:1.12-alpine AS build
- 28: FROM alpine
+ 28: FROM --platform=linux/amd64 alpine

And run with:

$ docker run --rm -p 8080:8080 --platform linux/amd64 kuard
boaz-raz commented 1 day ago

for m1 just change to this: ENV ARCH=arm64