Public Repository

Last pushed: 3 months ago
Short Description
Build cross-platform Go apps inside a Docker container
Full Description

Golang App Builder

Compiles Go source code (1.5+) using a Docker container to eliminate the
need to install a Go compiler on the host machine. Output is saved to bin/.

Compile for Darwin and Linux (Default)

docker run --rm -it -v $(PWD):/src healthcareblocks/gobuild

Other Examples

Darwin, 64-bit only

docker run --rm -it -v $(PWD):/src healthcareblocks/gobuild -o darwin -a amd64

Darwin, 32-bit and 64-bit

docker run --rm -it -v $(PWD):/src healthcareblocks/gobuild -o darwin

Linux, 64-bit only

docker run --rm -it -v $(PWD):/src healthcareblocks/gobuild -o linux -a amd64

Linux ARM 6 and 7

docker run --rm -it -v $(PWD):/src healthcareblocks/gobuild -o linux -a arm -m 6,7

Windows 64-bit

docker run --rm -it -v $(PWD):/src healthcareblocks/gobuild -o windows -a amd64

Refer to https://golang.org/doc/install/source#environment for supported platforms.

Naming Convention

Compiled artifacts are named per $name-$goos-$goarch[-$goarm] with $name variable
set to your main package name by default. To override $name, set the -n flag:

docker run --rm -it -v $(PWD):/src healthcareblocks/gobuild -n hamster

Example Makefile

.DEFAULT_GOAL := build

build:
    @docker run --rm -it -v $(PWD):/src healthcareblocks/gobuild -o darwin(or linux) -a amd64

release:
    @docker run --rm -it -v $(PWD):/src healthcareblocks/gobuild

.PHONY: build release

Canonical Import Path

The builder uses Go to determine the import path for your application and then
sets up the appropriate directory structure in order to compile successfully.

Your "main" package must have the following notation:

package main // import "github.com/MyRepo/hello"

See https://golang.org/doc/go1.4#canonicalimports for the why and how.

Credits

This project was inspired by https://github.com/CenturyLinkLabs/golang-builder.

Docker Pull Command
Owner
healthcareblocks

Comments (0)