A Makefile/Dockerfile example for Go projects.
 
 
 
Go to file
Tim Hockin 9179426e53 Fix travis 2019-01-28 11:48:28 -08:00
build Update build to latest thinking 2019-01-25 13:57:14 -08:00
cmd/myapp Import first rev of project template 2016-09-20 21:15:39 -07:00
pkg/version Add a godoc comment to version 2017-02-14 14:00:50 -08:00
.gitignore Add base image (busybox) for other arch's 2016-09-22 22:48:12 -07:00
.travis.yml Fix travis 2019-01-28 11:48:28 -08:00
Dockerfile.in Update build to latest thinking 2019-01-25 13:57:14 -08:00
LICENSE Initial commit 2016-09-20 20:16:58 -07:00
Makefile Clean up BASEIMAGE handling 2019-01-28 11:41:28 -08:00
README.md Add a rudimentary test environment based on Travis (#24) 2017-10-26 01:23:05 +02:00

README.md

Go app template build environment

Build Status

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.

Customizing it

To use this, simply copy these files and make the following changes:

Makefile:

  • change BIN to your binary name
  • rename cmd/myapp to cmd/$BIN
  • change PKG to the Go import path of this repo
  • change REGISTRY to the Docker registry you want to use
  • maybe change SRC_DIRS if you use some other layout
  • choose a strategy for VERSION values - git tags or manual

Dockerfile.in:

  • change the MAINTAINER to you
  • maybe change or remove the USER if you need

Building

Run make or 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.

Run 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.

Run make push to push the container image to REGISTRY. Run make all-push to push the container images for all architectures.

Run make clean to clean up.