From 80e185001750c1bfd579ed3235ae053535f2aedd Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Mon, 9 May 2016 15:09:58 +0800 Subject: [PATCH] fix add version on docker build. Signed-off-by: Bo-Yi Wu --- .gitignore | 1 + Makefile | 3 ++- docker/Dockerfile.build | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 0302cf1..b7b8cdb 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,4 @@ build.tar.gz gorush.tar.gz gorush.db vendor +Dockerfile.tmp diff --git a/Makefile b/Makefile index 301c6e7..d559524 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,8 @@ html: docker_build: clean tar -zcvf build.tar.gz gorush.go gorush config storage Makefile glide.lock glide.yaml - docker build --rm -t $(BUILD_IMAGE) -f docker/Dockerfile.build . + sed -e "s/#VERSION#/$(VERSION)/g" docker/Dockerfile.build > docker/Dockerfile.tmp + docker build --rm -t $(BUILD_IMAGE) -f docker/Dockerfile.tmp . docker run --rm $(BUILD_IMAGE) > gorush.tar.gz docker build --rm -t $(PRODUCTION_IMAGE) -f docker/Dockerfile.dist . diff --git a/docker/Dockerfile.build b/docker/Dockerfile.build index 497dc0b..eeacbf0 100644 --- a/docker/Dockerfile.build +++ b/docker/Dockerfile.build @@ -2,12 +2,13 @@ FROM golang:1.6-alpine MAINTAINER Bo-Yi Wu +ENV VERSION #VERSION# RUN apk --update add git make RUN go get github.com/Masterminds/glide && cd $GOPATH/src/github.com/Masterminds/glide && make install RUN mkdir -p $GOPATH/src/github.com/appleboy/gorush Add build.tar.gz $GOPATH/src/github.com/appleboy/gorush/ WORKDIR $GOPATH/src/github.com/appleboy/gorush RUN make bundle -RUN GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o bin/gorush gorush.go +RUN GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X main.Version=${VERSION}" -o bin/gorush gorush.go CMD tar -C bin -czf - gorush