Skip to content

Commit

Permalink
feat: dockerBuildArgs added
Browse files Browse the repository at this point in the history
  • Loading branch information
augi committed Dec 19, 2020
1 parent 7b69a34 commit 53e92e1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Only `image` parameter is mandatory - it's name of the resulting image.
dockerfileLines = ['RUN apt-get ...'] // additional lines to include to Dockerfile; default: empty
arguments = ['--server'] // arguments to be passed to your application; default: empty
dockerBuildDirectory = project.file('my-directory') // directory where Dockerfile is created; default: "$buildDir/dockerJava"
dockerBuildArgs = ['--isolation=hyperv'] // additional arguments to be send to 'docker build' command
customDockerfile = file('Dockerfile') // path to a custom Dockerfile - then all of the previous options (except image and alternativeImages) are ignored; default: null
filesToCopy = [project.file('my-file-txt')] // list of files to copy to the Docker working directory (so these file can be copied to the image using COPY or ADD directives)
buildArgs = ['version=1.2.3'] // build arguments to be send to 'docker build' command when using custom Dockerfile; default: empty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ class DistDockerTask extends DefaultTask {
settings.alternativeImages.each { args.addAll(['-t', it]) }
args.addAll(['--file', settings.customDockerfile.name])
settings.buildArgs.each { args.addAll(['--build-arg', it]) }
args.addAll(settings.dockerBuildArgs)
args.add(workDir.toFile().absolutePath)
dockerExecutor.execute(*args)
} else {
Expand All @@ -175,6 +176,7 @@ class DistDockerTask extends DefaultTask {
createDockerfile(workDir.toFile(), tarRootDirectory, applicationJarFilename, startScripts)
def args = ['build', '-t', settings.image]
settings.alternativeImages.each { args.addAll(['-t', it]) }
args.addAll(settings.dockerBuildArgs)
args.add(workDir.toFile().absolutePath)
dockerExecutor.execute(*args)
}
Expand Down Expand Up @@ -202,6 +204,8 @@ interface DistDockerSettings {
String[] getDockerfileLines()
@Input @Optional
String[] getArguments()
@Input @Optional
String[] getDockerBuildArgs()
@InputDirectory @Optional
File getDockerBuildDirectory()
@Input @Optional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class DockerJavaExtension implements DistDockerSettings, DockerPushSettings {
Map<String, String> labels = [:]
String[] dockerfileLines = []
String[] arguments = []
String[] dockerBuildArgs = []
File dockerBuildDirectory
File[] filesToCopy = []
File customDockerfile
Expand Down

0 comments on commit 53e92e1

Please sign in to comment.