add latest tag to every latest image dokku push

This commit is contained in:
Krzysztof Taraszka
2024-02-12 14:29:34 +01:00
parent d12eff3fe4
commit b6cf0ac410

View File

@@ -88,6 +88,7 @@ func pushToRegistry(appName string, tag int, imageID string, imageRepo string) e
imageTag, _ := common.GetRunningImageTag(appName, "")
fullImage := fmt.Sprintf("%s%s:%d", registryServer, imageRepo, tag)
latestImage := fmt.Sprintf("%s%s:latest", registryServer, imageRepo)
common.LogVerboseQuiet(fmt.Sprintf("Tagging %s:%d in registry format", imageRepo, tag))
if !dockerTag(imageID, fullImage) {
@@ -100,9 +101,11 @@ func pushToRegistry(appName string, tag int, imageID string, imageRepo string) e
return errors.New("Unable to tag image")
}
// For the future, we should also add the ability to create the remote repository
// This is only really important for registries that do not support creation on push
// Examples include AWS and Quay.io
// Tagging the image as latest
common.LogVerboseQuiet(fmt.Sprintf("Tagging %s as latest in registry format", imageRepo))
if !dockerTag(imageID, latestImage) {
return errors.New("Unable to tag image as latest")
}
common.LogVerboseQuiet(fmt.Sprintf("Pushing %s", fullImage))
if !dockerPush(fullImage) {
@@ -110,6 +113,12 @@ func pushToRegistry(appName string, tag int, imageID string, imageRepo string) e
return errors.New("Unable to push image")
}
// Pushing the latest tag
common.LogVerboseQuiet(fmt.Sprintf("Pushing %s", latestImage))
if !dockerPush(latestImage) {
return errors.New("Unable to push image with latest tag")
}
// Only clean up when the scheduler is not docker-local
// other schedulers do not retire local images
if common.GetAppScheduler(appName) != "docker-local" {