diff --git a/README.md b/README.md index 139c685..d28920a 100644 --- a/README.md +++ b/README.md @@ -40,20 +40,20 @@ or install it through command line: On `OSX`: ```bash -curl -sL https://github.com/coveo/tgf/releases/download/v1.19.0/tgf_1.19.0_macOS_64-bits.zip | bsdtar -xf- -C /usr/local/bin +curl -sL https://github.com/coveo/tgf/releases/download/v1.19.1/tgf_1.19.1_macOS_64-bits.zip | bsdtar -xf- -C /usr/local/bin ``` On `Linux`: ```bash -curl -sL https://github.com/coveo/tgf/releases/download/v1.19.0/tgf_1.19.0_linux_64-bits.zip | gzip -d > /usr/local/bin/tgf && chmod +x /usr/local/bin/tgf +curl -sL https://github.com/coveo/tgf/releases/download/v1.19.1/tgf_1.19.1_linux_64-bits.zip | gzip -d > /usr/local/bin/tgf && chmod +x /usr/local/bin/tgf ``` On `Windows` with Powershell: ```powershell [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -Invoke-WebRequest https://github.com/coveo/tgf/releases/download/v1.19.0/tgf_1.19.0_windows_64-bits.zip -OutFile tgf.zip +Invoke-WebRequest https://github.com/coveo/tgf/releases/download/v1.19.1/tgf_1.19.1_windows_64-bits.zip -OutFile tgf.zip ``` ## Configuration diff --git a/config.go b/config.go index ffaac28..9729a42 100644 --- a/config.go +++ b/config.go @@ -106,9 +106,9 @@ func (cb TGFConfigBuild) Dir() string { // GetTag returns the tag name that should be added to the image func (cb TGFConfigBuild) GetTag() string { - tag := filepath.Base(filepath.Dir(cb.source)) - if cb.Tag != "" { - tag = cb.Tag + tag := cb.Tag + if tag == "" { + tag = fmt.Sprintf("%s-%s", filepath.Base(filepath.Dir(cb.source)), cb.hash()) } tagRegex := regexp.MustCompile(`[^a-zA-Z0-9\._-]`) return tagRegex.ReplaceAllString(tag, "") diff --git a/config_test.go b/config_test.go index 4b94aaa..e978c01 100644 --- a/config_test.go +++ b/config_test.go @@ -107,7 +107,7 @@ func TestSetConfigDefaultValues(t *testing.T) { assert.Equal(t, "RUN ls test", config.imageBuildConfigs[1].Instructions) assert.Equal(t, "/abspath/my-folder", config.imageBuildConfigs[1].Folder) assert.Equal(t, "/abspath/my-folder", config.imageBuildConfigs[1].Dir()) - assert.Equal(t, "AWS", config.imageBuildConfigs[1].GetTag()) + assert.Equal(t, "AWS-b74da21c62057607be2582b50624bf40", config.imageBuildConfigs[1].GetTag()) assert.Equal(t, "coveo/stuff", config.Image) assert.Equal(t, "test", *config.ImageTag) diff --git a/docker.go b/docker.go index 8d769fa..ecdedbb 100644 --- a/docker.go +++ b/docker.go @@ -207,6 +207,7 @@ func getImage() (name string) { name += ":latest" } + lastHash := "" for i, ib := range config.imageBuildConfigs { var temp, folder, dockerFile string var out *os.File @@ -244,6 +245,10 @@ func getImage() (name string) { }() } + // We remove the last hash from the name to avoid cumulating several hash in the final name + name = strings.Replace(name, lastHash, "", 1) + lastHash = fmt.Sprintf("-%s", ib.hash()) + name = name + "-" + ib.GetTag() if image, tag := Split2(name, ":"); len(tag) > maxDockerTagLength { name = image + ":" + tag[0:maxDockerTagLength] diff --git a/main.go b/main.go index 5dafbb7..fa1cccb 100644 --- a/main.go +++ b/main.go @@ -147,7 +147,7 @@ func main() { app.Switch("no-temp", "Disable the mapping of the temp directory (alias --nt)").BoolVar(&noTemp) app.Switch("refresh-image", "Force a refresh of the docker image (alias --ri)").BoolVar(&refresh) app.Switch("local-image", "If set, TGF will not pull the image when refreshing (alias --li)").BoolVar(&useLocalImage) - app.Switch("interactive", "If set, docker will be launched in interactive mode, i.e. the -it flag will be passed to the docker cli (alias --it) or set "+envInteractive).Envar(envInteractive).BoolVar(&dockerInteractive) + app.Switch("interactive", "On by default, use --no-interactive or --no-it to disable launching Docker in interactive mode or set "+envInteractive+" to 0 or false").Envar(envInteractive).BoolVar(&dockerInteractive) app.Argument("mount-point", "Specify a mount point for the current folder --mp)").StringVar(&mountPoint) app.Argument("docker-arg", "Supply extra argument to Docker (alias --da)").PlaceHolder("").StringsVar(&dockerOptions) app.Argument("ignore-user-config", "Ignore all tgf.user.config files (alias --iuc)").BoolVar(&disableUserConfig)