Skip to content

Commit

Permalink
build arguments for custom Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
augi committed Aug 3, 2018
1 parent 6794a14 commit 8c4942c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Only `image` parameter is mandatory - it's name of the resulting image.
arguments = ['--server'] // arguments to be passed to your application; default: empty
dockerBuildDirectory = project.file('my-directory') // directory where Dockerfile is created; default: "$buildDir/dockerJava"
customDockerfile = file('Dockerfile') // path to a custom Dockerfile - then all of the previous options (except image and alternativeImages) are ignored; default: null
buildArgs = ['version=1.2.3'] // build arguments to be send to 'docker build' command when using custom Dockerfile; default: empty
// username and password are used if the Docker Registry requires credentials for pushing
username = 'registry-username'
password = System.getenv('DOCKER_REGISTRY_PASSWORD')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ class DistDockerTask extends DefaultTask {
def args = ['build', '-t', settings.image]
settings.alternativeImages.each { args.addAll(['-t', it]) }
args.addAll(['--file', settings.customDockerfile.name])
settings.buildArgs.each { args.addAll(['--build-arg', it]) }
args.add(settings.customDockerfile.parentFile.absolutePath)
dockerExecutor.execute(*args)
} else {
Expand Down Expand Up @@ -199,4 +200,6 @@ interface DistDockerSettings {
File getDockerBuildDirectory()
@Input @Optional
File getCustomDockerfile()
@Input @Optional
String[] getBuildArgs()
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class DockerJavaExtension implements DistDockerSettings, DockerPushSettings {
String[] arguments = []
File dockerBuildDirectory
File customDockerfile
String[] buildArgs = []

String username
String password
Expand Down

0 comments on commit 8c4942c

Please sign in to comment.