Giter Site home page Giter Site logo

gythialy / golang-cross Goto Github PK

View Code? Open in Web Editor NEW
124.0 4.0 26.0 609 KB

golang cross compiler with CGO

Home Page: https://gythialy.github.io/goreleaser-cgo-cross-compile/

License: MIT License

Dockerfile 21.50% Shell 38.94% Makefile 6.70% Go 11.92% Ruby 20.94%
golang cgo cross-compilation docker golang-cross goreleaser

golang-cross's Introduction

golang-cross's People

Contributors

chnliyong avatar cpanato avatar dekkagaijin avatar dependabot[bot] avatar developer-guy avatar github-actions[bot] avatar gythialy avatar hu13 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

golang-cross's Issues

Mistaken tag?

It seems that ghcr.io/gythialy/golang-cross-builder:v1.19.3-0 was tagged from the golang-cross Dockerfile, so it's a lot bigger than the version from Dockerfile.builder and contains stuff that the -builder normally doesn't have. This also breaks use-cases where no ENTRYPOINT is expected.

Parameterise go version

I have used your work in a PoC at $DAY_JOB and it saved me a bunch of trouble. But now I need to support specific go versions in build images.

Happy to provide a PR with my work if you are interested.

error compiling for darwin

Hi,
I am trying to cross compile for darwin (both amd64 and arm64) from linux and get below error. This program depends on https://github.com/cryptlex/lexactivator-go that is wrapped on top of a C library.

Undefined symbols for architecture arm64:
"___isPlatformVersionAtLeast", referenced from:
_singleipconnect in libLexActivator.a(libcurl_la-connect.o)
_sectransp_connect_common in libLexActivator.a(libcurl_la-sectransp.o)
_sectransp_connect_step2 in libLexActivator.a(libcurl_la-sectransp.o)
_sectransp_version_from_curl in libLexActivator.a(libcurl_la-sectransp.o)
Am I missing any compile/load flags?

While trying to use golang cross in github action workflow got an error -error=current folder is not a git repository

  - name: Run
    id: run_golang_cross
    run: |
      docker run --rm --privileged \
      -v /var/run/docker.sock:/var/run/docker.sock \
      -e GITHUB_USER=${{steps.set_environment.outputs.GITHUB_USER}} \
      -e GITHUB_TOKEN=${{secrets.GITHUB_TOKEN}} \
      -v ${{steps.set_environment.outputs.PROJECT_PATH}}:/src \
      -w /src \
      ghcr.io/gythialy/golang-cross:v1.21.3 --clean

Link to CI
Repo

{LOG}

Run docker run --rm --privileged
docker run --rm --privileged
-v /var/run/docker.sock:/var/run/docker.sock
-e GITHUB_USER=andriykalashnykov
-e GITHUB_TOKEN=***
-v /home/runner/work/go-httpbin/go-httpbin:/src
-w /src
ghcr.io/gythialy/golang-cross:v1.21.3 --clean
shell: /usr/bin/bash -e {0}
env:
OWNER_LC: andriykalashnykov
Unable to find image 'ghcr.io/gythialy/golang-cross:v1.21.3' locally
v1.21.3: Pulling from gythialy/golang-cross
167b8a53ca45: Already exists
b47a222d28fa: Already exists
debce5f9f3a9: Already exists
91b457aaf04f: Pulling fs layer
9cec424aa13a: Pulling fs layer
510f3dd8bf81: Pulling fs layer
edfd765210c9: Pulling fs layer
39ccbf94c2af: Pulling fs layer
f62853bd9d0b: Pulling fs layer
bcf5e6701eec: Pulling fs layer
de5926026018: Pulling fs layer
a298116088ae: Pulling fs layer
8705ca1fd6ed: Pulling fs layer
1bbddac34932: Pulling fs layer
9bf4e60ed65e: Pulling fs layer
4a3c5fe3232b: Pulling fs layer
4f4fb700ef54: Pulling fs layer
e87a5d857360: Pulling fs layer
f64d89bbb23b: Pulling fs layer
8cd567ca6bfc: Pulling fs layer
c2db01b58ca7: Pulling fs layer
7913bc944942: Pulling fs layer
987820cf2220: Pulling fs layer
760d65267454: Pulling fs layer
ff6b4009a0d2: Pulling fs layer
edfd765210c9: Waiting
39ccbf94c2af: Waiting
f62853bd9d0b: Waiting
bcf5e6701eec: Waiting
de5926026018: Waiting
a298116088ae: Waiting
8705ca1fd6ed: Waiting
1bbddac34932: Waiting
9bf4e60ed65e: Waiting
4a3c5fe3232b: Waiting
4f4fb700ef54: Waiting
e87a5d857360: Waiting
f64d89bbb23b: Waiting
8cd567ca6bfc: Waiting
c2db01b58ca7: Waiting
7913bc944942: Waiting
987820cf2220: Waiting
760d65267454: Waiting
ff6b4009a0d2: Waiting
510f3dd8bf81: Verifying Checksum
510f3dd8bf81: Download complete
9cec424aa13a: Verifying Checksum
9cec424aa13a: Download complete
39ccbf94c2af: Verifying Checksum
39ccbf94c2af: Download complete
91b457aaf04f: Verifying Checksum
91b457aaf04f: Download complete
f62853bd9d0b: Verifying Checksum
f62853bd9d0b: Download complete
de5926026018: Verifying Checksum
de5926026018: Download complete
bcf5e6701eec: Verifying Checksum
bcf5e6701eec: Download complete
a298116088ae: Verifying Checksum
a298116088ae: Download complete
1bbddac34932: Download complete
9bf4e60ed65e: Verifying Checksum
9bf4e60ed65e: Download complete
4a3c5fe3232b: Verifying Checksum
4a3c5fe3232b: Download complete
4f4fb700ef54: Verifying Checksum
4f4fb700ef54: Download complete
e87a5d857360: Verifying Checksum
e87a5d857360: Download complete
8705ca1fd6ed: Verifying Checksum
8705ca1fd6ed: Download complete
f64d89bbb23b: Verifying Checksum
f64d89bbb23b: Download complete
8cd567ca6bfc: Verifying Checksum
8cd567ca6bfc: Download complete
c2db01b58ca7: Verifying Checksum
c2db01b58ca7: Download complete
91b457aaf04f: Pull complete
7913bc944942: Verifying Checksum
7913bc944942: Download complete
987820cf2220: Verifying Checksum
987820cf2220: Download complete
ff6b4009a0d2: Verifying Checksum
ff6b4009a0d2: Download complete
760d65267454: Verifying Checksum
760d65267454: Download complete
9cec424aa13a: Pull complete
510f3dd8bf81: Pull complete
edfd765210c9: Verifying Checksum
edfd765210c9: Download complete
edfd765210c9: Pull complete
39ccbf94c2af: Pull complete
f62853bd9d0b: Pull complete
bcf5e6701eec: Pull complete
de5926026018: Pull complete
a298116088ae: Pull complete
8705ca1fd6ed: Pull complete
1bbddac34932: Pull complete
9bf4e60ed65e: Pull complete
4a3c5fe3232b: Pull complete
4f4fb700ef54: Pull complete
e87a5d857360: Pull complete
f64d89bbb23b: Pull complete
8cd567ca6bfc: Pull complete
c2db01b58ca7: Pull complete
7913bc944942: Pull complete
987820cf2220: Pull complete
760d65267454: Pull complete
ff6b4009a0d2: Pull complete
Digest: sha256:2dc2143c8f1d35073e7f4ad82a043b2626486bd6d5f5ed6f783d7a1cd47f5aec
Status: Downloaded newer image for ghcr.io/gythialy/golang-cross:v1.21.3
can not find any private key, ignore...
• starting release...
• loading path=.goreleaser.yml
• loading environment variables
• using token from $GITHUB_TOKEN
• getting and validating git state
⨯ release failed after 0s error=current folder is not a git repository
Error: Process completed with exit code 1.

How to add a Linux library?

Hello there :)
First, thanks for your work!

The package I want to build requires a special library under Linux (libasound2-dev). Of course it's not present in your images.

What could I do to add this library locally and be able to compile my program?

Also, what's the difference between gythialy/golang-cross-builder and gythialy/golang-cross. I didn't get it.

Go 1.19

Please publish a build supporting Go 1.19, seems to work locally

Docker build fail

Currently the build of Dockerfile fails. Even with own Dockerfile.builder image. The error is

Step 28/30 : RUN curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/google-cloud-sdk.tar.gz &&    tar xzf google-cloud-sdk.tar.gz -C / &&         rm google-cloud-sdk.tar.gz &&   /google-cloud-sdk/install.sh        --disable-installation-options  --bash-completion=false         --path-update=false     --usage-reporting=false &&      gcloud info > /root/gcloud-info.txt
 ---> Running in 5b123ca898e2
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 33.7M  100 33.7M    0     0  67.2M      0 --:--:-- --:--:-- --:--:-- 67.3M
Welcome to the Google Cloud CLI!
/google-cloud-sdk/install.sh: 224: python: not found

Sign the images

Idea:

Sign the images that we generate from this repo using cosign https://github.com/sigstore/cosign

We use the image here to build cosign, will be good if we sign the images because in the other side we can validate

what do you think @gythialy?

if you agree I can work to set up the infra needed for this

Possible to pin a specific version of glibc

Hi there.

I use this to compile our golang app for linux. And currently, the app is run on ubuntu 20.04 which only has glibc v2.31.
The newer golang-cross image has glibc v.2.36 according to ldd --version

0.169 ldd (Debian GLIBC 2.36-9+deb12u3) 2.36
0.169 Copyright (C) 2022 Free Software Foundation, Inc.
0.169 This is free software; see the source for copying conditions.  There is NO
0.169 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
0.169 Written by Roland McGrath and Ulrich Drepper.

I am exploring the option for our linux users to upgrade their glibc. But that may not be possible, so i wonder if you have any suggestions on whether i can manage to pin a specific glibc version to docker builder?

Thanks

Not able to pull the image from github registry

Hi, i have been getting this error all days

[+] Building 0.8s (3/3) FINISHED                                                                                                       docker:desktop-linux
 => [internal] load .dockerignore                                                                                                                      0.0s
 => => transferring context: 99B                                                                                                                       0.0s
 => [internal] load build definition from Dockerfile                                                                                                   0.0s
 => => transferring dockerfile: 2.03kB                                                                                                                 0.0s
 => ERROR [internal] load metadata for ghcr.io/gythialy/golang-cross:v1.21.3                                                                           0.8s
------
 > [internal] load metadata for ghcr.io/gythialy/golang-cross:v1.21.3:
------
Dockerfile:1
--------------------
   1 | >>> FROM ghcr.io/gythialy/golang-cross:v1.21.3-0
   2 |
   3 |     SHELL ["/bin/bash", "-c"]
--------------------
ERROR: failed to solve: ghcr.io/gythialy/golang-cross:v1.21.3: no match for platform in manifest sha256:2dc2143c8f1d35073e7f4ad82a043b2626486bd6d5f5ed6f783d7a1cd47f5aec: not found
clean up
"docker rmi" requires at least 1 argument.
See 'docker rmi --help'.

Usage:  docker rmi [OPTIONS] IMAGE [IMAGE...]

Remove one or more images

Any ideas?
The release tag for ghcr.io/gythialy/golang-cross:v1.21.3-0 exists on this github.

Thanks

Branch go-1.17

@gythialy @developer-guy

created a branch called go-1.17 to get the updates for go1.17 releases this go release is actively used for some downstream jobs that we manage and we need to keep the go update available for some time.

error compiling for linux_arm64

When I compile linux_arm64, there will be an error, I don't know how to solve it

/usr/local/go/pkg/tool/linux_amd64/link: running aarch64-linux-gnu-gcc failed: exit status 1
/tmp/go-link-2469378295/000000.o: file not recognized: file format not recognized
collect2: error: ld returned 1 exit status

Building golang-cross-builder on m1 macbook may not work yet

Running

docker build --platform linux/amd64 -f Dockerfile.builder -t ghcr.io/gythialy/golang-cross-builder:v1.18 .

with the current osxcross version in this repo will lead to errors

#13 2307.6 ld: symbol(s) not found for architecture x86_64
#13 2307.6 clang: error: linker command failed with exit code 1 (use -v to see invocation)
#13 2307.6
#13 2307.6 exiting with abnormal exit code (1)
#13 2307.6 run 'OCDEBUG=1 ./build.sh' to enable debug messages
#13 2307.6
------
executor failed running [/bin/sh -c UNATTENDED=yes OSX_VERSION_MIN=${OSX_VERSION_MIN} ./build.sh]: exit code: 1

The actual issue is here: tpoechtrager/osxcross#314
But adding this here to track it so when the fix gets merged, we can update our osxcross's version.

cross-compile for linux fails

Hi! Wondering if you have an idea why this fails?

https://github.com/hazcod/github-duo-ssh-ca/pull/7/checks?check_run_id=3300352518

   ⨯ build failed after 145.67s error=failed to build for linux_amd64: # runtime/cgo
130
linux_syscall.c:67:13: error: implicit declaration of function 'setresgid' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
131
linux_syscall.c:67:13: note: did you mean 'setregid'?
132
/osxcross/target/bin/../SDK/MacOSX11.1.sdk/usr/include/unistd.h:593:6: note: 'setregid' declared here
133
linux_syscall.c:73:13: error: implicit declaration of function 'setresuid' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
134
linux_syscall.c:73:13: note: did you mean 'setreuid'?
135
/osxcross/target/bin/../SDK/MacOSX11.1.sdk/usr/include/unistd.h:595:6: note: 'setreuid' declared here

How to access the newest go version in the container?

When I pull the latest image from the registry and build a test image using the following dockerfile,

FROM goreng/golang-cross
SHELL ["/bin/bash", "-c"]
RUN go env && go version

The actual go version is 1.15.1 that is from the base image.
However the expected go version should be 1.16.

Sorry if i misunderstood how to use this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.