Com.palantir.docker: Difference between revisions
Jump to navigation
Jump to search
(→name) |
|||
Line 99: | Line 99: | ||
name the name to use for this container, may include a tag | name the name to use for this container, may include a tag | ||
==dockerfile== | |||
The dockerfile to use for building the image. It defaults to project.file('Dockerfile') and must be a file object. | |||
<syntaxhighlight lang='groovy'> | |||
docker { | |||
... | |||
dockerfile file('Dockerfile') | |||
... | |||
} | |||
</syntaxhighlight> | |||
==files== | |||
An argument list of files to be included in the Docker build context. |
Revision as of 05:32, 24 February 2019
External
Internal
Overview
Latest Version
Example
buildscript {
ext {
...
dockerGradleVersion = '0.21.0'
}
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
...
classpath("gradle.plugin.com.palantir.gradle.docker:gradle-docker:${dockerGradleVersion}")
}
}
ext {
dockerNamespace = "com.example/playground"
}
...
apply plugin: 'com.palantir.docker'
...
docker {
dependsOn build
// bootJar.baseName resolves to the artifact name, without version and extension information
name "${dockerNamespace}/${bootJar.baseName}"
dockerfile file('Dockerfile')
// bootJar.archivePath resolves to the absolute path of the artifact file
files bootJar.archivePath
// bootJar.archiveName resolves to the artifact name, including version and extension
buildArgs(['JAR_FILE': "${bootJar.archiveName}"])
}
The corresponding Dockerfile:
FROM openjdk:8-jdk-alpine
ARG JAR_FILE
COPY ${JAR_FILE} app.jar
RUN apk --no-cache add curl bash bind-tools
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
Execute
gradle clean docker
The command will build the container image and place into the local registry as "com.example/playground/myartifact" with the "latest" tag.
Configuration
The plugin configuration is applied in a docker {} script block. The following parameters are available:
name
The container name. Includes the namespace and may include a tag. Example:
docker {
...
name com.example/my-container:latest
...
}
name the name to use for this container, may include a tag
dockerfile
The dockerfile to use for building the image. It defaults to project.file('Dockerfile') and must be a file object.
docker {
...
dockerfile file('Dockerfile')
...
}
files
An argument list of files to be included in the Docker build context.