||2 weeks ago|
|build||4 months ago|
|cmd/myapp||4 months ago|
|pkg/version||4 months ago|
|.editorconfig||2 weeks ago|
|.gitignore||4 months ago|
|Dockerfile.in||4 months ago|
|Makefile||4 months ago|
|README.md||4 months ago|
|go.mod||2 weeks ago|
Go app template build environment
This is a skeleton project for a Go application, which captures the best build techniques I have learned to date. It uses a Makefile to drive the build (the universal API to software projects) and a Dockerfile to build a docker image.
This has only been tested on Linux, and depends on Docker to build.
To use this, simply copy these files and make the following changes:
BINto your binary name
REGISTRYto the Docker registry you want to use
- maybe change
SRC_DIRSif you use some other layout
- choose a strategy for
VERSIONvalues - git tags or manual
- maybe change or remove the
USERif you need
This assumes the use of go modules (which will be the default for all Go builds
as of Go 1.13) and vendoring (which reasonable minds might disagree about).
You will need to run
go mod vendor to create a
vendor directory when you
make build to compile your app. This will use a Docker image
to build your app, with the current directory volume-mounted into place. This
will store incremental state for the fastest possible build. Run
make all-build to build for all architectures.
make container to build the container image. It will calculate the image
tag based on the most recent git tag, and whether the repo is "dirty" since
that tag (see
make version). Run
make all-container to build containers
for all architectures.
make push to push the container image to
to push the container images for all architectures.
make clean to clean up.