docker: second --ldflags was overriding the first --ldflags option

This commit is contained in:
Krishna Srinivas 2015-11-06 23:39:26 -08:00
parent 03f185db5f
commit f77851bee0
5 changed files with 20 additions and 9 deletions

View File

@ -1,5 +1,5 @@
LDFLAGS := $(shell go run buildscripts/gen-ldflags.go) LDFLAGS := $(shell go run buildscripts/gen-ldflags.go)
DOCKER_LDFLAGS = '-extldflags "-static"' DOCKER_LDFLAGS := $(LDFLAGS) -extldflags "-static"
TAG := latest TAG := latest
all: install all: install
@ -55,7 +55,7 @@ test: build
@GO15VENDOREXPERIMENT=1 go test $(GOFLAGS) github.com/minio/minio/pkg... @GO15VENDOREXPERIMENT=1 go test $(GOFLAGS) github.com/minio/minio/pkg...
gomake-all: build gomake-all: build
GO15VENDOREXPERIMENT=1 go build --ldflags $(LDFLAGS) -o $(GOPATH)/bin/minio @GO15VENDOREXPERIMENT=1 go build --ldflags '$(LDFLAGS)' -o $(GOPATH)/bin/minio
pkg-add: pkg-add:
@GO15VENDOREXPERIMENT=1 govendor add $(PKG) @GO15VENDOREXPERIMENT=1 govendor add $(PKG)
@ -70,7 +70,7 @@ install: gomake-all
dockerimage: install dockerimage: install
@echo "Building docker image:" minio:$(TAG) @echo "Building docker image:" minio:$(TAG)
@GO15VENDOREXPERIMENT=1 go build --ldflags $(LDFLAGS) --ldflags $(DOCKER_LDFLAGS) -o minio.dockerimage @GO15VENDOREXPERIMENT=1 go build --ldflags '$(DOCKER_LDFLAGS)' -o minio.dockerimage
@mkdir -p export @mkdir -p export
@docker build --rm --tag=minio:$(TAG) . @docker build --rm --tag=minio:$(TAG) .
@rmdir export @rmdir export

View File

@ -26,9 +26,10 @@ build_script:
- go test -race . - go test -race .
- go test github.com/minio/minio/pkg... - go test github.com/minio/minio/pkg...
- go test -race github.com/minio/minio/pkg... - go test -race github.com/minio/minio/pkg...
- go run buildscripts/gen-ldflags.go > temp.txt # FIXME: appveyor build has errors related to LDFLAGS
- set /p LDFLAGS=<temp.txt # - go run buildscripts/gen-ldflags.go > temp.txt
- go build --ldflags %LDFLAGS% -o %GOPATH%\bin\minio.exe # - set /p LDFLAGS=<temp.txt
# - go build --ldflags %LDFLAGS% -o %GOPATH%\bin\minio.exe
# to disable automatic tests # to disable automatic tests
test: off test: off

View File

@ -28,10 +28,10 @@ import (
func genLDFlags(version string) string { func genLDFlags(version string) string {
var ldflagsStr string var ldflagsStr string
ldflagsStr = "\"-X main.minioVersion=" + version + " " ldflagsStr = "-X main.minioVersion=" + version + " "
ldflagsStr = ldflagsStr + "-X main.minioReleaseTag=" + releaseTag(version) + " " ldflagsStr = ldflagsStr + "-X main.minioReleaseTag=" + releaseTag(version) + " "
ldflagsStr = ldflagsStr + "-X main.minioCommitID=" + commitID() + " " ldflagsStr = ldflagsStr + "-X main.minioCommitID=" + commitID() + " "
ldflagsStr = ldflagsStr + "-X main.minioShortCommitID=" + commitID()[:12] + "\"" ldflagsStr = ldflagsStr + "-X main.minioShortCommitID=" + commitID()[:12]
return ldflagsStr return ldflagsStr
} }

View File

@ -156,6 +156,9 @@ func main() {
probe.Init() // Set project's root source path. probe.Init() // Set project's root source path.
probe.SetAppInfo("Release-Tag", minioReleaseTag) probe.SetAppInfo("Release-Tag", minioReleaseTag)
probe.SetAppInfo("Commit-ID", minioShortCommitID) probe.SetAppInfo("Commit-ID", minioShortCommitID)
if os.Getenv("DOCKERIMAGE") == "1" {
probe.SetAppInfo("Docker-Image", "true")
}
app := registerApp() app := registerApp()
app.Before = func(c *cli.Context) error { app.Before = func(c *cli.Context) error {

View File

@ -16,7 +16,11 @@
package main package main
import "github.com/minio/cli" import (
"os"
"github.com/minio/cli"
)
var versionCmd = cli.Command{ var versionCmd = cli.Command{
Name: "version", Name: "version",
@ -34,4 +38,7 @@ func mainVersion(ctxx *cli.Context) {
Println("Version: " + minioVersion) Println("Version: " + minioVersion)
Println("Release-Tag: " + minioReleaseTag) Println("Release-Tag: " + minioReleaseTag)
Println("Commit-ID: " + minioCommitID) Println("Commit-ID: " + minioCommitID)
if os.Getenv("DOCKERIMAGE") == "1" {
Println("Docker-Image: " + "true")
}
} }