New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to build image with multiple tags #380
Conversation
Adds tags property to DockerBuildImage task and deprecates tag. To preserve backward compatibility if tag is defined, tags are ignored. Fix #286
private String imageCreation() { | ||
""" | ||
import com.bmuschko.gradle.docker.tasks.image.Dockerfile | ||
import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage | ||
|
||
task dockerfile(type: Dockerfile) { | ||
from 'ubuntu:12.04' | ||
from 'alpine' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
} else if (getTags()) { | ||
def tagListString = getTags().collect {"'${it}'"}.join(", ") | ||
logger.quiet "Using tags ${tagListString} for image." | ||
buildImageCmd.withTags(getTags()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we allow for both? Maybe something like:
def allTags = [] + getTags()
if (getTag()) { allTags << getTag() }
if (allTags) {
def tagListString = allTags.collect {"'${it}'"}.join(", ")
logger.quiet "Using tags ${tagListString} for image."
buildImageCmd.withTags(allTags)
}
May be a better more succinct way to write this but I can def see folks defining a default tag and then possibly through a doFirst
block add additional tags at runtime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor comment to address about allowing for both. Let me know what you think.
I take that back. Doing so is going to promote bad behavior and force us to maintain both ways for longer than is necessary. Merging now. |
Exactly! |
Adds
tags
property toDockerBuildImage
task and deprecatestag
property.To preserve backward compatibility if
tag
is defined,tags
are ignored.Fix #286