defaultBuildArgs
This commit is contained in:
parent
49ad1a64a6
commit
f0594afc4c
|
@ -63,22 +63,20 @@ func commandBuild(build Build, dryrun bool) *exec.Cmd {
|
|||
"-f", build.Dockerfile,
|
||||
}
|
||||
|
||||
defaultBuildArgs := []string{
|
||||
fmt.Sprintf("DOCKER_IMAGE_CREATED=%s", time.Now().Format(time.RFC3339)),
|
||||
}
|
||||
|
||||
// determine git epoch to define SOURCE_DATE_EPOCH build_arg
|
||||
r, _ := git.PlainOpen(".")
|
||||
ref, _ := r.Head()
|
||||
iter, _ := r.Log(&git.LogOptions{From: ref.Hash()})
|
||||
commit, _ := iter.Next()
|
||||
build.Epoch = commit.Author.When.Unix()
|
||||
os.Setenv("SOURCE_DATE_EPOCH", strconv.FormatInt(build.Epoch, 10))
|
||||
// os.Setenv("SOURCE_DATE_EPOCH", strconv.FormatInt(build.Epoch, 10))
|
||||
|
||||
defaultBuildArgs := []string{
|
||||
fmt.Sprintf("DOCKER_IMAGE_CREATED=%s", time.Now().Format(time.RFC3339)),
|
||||
fmt.Sprintf("SOURCE_DATE_EPOCH=%s", strconv.FormatInt(build.Epoch, 10)),
|
||||
}
|
||||
|
||||
args = append(args, build.Context)
|
||||
// if !dryrun {
|
||||
// args = append(args, "--push")
|
||||
// }
|
||||
if build.Compress {
|
||||
args = append(args, "--compress")
|
||||
}
|
||||
|
@ -100,7 +98,6 @@ func commandBuild(build Build, dryrun bool) *exec.Cmd {
|
|||
for _, arg := range append(defaultBuildArgs, build.Args.Value()...) {
|
||||
args = append(args, "--build-arg", arg)
|
||||
}
|
||||
args = append(args, "--build-arg SOURCE_DATE_EPOCH="+strconv.FormatInt(build.Epoch, 10))
|
||||
for _, host := range build.AddHost.Value() {
|
||||
args = append(args, "--add-host", host)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue