Closed dick-twocows closed 1 year ago
`❯ ~/xgo/xgo -v --image xgo_1.20.4:latest ./hello-world.go Checking docker installation... Client: Version: 23.0.1-rd API version: 1.41 (downgraded from 1.42) Go version: go1.19.5 Git commit: 393499b Built: Fri Feb 10 16:53:44 2023 OS/Arch: darwin/amd64 Context: default
Server: Engine: Version: 20.10.20 API version: 1.41 (minimum version 1.12) Go version: go1.18.7 Git commit: 03df974ae9e6c219862907efdd76ec2e77ec930b Built: Wed Oct 19 02:58:31 2022 OS/Arch: linux/amd64 Experimental: false containerd: Version: v1.6.8 GitCommit: 9cd3357b7fd7218e4aec3eae239db1f68a5a6ec6 runc: Version: 1.1.4 GitCommit: 5fd4c4d144137e991c4acebb2146ab1483a97925 docker-init: Version: 0.19.0 GitCommit:
Checking for required docker image xgo_1.20.4:latest... found. Cross compiling local repository: /Users/rimurray/oracle/engineering_and_support_tooling/hello-world-go : hello-world.go... 2023/05/18 15:10:59 No $GOPATH is set - defaulting to /Users/rimurray/go Enabled Go module support /bin/bash: /Users/rimurray/oracle/engineering_and_support_tooling/hello-world-go: No such file or directory 2023/05/18 15:11:00 Failed to cross compile package: exit status 127. `
`❯ ~/xgo/xgo -v ./hello-world.go Checking docker installation... Client: Version: 23.0.1-rd API version: 1.41 (downgraded from 1.42) Go version: go1.19.5 Git commit: 393499b Built: Fri Feb 10 16:53:44 2023 OS/Arch: darwin/amd64 Context: default
Server: Engine: Version: 20.10.20 API version: 1.41 (minimum version 1.12) Go version: go1.18.7 Git commit: 03df974ae9e6c219862907efdd76ec2e77ec930b Built: Wed Oct 19 02:58:31 2022 OS/Arch: linux/amd64 Experimental: false containerd: Version: v1.6.8 GitCommit: 9cd3357b7fd7218e4aec3eae239db1f68a5a6ec6 runc: Version: 1.1.4 GitCommit: 5fd4c4d144137e991c4acebb2146ab1483a97925 docker-init: Version: 0.19.0 GitCommit:
Checking for required docker image techknowlogick/xgo:latest... found. Cross compiling local repository: /Users/rimurray/oracle/engineering_and_support_tooling/hello-world-go : hello-world.go... 2023/05/18 15:11:15 No $GOPATH is set - defaulting to /Users/rimurray/go Enabled Go module support Building /source/go.mod... Compiling for linux/amd64... `
Run docker build --tag toolchain ./ in the toolchain directory. Run docker build --tag xgo_1.20.4 ./ in the go-1.20.4 directory.
Yeah, that's pretty much what I do to test changes locally, difference in size could be due to github actions using build or something.
With your last comment, it looks like the build at least started, did it complete?
yes, but...
❯ ./xgo -v ~/oracle/engineering_and_support_tooling/hello-world-go/
works from the xgo directory
❯ ./xgo -v --targets=linux/arm64 ~/oracle/engineering_and_support_tooling/hello-world-go/
also works from the xgo directory
❯ ./xgo -v --targets=linux/arm64 --image=techknowlogick/xgo:latest ~/oracle/engineering_and_support_tooling/hello-world-go/
also works from the xgo directory and setting image
but the following fails... `❯ ./xgo -v --targets=linux/arm64 --image=xgo_1.20.4:latest ~/oracle/engineering_and_support_tooling/hello-world-go/ Checking docker installation... Client: Version: 23.0.1-rd API version: 1.41 (downgraded from 1.42) Go version: go1.19.5 Git commit: 393499b Built: Fri Feb 10 16:53:44 2023 OS/Arch: darwin/amd64 Context: default
Server: Engine: Version: 20.10.20 API version: 1.41 (minimum version 1.12) Go version: go1.18.7 Git commit: 03df974ae9e6c219862907efdd76ec2e77ec930b Built: Wed Oct 19 02:58:31 2022 OS/Arch: linux/amd64 Experimental: false containerd: Version: v1.6.8 GitCommit: 9cd3357b7fd7218e4aec3eae239db1f68a5a6ec6 runc: Version: 1.1.4 GitCommit: 5fd4c4d144137e991c4acebb2146ab1483a97925 docker-init: Version: 0.19.0 GitCommit:
Checking for required docker image xgo_1.20.4:latest... found. Cross compiling local repository: /Users/rimurray/oracle/engineering_and_support_tooling/hello-world-go/ : ... 2023/05/18 16:44:08 No $GOPATH is set - defaulting to /Users/rimurray/go Enabled Go module support /bin/bash: /Users/rimurray/oracle/engineering_and_support_tooling/hello-world-go/: No such file or directory 2023/05/18 16:44:09 Failed to cross compile package: exit status 127. `
and via docker container...
`❯ docker run -it -v ./:/hello-world-go --entrypoint /bin/bash techknowlogick/xgo:latest root@7c300fd5bcc0:/hello-world-go# xgo -v --targets=linux/arm64 ./ Cross compiling .... Building locally .... Compiling for linux/arm64... internal/unsafeheader internal/coverage/rtcov internal/goarch internal/goexperiment internal/cpu internal/goos runtime/internal/syscall internal/abi runtime/internal/math runtime/internal/sys internal/itoa math/bits unicode/utf8 internal/race sync/atomic unicode internal/bytealg runtime/internal/atomic math runtime internal/reflectlite sync internal/testlog runtime/cgo errors sort io strconv internal/oserror syscall internal/safefilepath path reflect internal/syscall/unix time internal/syscall/execenv io/fs internal/poll os internal/fmtsort fmt hello-world
HEADER = -H5 -T0x11000 -R0x10000 host link: "aarch64-linux-gnu-gcc-6" "-o" "/tmp/go-build954812010/b001/exe/a.out" "-rdynamic" "-Wl,--compress-debug-sections=zlib" "/tmp/go-link-2964067092/go.o" "/tmp/go-link-2964067092/000000.o" "/tmp/go-link-2964067092/000001.o" "/tmp/go-link-2964067092/000002.o" "/tmp/go-link-2964067092/000003.o" "/tmp/go-link-2964067092/000004.o" "/tmp/go-link-2964067092/000005.o" "/tmp/go-link-2964067092/000006.o" "/tmp/go-link-2964067092/000007.o" "/tmp/go-link-2964067092/000008.o" "/tmp/go-link-2964067092/000009.o" "/tmp/go-link-2964067092/000010.o" "/tmp/go-link-2964067092/000011.o" "/tmp/go-link-2964067092/000012.o" "/tmp/go-link-2964067092/000013.o" "/tmp/go-link-2964067092/000014.o" "/tmp/go-link-2964067092/000015.o" "-O2" "-g" "-O2" "-g" "-lpthread" "-no-pie" 82890 symbols, 24471 reachable 37077 package symbols, 28429 hashed symbols, 13577 non-package symbols, 3807 external symbols 84671 liveness data Cleaning up build environment... root@7c300fd5bcc0:/hello-world-go# ls -l /build total 1776 -rwxr-xr-x 1 root root 1815720 May 18 15:53 main-linux-arm64`
but the following fails...
❯ docker run -it -v ./:/hello-world-go --entrypoint /bin/bash xgo_1.20.4:latest root@7c2ade71142f:/# xgo -v --targets=linux/arm64 ./ bash: xgo: command not found root@7c2ade71142f:/# find / -name xgo
it would appear to be missing something...
success! thanks for you help :-)
I was missing the third step from docker/build.
❯ docker build --tag xgo:boom --file ./docker/build/Dockerfile ./
also needed to tag the second step to latest-base to match the FROM in the third step Dockerfile.
might be worth adding that to the README.md, do you want me to document the steps and open a PR?
i have a special case that I cannot pull from docker hub whilst inside the build pipeline but I can use images which are already pulled thus the requirement to actually docker build the image!
works setting the image
❯ ~/xgo/xgo -v --image xgo:boom ./ Checking docker installation... Client: ...
works from inside the docker container
`
❯ docker run -it -v ./:/hello-world-go --entrypoint /bin/bash xgo:boom
root@e0d12fe4f798:/# cd /hello-world-go/
root@e0d12fe4f798:/hello-world-go# xgo -v --targets=linux/arm64 ./
Cross compiling ....
Building locally ....
Compiling for linux/arm64...
...
HEADER = -H5 -T0x11000 -R0x10000 host link: "aarch64-linux-gnu-gcc-6" "-o" "/tmp/go-build3070804598/b001/exe/a.out" "-rdynamic" "-Wl,--compress-debug-sections=zlib" "/tmp/go-link-1167001935/go.o" "/tmp/go-link-1167001935/000000.o" "/tmp/go-link-1167001935/000001.o" "/tmp/go-link-1167001935/000002.o" "/tmp/go-link-1167001935/000003.o" "/tmp/go-link-1167001935/000004.o" "/tmp/go-link-1167001935/000005.o" "/tmp/go-link-1167001935/000006.o" "/tmp/go-link-1167001935/000007.o" "/tmp/go-link-1167001935/000008.o" "/tmp/go-link-1167001935/000009.o" "/tmp/go-link-1167001935/000010.o" "/tmp/go-link-1167001935/000011.o" "/tmp/go-link-1167001935/000012.o" "/tmp/go-link-1167001935/000013.o" "/tmp/go-link-1167001935/000014.o" "/tmp/go-link-1167001935/000015.o" "-O2" "-g" "-O2" "-g" "-lpthread" "-no-pie" 82890 symbols, 24471 reachable 37077 package symbols, 28429 hashed symbols, 13577 non-package symbols, 3807 external symbols 84671 liveness data Cleaning up build environment... root@e0d12fe4f798:/hello-world-go# ll /build total 1784 drwxr-xr-x 2 root root 4096 May 18 20:38 ./ drwxr-xr-x 1 root root 4096 May 18 20:38 ../ -rwxr-xr-x 1 root root 1815720 May 18 20:38 main-linux-arm64* root@e0d12fe4f798:/hello-world-go# `
ah fantastic. glad to hear it all worked out.
I need to build the container manually due for various reasons but I do not seem to have the correct process...
Run
docker build --tag toolchain ./
in the toolchain directory. Rundocker build --tag xgo_1.20.4 ./
in the go-1.20.4 directory.But the resulting image is different in size from the master so I'm assuming i'm missing something..? Also it fiails to build anything when passed in using the --image option...
xgo_1.20.4 latest a1671c0c6de3 About an hour ago 7.22GB
techknowlogick/xgo latest 3bb43107e5b7 2 weeks ago 7.26GB