@@ -4,70 +4,66 @@ Docker container to do cross compilation (Linux, windows, macOS, ARM, ARM64) of
4
4
5
5
## Docker images
6
6
7
- - Find it on GitHub packages
7
+ ### Pre-built Images
8
8
9
- - golang-cross
10
- ```
11
- docker pull ghcr.io/gythialy/golang-cross:latest
12
- ```
13
- - golang-cross-builder
14
- ```
15
- docker pull ghcr.io/gythialy/golang-cross-builder:v1.22.0-0-bullseye
16
- ```
17
- ```
18
- docker pull ghcr.io/gythialy/golang-cross-builder:v1.17.1
19
- ```
9
+ - golang-cross
10
+ ```
11
+ docker pull ghcr.io/gythialy/golang-cross:latest
12
+ ```
13
+ - golang-cross-builder
14
+ ```
15
+ docker pull ghcr.io/gythialy/golang-cross-builder:v1.22.0-0-bullseye
16
+ docker pull ghcr.io/gythialy/golang-cross-builder:v1.17.1
17
+ ```
18
+
19
+ ### Build your own
20
+ - Build base image (optional)
21
+ ```
22
+ docker build -f Dockerfile_builder -t ghcr.io/gythialy/golang-cross-builder:v1.17.1 .
23
+ # if running docker on M1 (arm64) macOS:
24
+ docker build --platform linux/amd64 -f Dockerfile.builder -t ghcr.io/gythialy/golang-cross-builder:v1.18 .
25
+ ```
26
+ > Note: [ Pack the SDK] ( https://github.com/tpoechtrager/osxcross#packaging-the-sdk ) first or use [ GitHub Action] ( https://github.com/gythialy/golang-cross/actions/workflows/osx-sdk.yaml )
20
27
21
- - Build your own images
22
- - Build base image (optional)
23
- ```
24
- docker build -f Dockerfile_builder -t ghcr.io/gythialy/golang-cross-builder:v1.17.1 .
25
- ```
26
- if running docker on M1 (arm64) macbook:
27
- ```
28
- docker build --platform linux/amd64 -f Dockerfile.builder -t ghcr.io/gythialy/golang-cross-builder:v1.18 .
29
- ```
30
- > Please follow the guide to [pack the SDK](https://github.com/tpoechtrager/osxcross#packaging-the-sdk) first or build by [GitHub Action](https://github.com/gythialy/golang-cross/actions/workflows/osx-sdk.yaml)
31
- - Build golang-cross image
32
- ```
33
- docker build --build-arg GO_VERSION=1.22.0 \
34
- --build-arg OS_CODENAME=bullseye \
35
- --build-arg GOLANG_DIST_SHA=542e936b19542e62679766194364f45141fde55169db2d8d01046555ca9eb4b8 \
36
- --build-arg GORELEASER_VERSION=1.24.0 \
37
- --build-arg GORELEASER_SHA=4b7d2f1e59ead8047fcef795d66236ff6f8cfe7302c1ff8fb31bd360a3c6f32e \
38
- -f Dockerfile \
39
- -t ghcr.io/gythialy/golang-cross:latest .
40
- ```
41
- > The default arguments can be overridden with `--build-arg`
28
+ - Build golang-cross image
29
+ ```
30
+ docker build --build-arg GO_VERSION=1.22.0 \
31
+ --build-arg OS_CODENAME=bullseye \
32
+ --build-arg GOLANG_DIST_SHA=542e936b19542e62679766194364f45141fde55169db2d8d01046555ca9eb4b8 \
33
+ --build-arg GORELEASER_VERSION=1.24.0 \
34
+ --build-arg GORELEASER_SHA=4b7d2f1e59ead8047fcef795d66236ff6f8cfe7302c1ff8fb31bd360a3c6f32e \
35
+ -f Dockerfile \
36
+ -t ghcr.io/gythialy/golang-cross:latest .
37
+ ```
38
+ > Override default arguments with ` --build-arg `
42
39
43
- ## How to use
40
+ ## Usage
44
41
45
42
- Prepare [ GoReleaser] ( https://goreleaser.com/intro/ ) configuration
46
43
47
- - Generate environment variable `PRIVATE_KEY` from the GPG private key (optional), if enable the [signing](https://goreleaser.com/customization/sign/) feature
44
+ - Set up GPG signing (optional), if enable the [ signing] ( https://goreleaser.com/customization/sign/ ) feature
48
45
49
46
``` bash
50
47
export PRIVATE_KEY=$( cat ~ /private_key.gpg | base64)
51
48
```
52
49
53
- - Run docker container to build the binaries
54
-
50
+ - Build the binaries:
55
51
``` bash
56
- export GO_BUILDER_VERSION=v1.17.1
57
- docker run --rm --privileged \
58
- -e PRIVATE_KEY=$( PRIVATE_KEY) \
59
- -v $( CURDIR) :/golang-cross-example \
60
- -v /var/run/docker.sock:/var/run/docker.sock \
61
- -v $( GOPATH) /src:/go/src \
62
- -w /golang-cross-example \
63
- ghcr.io/gythialy/golang-cross:$( GO_BUILDER_VERSION) --snapshot --rm-dist
52
+ export GO_BUILDER_VERSION=v1.17.1;
53
+ docker run --rm --privileged \
54
+ -e PRIVATE_KEY=$( PRIVATE_KEY) \
55
+ -v $( CURDIR) :/golang-cross-example \
56
+ -v /var/run/docker.sock:/var/run/docker.sock \
57
+ -v $( GOPATH) /src:/go/src \
58
+ -w /golang-cross-example \
59
+ ghcr.io/gythialy/golang-cross:$( GO_BUILDER_VERSION) --snapshot --rm-dist
64
60
```
65
61
66
- ## Practical example
62
+ ## Examples
67
63
68
64
- [ .goreleaser.yml] ( example/.goreleaser.yml )
69
65
- [ Makefile] ( example/Makefile#L35-L42 )
70
66
71
- ## Thanks
67
+ ## Alternative projects
72
68
73
- [ ![ Jetbrains ] ( assets/jetbrains-variant-3.svg ) ]( https://www.jetbrains. com/?from=golang -cross )
69
+ - [ goreleaser/goreleaser-cross ] ( https://github. com/goreleaser/goreleaser -cross )
0 commit comments