Merge pull request #3 from Clever/publish-latest

Also publish "latest" image
This commit is contained in:
kvigen 2014-06-25 15:09:16 -07:00
commit 022a8b3908
2 changed files with 8 additions and 3 deletions

View file

@ -51,8 +51,9 @@ func (d *Docker) Write(f *buildfile.Buildfile, r *repo.Repo) {
dockerServerUrl := d.Server + ":" + strconv.Itoa(d.Port)
splitRepoName := strings.Split(r.Name, "/")
dockerRepo := d.RepoBaseName + "/" + splitRepoName[len(splitRepoName) - 1]
// Run the command commands to build and deploy the image. Note that the image is tagged
// with the git hash.
// Run the command commands to build and deploy the image. Note that we both create a new image
// tagged with the git hash as well as update the "latest" image.
f.WriteCmd(fmt.Sprintf("docker -H %s build -t %s - < %s", dockerServerUrl, dockerRepo, d.Dockerfile))
f.WriteCmd(fmt.Sprintf("docker -H %s build -t %s:$(git rev-parse --short HEAD) - < %s",
dockerServerUrl, dockerRepo, d.Dockerfile))

View file

@ -58,9 +58,13 @@ func TestValidYaml(t *testing.T) {
if err != nil {
t.Fatalf("Can't unmarshal script: %s", err.Error())
}
if !strings.Contains(response, "docker -H server:1000 build -t base_repo/name - <") {
t.Fatalf("Response: " + response + " doesn't contain build command for latest")
}
if !strings.Contains(response, "docker -H server:1000 build -t base_repo/name" +
":$(git rev-parse --short HEAD)") {
t.Fatalf("Response: " + response + "doesn't contain build command")
t.Fatalf("Response: " + response + "doesn't contain build command for commit hash")
}
if !strings.Contains(response, "docker -H server:1000 login -u user -p password -e email") {
t.Fatalf("Response: " + response + " doesn't contain login command")