Skip to content
This repository was archived by the owner on Mar 16, 2021. It is now read-only.

Commit 45bb3bb

Browse files
memorymxschmitt
authored andcommitted
make docker builds (more) host-OS independent (#102)
Sadly, `date --iso8601` is a GNU coreutils-ism, and returns an error on platforms that still ship a more generically posix-esque `/bin/date`: notably FreeBSD and macOS do not support the flag. Replace with a standard date formatstring that should be portable to both Linux macOS. (And probably Solaris/OpenSolaris/SmartOS as well?)
1 parent f8086c7 commit 45bb3bb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ getGoDependencies:
2323
buildProject:
2424
rm -rf releases
2525
mkdir releases
26-
gox -output="releases/{{.Dir}}_{{.OS}}_{{.Arch}}/{{.Dir}}" -osarch="linux/amd64 linux/arm windows/amd64 windows/386" -ldflags="-X github.com/mxschmitt/golang-url-shortener/util.ldFlagNodeJS=`node --version` -X github.com/mxschmitt/golang-url-shortener/util.ldFlagCommit=`git rev-parse HEAD` -X github.com/mxschmitt/golang-url-shortener/util.ldFlagYarn=`yarn --version` -X github.com/mxschmitt/golang-url-shortener/util.ldFlagCompilationTime=`date --iso-8601=seconds`"
26+
gox -output="releases/{{.Dir}}_{{.OS}}_{{.Arch}}/{{.Dir}}" -osarch="linux/amd64 linux/arm windows/amd64 windows/386" -ldflags="-X github.com/mxschmitt/golang-url-shortener/util.ldFlagNodeJS=`node --version` -X github.com/mxschmitt/golang-url-shortener/util.ldFlagCommit=`git rev-parse HEAD` -X github.com/mxschmitt/golang-url-shortener/util.ldFlagYarn=`yarn --version` -X github.com/mxschmitt/golang-url-shortener/util.ldFlagCompilationTime=`TZ=UTC date +%Y-%m-%dT%H:%M:%S+0000`"
2727
find releases -maxdepth 1 -mindepth 1 -type d -exec cp build/config.yaml {} \;
2828
find releases -maxdepth 1 -mindepth 1 -type d -exec tar -cvjf {}.tar.bz2 {} \;
2929

3030
buildDockerImage:
3131
rm -rf docker_releases
3232
mkdir docker_releases
33-
CGO_ENABLED=0 gox -output="docker_releases/{{.Dir}}_{{.OS}}_{{.Arch}}/{{.Dir}}" -osarch="linux/amd64 linux/arm" -ldflags="-X github.com/mxschmitt/golang-url-shortener/util.ldFlagNodeJS=`node --version` -X github.com/mxschmitt/golang-url-shortener/util.ldFlagCommit=`git rev-parse HEAD` -X github.com/mxschmitt/golang-url-shortener/util.ldFlagYarn=`yarn --version` -X github.com/mxschmitt/golang-url-shortener/util.ldFlagCompilationTime=`date --iso-8601=seconds`"
33+
CGO_ENABLED=0 gox -output="docker_releases/{{.Dir}}_{{.OS}}_{{.Arch}}/{{.Dir}}" -osarch="linux/amd64 linux/arm" -ldflags="-X github.com/mxschmitt/golang-url-shortener/util.ldFlagNodeJS=`node --version` -X github.com/mxschmitt/golang-url-shortener/util.ldFlagCommit=`git rev-parse HEAD` -X github.com/mxschmitt/golang-url-shortener/util.ldFlagYarn=`yarn --version` -X github.com/mxschmitt/golang-url-shortener/util.ldFlagCompilationTime=`TZ=UTC date +%Y-%m-%dT%H:%M:%S+0000`"
3434
docker build -t mxschmitt/golang_url_shortener:arm -f Dockerfile.arm .
35-
docker build -t mxschmitt/golang_url_shortener -f Dockerfile.amd64 .
35+
docker build -t mxschmitt/golang_url_shortener -f Dockerfile.amd64 .

0 commit comments

Comments
 (0)