Skip to content

Commit

Permalink
Merge pull request #338 from gythialy/hotfix/read-me
Browse files Browse the repository at this point in the history
docs: update README
  • Loading branch information
cpanato authored Oct 2, 2024
2 parents cf1af1b + e672372 commit bed2286
Showing 1 changed file with 44 additions and 48 deletions.
92 changes: 44 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,70 +4,66 @@ Docker container to do cross compilation (Linux, windows, macOS, ARM, ARM64) of

## Docker images

- Find it on GitHub packages
### Pre-built Images

- golang-cross
```
docker pull ghcr.io/gythialy/golang-cross:latest
```
- golang-cross-builder
```
docker pull ghcr.io/gythialy/golang-cross-builder:v1.22.0-0-bullseye
```
```
docker pull ghcr.io/gythialy/golang-cross-builder:v1.17.1
```
- golang-cross
```
docker pull ghcr.io/gythialy/golang-cross:latest
```
- golang-cross-builder
```
docker pull ghcr.io/gythialy/golang-cross-builder:v1.22.0-0-bullseye
docker pull ghcr.io/gythialy/golang-cross-builder:v1.17.1
```

### Build your own
- Build base image (optional)
```
docker build -f Dockerfile_builder -t ghcr.io/gythialy/golang-cross-builder:v1.17.1 .
# if running docker on M1 (arm64) macOS:
docker build --platform linux/amd64 -f Dockerfile.builder -t ghcr.io/gythialy/golang-cross-builder:v1.18 .
```
> 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)
- Build your own images
- Build base image (optional)
```
docker build -f Dockerfile_builder -t ghcr.io/gythialy/golang-cross-builder:v1.17.1 .
```
if running docker on M1 (arm64) macbook:
```
docker build --platform linux/amd64 -f Dockerfile.builder -t ghcr.io/gythialy/golang-cross-builder:v1.18 .
```
> 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)
- Build golang-cross image
```
docker build --build-arg GO_VERSION=1.22.0 \
--build-arg OS_CODENAME=bullseye \
--build-arg GOLANG_DIST_SHA=542e936b19542e62679766194364f45141fde55169db2d8d01046555ca9eb4b8 \
--build-arg GORELEASER_VERSION=1.24.0 \
--build-arg GORELEASER_SHA=4b7d2f1e59ead8047fcef795d66236ff6f8cfe7302c1ff8fb31bd360a3c6f32e \
-f Dockerfile \
-t ghcr.io/gythialy/golang-cross:latest .
```
> The default arguments can be overridden with `--build-arg`
- Build golang-cross image
```
docker build --build-arg GO_VERSION=1.22.0 \
--build-arg OS_CODENAME=bullseye \
--build-arg GOLANG_DIST_SHA=542e936b19542e62679766194364f45141fde55169db2d8d01046555ca9eb4b8 \
--build-arg GORELEASER_VERSION=1.24.0 \
--build-arg GORELEASER_SHA=4b7d2f1e59ead8047fcef795d66236ff6f8cfe7302c1ff8fb31bd360a3c6f32e \
-f Dockerfile \
-t ghcr.io/gythialy/golang-cross:latest .
```
> Override default arguments with `--build-arg`
## How to use
## Usage

- Prepare [GoReleaser](https://goreleaser.com/intro/) configuration

- Generate environment variable `PRIVATE_KEY` from the GPG private key (optional), if enable the [signing](https://goreleaser.com/customization/sign/) feature
- Set up GPG signing (optional), if enable the [signing](https://goreleaser.com/customization/sign/) feature

```bash
export PRIVATE_KEY=$(cat ~/private_key.gpg | base64)
```

- Run docker container to build the binaries

- Build the binaries:
```bash
export GO_BUILDER_VERSION=v1.17.1
docker run --rm --privileged \
-e PRIVATE_KEY=$(PRIVATE_KEY) \
-v $(CURDIR):/golang-cross-example \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(GOPATH)/src:/go/src \
-w /golang-cross-example \
ghcr.io/gythialy/golang-cross:$(GO_BUILDER_VERSION) --snapshot --rm-dist
export GO_BUILDER_VERSION=v1.17.1;
docker run --rm --privileged \
-e PRIVATE_KEY=$(PRIVATE_KEY) \
-v $(CURDIR):/golang-cross-example \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(GOPATH)/src:/go/src \
-w /golang-cross-example \
ghcr.io/gythialy/golang-cross:$(GO_BUILDER_VERSION) --snapshot --rm-dist
```

## Practical example
## Examples

- [.goreleaser.yml](example/.goreleaser.yml)
- [Makefile](example/Makefile#L35-L42)

## Thanks
## Alternative projects

[![Jetbrains](assets/jetbrains-variant-3.svg)](https://www.jetbrains.com/?from=golang-cross)
- [goreleaser/goreleaser-cross](https://github.com/goreleaser/goreleaser-cross)

0 comments on commit bed2286

Please sign in to comment.