Docker
Distribution Support
Distribution | Supported | Buildx |
---|---|---|
Building and publishing docker images requires the docker command and a running Docker deamon.
JReleaser will not install these tools.
|
docker.io will be set as default registry (with "DEFAULT" as name) if no registries are configured. The chosen
username will be set to match the Git username.
|
Configuration
Legend:
-
required
-
optional
-
may use environment variable
-
accepts Name Templates
#
packagers:
#
docker:
# Enables or disables Docker.
# Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
# Defaults to `NEVER`.
#
active: ALWAYS
# Let the release continue if the packager fails.
# Defaults to `false`.
#
continueOnError: true
# Custom download URL.
#
downloadUrl: https://my.server.com/{{projectName}}/{{tagName}}/{{artifactFile}}
# Additional properties used when evaluating templates.
#
extraProperties:
# Key will be capitalized and prefixed with `docker`, i.e, `dockerFoo`.
foo: bar
# Directory with file templates used to prepare the Docker distribution.
# Defaults to `src/jreleaser/distributions/#{distribution.name}/docker`.
# If specified, path must exist.
#
templateDirectory: path/to/docker/templates
# List of template files to be skipped.
# Value may be an exact match or a regex.
#
skipTemplates:
- README.md.tpl
# Git author used to commit to the repository.
#
commitAuthor:
# Name used when authoring commits.
# Defaults to `jreleaserbot`.
#
name: jreleaserbot
# E-mail used when authoring commits.
# Defaults to `jreleaser@kordamp.org`.
#
email: jreleaser@kordamp.org
# Git repository to push the Dockerfile to.
# Defaults are shown.
#
repository:
# Enables or disables the repository.
# Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
# Defaults to `RELEASE`.
#
active: ALWAYS
# Stores files in a folder matching the image's version/tag.
# Defaults to `false`.
#
versionedSubfolders: true
# The owner of the repository.
# Defaults to the same owner as the release repository.
#
owner: duke
# The name of the repository.
# Defaults to `app-docker`.
#
name: app-docker
# The tag associated with the Dockerfile.
# If left unspecified, will use `{{tagName}}`.
#
tagName: '{{distributionName}}-{{tagName}}'
# The target branch to pull from.
# Defaults to the branch pointed by HEAD.
#
branch: HEAD
# The target branch to push to.
# Defaults to the branch pointed by `#{branch}`.
#
branchPush: '{{projectName}}-{{tagName}}'
# Username used for authoring commits.
# Must have write access to the repository.
# Defaults to the same username as the release repository.
#
username: duke
# Password or OAuth token with write access to the repository.
#
token: __USE_ENVIRONMENT_VARIABLE__
# Message when committing to the repository.
# If left unspecified, `{{distributionName}} {{tagName}}` will be used.
#
commitMessage: '{{distributionName}} {{tagName}}'
# Additional properties used when evaluating templates.
#
extraProperties:
# Key will be capitalized and prefixed with `repository`, i.e, `repositoryFoo`.
foo: bar
# The base Docker image to use.
#
baseImage: "alpine:latest"
# A list of image names.
# If unspecified, a single image `{{repoOwner}}/{{distributionName}}:{{tagName}}`
# will be created.
#
imageNames:
- "{{repoOwner}}/{{distributionName}}:{{tagName}}"
- "duke/app:latest"
# A list of build arguments.
#
buildArgs:
- "--pull"
# Selects a Dockerfile template.
# If `true` (default) then the Dockerfile will use the local distribution files.
# If `false` then the Dockerfile expects the artifact to be downloaded from an URL.
#
useLocalArtifact: true
# Dockerfile commands to run before the assembly.
#
preCommands:
- "RUN apt-get update -y"
- "RUN apt-get install unzip"
# Dockerfile commands to run after the assembly, before ENTRYPOINT.
#
postCommands:
- "VOLUME /workspace"
# A map of Docker labels.
#
labels:
foo: bar
# Configure multi-arch image support.
#
buildx:
# Enable buildx support.
# Default is `false`.
#
enabled: true
# Creates a builder before creating the container image.
# Default is `true`.
#
createBuilder: true
# Configure the buildx builder.
# Defaults to `['--name', 'jreleaser', '--driver', 'docker-container', '--bootstrap', '--use']`.
#
createBuilderFlags:
- '--name'
- 'jreleaser'
- '--bootstrap'
- '--use'
# Configure platforms to be used.
#
platforms:
- 'linux/amd64'
- 'linux/arm64'
# A list of docker registries where images will be published.
#
registries:
# The name of the registry. Must be unique.
# Use `DEFAULT` to match the default registry
# provided by the Docker daemon.
#
- serverName: myRegistry
# The address of the docker registry.
# if `serverName != DEFAULT`.
server: https://myregistry.com
# Expect login/lougout to be carried out by external means.
# Defaults to `false`.
#
externalLogin: false
# The user that can publish images.
# Defaults to the same username as the release repository.
#
username: duke
# Password for login into the registry
#
password: __USE_ENVIRONMENT_VARIABLE__
# The name of the repository
# Defaults to the same owner as the release repository.
#
repositoryName: duke
#
[packagers.docker]
# Enables or disables Docker.
# Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
# Defaults to `NEVER`.
#
active = "ALWAYS"
# Let the release continue if the packager fails.
# Defaults to `false`.
#
continueOnError = true
# Custom download URL.
#
downloadUrl = "https://my.server.com/{{projectName}}/{{tagName}}/{{artifactFile}}"
# Additional properties used when evaluating templates.
#
extraProperties.foo = "bar"
# Key will be capitalized and prefixed with `docker`, i.e, `dockerFoo`.
# Directory with file templates used to prepare the Docker distribution.
# Defaults to `src/jreleaser/distributions/#{distribution.name}/docker`.
# If specified, path must exist.
#
templateDirectory = "path/to/docker/templates"
# List of template files to be skipped.
# Value may be an exact match or a regex.
#
skipTemplates = [ "README.md.tpl" ]
# Git author used to commit to the repository.
# Name used when authoring commits.
# Defaults to `jreleaserbot`.
#
commitAuthor.name = "jreleaserbot"
# E-mail used when authoring commits.
# Defaults to `jreleaser@kordamp.org`.
#
commitAuthor.email = "jreleaser@kordamp.org"
# Git repository to push the Dockerfile to.
# Defaults are shown.
# Enables or disables the repository.
# Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
# Defaults to `RELEASE`.
#
repository.active = "ALWAYS"
# Stores files in a folder matching the image's version/tag.
# Defaults to `false`.
#
repository.versionedSubfolders = true
# The owner of the repository.
# Defaults to the same owner as the release repository.
#
repository.owner = "duke"
# The name of the repository.
# Defaults to `app-docker`.
#
repository.name = "app-docker"
# The tag associated with the Dockerfile.
# If left unspecified, will use `{{tagName}}`.
#
repository.tagName = "{{distributionName}}-{{tagName}}"
# The target branch to pull from.
# Defaults to the branch pointed by HEAD.
#
repository.branch = "HEAD"
# The target branch to push to.
# Defaults to the branch pointed by `#{branch}`.
#
repository.branchPush = "{{projectName}}-{{tagName}}"
# Username used for authoring commits.
# Must have write access to the repository.
# Defaults to the same username as the release repository.
#
repository.username = "duke"
# Password or OAuth token with write access to the repository.
#
repository.token = "__USE_ENVIRONMENT_VARIABLE__"
# Message when committing to the repository.
# If left unspecified, `{{distributionName}} {{tagName}}` will be used.
#
repository.commitMessage = "{{distributionName}} {{tagName}}"
# Additional properties used when evaluating templates.
#
repository.extraProperties.foo = "bar"
# Key will be capitalized and prefixed with `repository`, i.e, `repositoryFoo`.
# The base Docker image to use.
#
baseImage = "alpine:latest"
# A list of image names.
# If unspecified, a single image `{{repoOwner}}/{{distributionName}}:{{tagName}}`
# will be created.
#
imageNames = [
"{{repoOwner}}/{{distributionName}}:{{tagName}}",
"duke/app:latest"]
# A list of build arguments.
#
buildArgs = ["--pull"]
# Selects a Dockerfile template.
# If `true` (default) then the Dockerfile will use the local distribution files.
# If `false` then the Dockerfile expects the artifact to be downloaded from an URL.
#
useLocalArtifact = true
# Dockerfile commands to run before the assembly.
#
preCommands = [
"RUN apt-get update -y",
"RUN apt-get install unzip"]
# Dockerfile commands to run after the assembly, before ENTRYPOINT.
#
postCommands = ["VOLUME /workspace"]
# A map of Docker labels.
#
labels.foo = "bar"
# Configure multi-arch image support.
#
# Enable buildx support.
# Default is `false`.
#
buildx.enabled = true
# Creates a builder before creating the container image.
# Default is `true`.
#
buildx.createBuilder = true
# Configure the buildx builder.
# Defaults to `['--name', 'jreleaser', '--driver', 'docker-container', '--bootstrap', '--use']`.
#
buildx.createBuilderFlags = ["--name", "jreleaser", "--driver", "docker-container", "--bootstrap", "--use"]
# Configure platforms to be used.
#
buildx.platforms = ["linux/amd64", "linux/arm64"]
# A list of docker registries where images will be published.
#
[[packagers.docker.registries]]
# The name of the registry. Must be unique.
# Use `DEFAULT` to match the default registry
# provided by the Docker daemon.
#
serverName = "myRegistry"
# The address of the docker registry.
# if `serverName != DEFAULT`.
server = "https://myregistry.com"
# Expect login/lougout to be carried out by external means.
# Defaults to `false`.
#
externalLogin = false
# The user that can publish images.
# Defaults to the same username as the release repository.
#
username = "duke"
# Password for login into the registry
#
password = "__USE_ENVIRONMENT_VARIABLE__"
# The name of the repository
# Defaults to the same owner as the release repository.
#
repositoryName = "duke"
{
//
"packagers": {
//
"docker": {
// Enables or disables Docker.
// Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
// Defaults to `NEVER`.
//
"active": "ALWAYS",
// Let the release continue if the packager fails.
// Defaults to `false`.
//
"continueOnError": true,
// Custom download URL.
//
"downloadUrl": "https://my.server.com/{{projectName}}/{{tagName}}/{{artifactFile}}",
// Additional properties used when evaluating templates.
//
"extraProperties": {
// Key will be capitalized and prefixed with `docker`, i.e, `dockerFoo`.
"foo": "bar"
},
// Directory with file templates used to prepare the Docker distribution.
// Defaults to `src/jreleaser/distributions/#{distribution.name}/docker`.
// If specified, path must exist.
//
"templateDirectory": "path/to/docker/templates",
// List of template files to be skipped.
// Value may be an exact match or a regex.
//
"skipTemplates": [
"README.md.tpl"
],
// Git author used to commit to the repository.
//
"commitAuthor": {
// Name used when authoring commits.
// Defaults to `jreleaserbot`.
//
"name": "jreleaserbot",
// E-mail used when authoring commits.
// Defaults to `jreleaser@kordamp.org`.
//
"email": "jreleaser@kordamp.org"
},
// Git repository to push the Dockerfile to.
// Defaults are shown.
//
"repository": {
// Enables or disables the repository.
// Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
// Defaults to `RELEASE`.
//
"active": "ALWAYS",
// Stores files in a folder matching the image's version/tag.
// Defaults to `false`.
//
"versionedSubfolders": true,
// The owner of the repository.
// Defaults to the same owner as the release repository.
//
"owner": "duke",
// The name of the repository.
// Defaults to `app-docker`.
//
"name": "app-docker",
// The tag associated with the Dockerfile.
// If left unspecified, will use `{{tagName}}`.
//
"tagName": "{{distributionName}}-{{tagName}}",
// The target branch to pull from.
// Defaults to the branch pointed by HEAD.
//
"branch": "HEAD",
// The target branch to push to.
// Defaults to the branch pointed by `#{branch}`.
//
"branchPush": "{{projectName}}-{{tagName}}",
// Username used for authoring commits.
// Must have write access to the repository.
// Defaults to the same username as the release repository.
//
"username": "duke",
// Password or OAuth token with write access to the repository.
//
"token": "__USE_ENVIRONMENT_VARIABLE__",
// Message when committing to the repository.
// If left unspecified, `{{distributionName}} {{tagName}}` will be used.
//
"commitMessage": "{{distributionName}} {{tagName}}",
// Additional properties used when evaluating templates.
//
"extraProperties": {
// Key will be capitalized and prefixed with `repository`, i.e, `repositoryFoo`.
"foo": "bar"
}
},
// The base Docker image to use.
//
"baseImage": "alpine:latest",
// A list of image names.
// If unspecified, a single image `{{repoOwner}}/{{distributionName}}:{{tagName}}`
// will be created.
//
"imageNames": [
"{{repoOwner}}/{{distributionName}}:{{tagName}}",
"duke/app:latest"
],
// A list of build arguments.
//
"buildArgs": [
"--pull"
],
// Selects a Dockerfile template.
// If `true` (default) then the Dockerfile will use the local distribution files.
// If `false` then the Dockerfile expects the artifact to be downloaded from an URL.
//
"useLocalArtifact": true,
// Dockerfile commands to run before the assembly.
//
"preCommands": [
"RUN apt-get update -y",
"RUN apt-get install unzip"
],
// Dockerfile commands to run after the assembly, before ENTRYPOINT.
//
"postCommands": [
"VOLUME /workspace"
],
// A map of Docker labels.
//
"labels": {
"foo": "bar"
},
// Configure multi-arch image support.
//
"buildx": {
// Enable buildx support.
// Default is `false`.
//
"enabled": true,
// Creates a builder before creating the container image.
// Default is `true`.
//
"createBuilder": true,
// Configure the buildx builder.
// Defaults to `['--name', 'jreleaser', '--driver', 'docker-container', '--bootstrap', '--use']`.
//
"createBuilderFlags": [
"--name",
"jreleaser",
"--bootstrap",
"--use"
],
// Configure platforms to be used.
//
"platforms": [
"linux/amd64",
"linux/arm64"
]
},
// A list of docker registries where images will be published.
//
"registries": [
{
// The name of the registry. Must be unique.
// Use `DEFAULT` to match the default registry
// provided by the Docker daemon.
//
"serverName": "myRegistry",
// The address of the docker registry.
// if `serverName != DEFAULT`.
"server": "https://myregistry.com",
// Expect login/lougout to be carried out by external means.
// Defaults to `false`.
//
"externalLogin": false,
// The user that can publish images.
// Defaults to the same username as the release repository.
//
"username": "duke",
// Password for login into the registry
//
"password": "__USE_ENVIRONMENT_VARIABLE__",
// The name of the repository
// Defaults to the same owner as the release repository.
//
"repositoryName": "duke"
}
]
}
}
}
<jreleaser>
<!--
-->
<packagers>
<!--
-->
<docker>
<!--
Enables or disables Docker.
Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
Defaults to `NEVER`.
-->
<active>ALWAYS</active>
<!--
Let the release continue if the packager fails.
Defaults to `false`.
-->
<continueOnError>true</continueOnError>
<!--
Custom download URL.
-->
<downloadUrl>https://my.server.com/{{projectName}}/{{tagName}}/{{artifactFile}}</downloadUrl>
<!--
Additional properties used when evaluating templates.
-->
<extraProperties>
<!--
Key will be capitalized and prefixed with `docker`, i.e, `dockerFoo`.
-->
<foo>bar</foo>
</extraProperties>
<!--
Directory with file templates used to prepare the Docker distribution.
Defaults to `src/jreleaser/distributions/#{distribution.name}/docker`.
If specified, path must exist.
-->
<templateDirectory>path/to/docker/templates</templateDirectory>
<!--
List of template files to be skipped.
Value may be an exact match or a regex.
-->
<skipTemplates>
<skipTemplate>README.md.tpl</skipTemplate>
</skipTemplates>
<!--
Git author used to commit to the repository.
-->
<commitAuthor>
<!--
Name used when authoring commits.
Defaults to `jreleaserbot`.
-->
<name>jreleaserbot</name>
<!--
E-mail used when authoring commits.
Defaults to `jreleaser@kordamp.org`.
-->
<email>jreleaser@kordamp.org</email>
</commitAuthor>
<!--
Git repository to push the Dockerfile to.
Defaults are shown.
-->
<repository>
<!--
Enables or disables the repository.
Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
Defaults to `RELEASE`.
-->
<active>ALWAYS</active>
<!--
Stores files in a folder matching the image's version/tag.
Defaults to `false`.
-->
<versionedSubfolders>true</versionedSubfolders>
<!--
The owner of the repository.
Defaults to the same owner as the release repository.
-->
<owner>duke</owner>
<!--
The name of the repository.
Defaults to `app-docker`.
-->
<name>app-docker</name>
<!--
The tag associated with the Dockerfile.
If left unspecified, will use `{{tagName}}`.
-->
<tagName>{{distributionName}}-{{tagName}}</tagName>
<!--
The target branch to pull from.
Defaults to the branch pointed by HEAD.
-->
<branch>HEAD</branch>
<!--
The target branch to push to.
Defaults to the branch pointed by `#{branch}`.
-->
<branchPush>{{projectName}}-{{tagName}}</branchPush>
<!--
Username used for authoring commits.
Must have write access to the repository.
Defaults to the same username as the release repository.
-->
<username>duke</username>
<!--
Password or OAuth token with write access to the repository.
-->
<token>__USE_ENVIRONMENT_VARIABLE__</token>
<!--
Message when committing to the repository.
If left unspecified, `{{distributionName}} {{tagName}}` will be used.
-->
<commitMessage>{{distributionName}} {{tagName}}</commitMessage>
<!--
Additional properties used when evaluating templates.
-->
<extraProperties>
<!--
Key will be capitalized and prefixed with `repository`, i.e, `repositoryFoo`.
-->
<foo>bar</foo>
</extraProperties>
</repository>
<!--
The base Docker image to use.
-->
<baseImage>alpine:latest</baseImage>
<!--
A list of image names.
If unspecified, a single image `{{repoOwner}}/{{distributionName}}:{{tagName}}`
will be created.
-->
<imageNames>
<imageName>{{repoOwner}}/{{distributionName}}:{{tagName}}</imageName>
<imageName>duke/app:latest</imageName>
</imageNames>
<!--
A list of build arguments.
-->
<buildArgs>
<buildArg>--pull</buildArg>
</buildArgs>
<!--
Selects a Dockerfile template.
If `true` (default) then the Dockerfile will use the local distribution files.
If `false` then the Dockerfile expects the artifact to be downloaded from an URL.
-->
<useLocalArtifact>true</useLocalArtifact>
<!--
Dockerfile commands to run before the assembly.
-->
<preCommands>
<preCommand>RUN apt-get update -y</preCommand>
<preCommand>RUN apt-get install unzip</preCommand>
</preCommands>
<!--
Dockerfile commands to run after the assembly, before ENTRYPOINT.
-->
<postCommands>
<postCommand>VOLUME /workspace</postCommand>
</postCommands>
<!--
A map of Docker labels.
-->
<labels>
<foo>bar</foo>
</labels>
<!--
Configure multi-arch image support.
-->
<buildx>
<!--
Enable buildx support.
Default is `false`.
-->
<enabled>true</enabled>
<!--
Creates a builder before creating the container image.
Default is `true`.
-->
<createBuilder>true</createBuilder>
<!--
Configure the buildx builder.
Defaults to `['--name', 'jreleaser', '--driver', 'docker-container', '--bootstrap', '--use']`.
-->
<createBuilderFlags>
<createBuilderFlag>--name</createBuilderFlag>
<createBuilderFlag>jreleaser</createBuilderFlag>
<createBuilderFlag>--bootstrap</createBuilderFlag>
<createBuilderFlag>--use</createBuilderFlag>
</createBuilderFlags>
<!--
Configure platforms to be used.
-->
<platforms>
<platform>linux/amd64</platform>
<platform>linux/arm64</platform>
</platforms>
</buildx>
<!--
A list of docker registries where images will be published.
-->
<registries>
<registry>
<!--
The name of the registry. Must be unique.
Use `DEFAULT` to match the default registry
provided by the Docker daemon.
-->
<serverName>myRegistry</serverName>
<!--
The address of the docker registry.
if `serverName != DEFAULT`.
-->
<server>pass[https: myregistry.com]</server>
<!--
Expect login/lougout to be carried out by external means.
Defaults to `false`.
-->
<externalLogin>false</externalLogin>
<!--
The user that can publish images.
Defaults to the same username as the release repository.
-->
<username>duke</username>
<!--
Password for login into the registry
-->
<password>__USE_ENVIRONMENT_VARIABLE__</password>
<!--
The name of the repository
Defaults to the same owner as the release repository.
-->
<repositoryName>duke</repositoryName>
</registry>
</registries>
</docker>
</packagers>
</jreleaser>
jreleaser {
//
packagers {
//
docker {
// Enables or disables Docker.
// Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
// Defaults to `NEVER`.
//
active = 'ALWAYS'
// Let the release continue if the packager fails.
// Defaults to `false`.
//
continueOnError = true
// Custom download URL.
//
downloadUrl = 'https://my.server.com/{{projectName}}/{{tagName}}/{{artifactFile}}'
// Additional properties used when evaluating templates.
// Key will be capitalized and prefixed with `docker`, i.e, `dockerFoo`.
//
extraProperties.put('foo', 'bar')
// Directory with file templates used to prepare the Docker distribution.
// Defaults to `src/jreleaser/distributions/#{distribution.name}/docker`.
// If specified, path must exist.
//
templateDirectory = 'path/to/docker/templates'
// List of template files to be skipped.
// Value may be an exact match or a regex.
//
skipTemplate('README.md.tpl')
// Git author used to commit to the repository.
//
commitAuthor {
// Name used when authoring commits.
// Defaults to `jreleaserbot`.
//
name = 'jreleaserbot'
// E-mail used when authoring commits.
// Defaults to `jreleaser@kordamp.org`.
//
email = 'jreleaser@kordamp.org'
}
// Git repository to push the Dockerfile to.
// Defaults are shown.
//
repository {
// Enables or disables the repository.
// Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
// Defaults to `RELEASE`.
//
active = 'ALWAYS'
// Stores files in a folder matching the image's version/tag.
// Defaults to `false`.
//
versionedSubfolders = true
// The owner of the repository.
// Defaults to the same owner as the release repository.
//
repoOwner = 'duke'
// The name of the repository.
// Defaults to `app-docker`.
//
name = 'app-docker'
// The tag associated with the Dockerfile.
// If left unspecified, will use `{{tagName}}`.
//
tagName = '{{distributionName}}-{{tagName}}'
// The target branch to pull from.
// Defaults to the branch pointed by HEAD.
//
branch = 'HEAD'
// The target branch to push to.
// Defaults to the branch pointed by `#{branch}`.
//
branchPush = '{{projectName}}-{{tagName}}'
// Username used for authoring commits.
// Must have write access to the repository.
// Defaults to the same username as the release repository.
//
username = 'duke'
// Password or OAuth token with write access to the repository.
//
token = '__USE_ENVIRONMENT_VARIABLE__'
// Message when committing to the repository.
// If left unspecified, `{{distributionName}} {{tagName}}` will be used.
//
commitMessage = '{{distributionName}} {{tagName}}'
// Additional properties used when evaluating templates.
// Key will be capitalized and prefixed with `repository`, i.e, `repositoryFoo`.
//
extraProperties.put('foo', 'bar')
}
// The base Docker image to use.
//
baseImage = 'alpine:latest'
// A list of image names.
// If unspecified, a single image `{{repoOwner}}/{{distributionName}}:{{tagName}}`
// will be created.
//
imageName('{{repoOwner}}/{{distributionName}}:{{tagName}}')
imageName('duke/app:latest')
// A list of build arguments.
//
buildArg('--pull')
// Selects a Dockerfile template.
// If `true` (default) then the Dockerfile will use the local distribution files.
// If `false` then the Dockerfile expects the artifact to be downloaded from an URL.
//
useLocalArtifact = true
// Dockerfile commands to run before the assembly.
//
preCommand('RUN apt-get update -y')
preCommand('RUN apt-get install unzip')
// Dockerfile commands to run after the assembly, before ENTRYPOINT.
//
postCommand('VOLUME /workspace')
// A map of Docker labels.
// The key `openjdk@#{java.version}` will be added automatically if not defined.
//
label('foo', 'bar')
// Configure multi-arch image support.
//
buildx {
// Enable buildx support.
// Default is `false`.
//
enabled = true
// Creates a builder before creating the container image.
// Default is `true`.
//
createBuilder = true
// Configure the buildx builder.
// Defaults to `['--name', 'jreleaser', '--driver', 'docker-container', '--bootstrap', '--use']`.
//
createBuilderFlag('--name')
createBuilderFlag('jreleaser')
createBuilderFlag('--bootstrap')
createBuilderFlag('--use')
// Configure platforms to be used.
//
platform('linux/amd64')
platform('linux/arm64')
}
// A list of docker registries where images will be published.
//
registries {
// The name of the registry. Must be unique.
// Use `DEFAULT` to match the default registry
// provided by the Docker daemon.
//
myRegistry {
// The address of the docker registry.
// if `serverName != DEFAULT`.
server = 'https://myregistry.com'
// Expect login/lougout to be carried out by external means.
// Defaults to `false`.
//
externalLogin = false
// The user that can publish images.
// Defaults to the same username as the release repository.
//
username = 'duke'
// Password for login into the registry
//
password = '__USE_ENVIRONMENT_VARIABLE__'
// The name of the repository
// Defaults to the same owner as the release repository.
//
repositoryName = 'duke'
}
}
}
}
}
Environment
When not explicitly set, the value of the following properties may be resolved from an environment variable or a system property as shown in the table. The system property takes precedence over the environment variable.
Inside packagers
section
System Property | Environment Variable |
---|---|
active |
|
jreleaser.packagers.docker.active |
JRELEASER_PACKAGERS_DOCKER_ACTIVE |
Inside distributions
section
System Property | Environment Variable |
---|---|
active |
|
jreleaser.distributions.${name}.docker.active |
JRELEASER_DISTRIBUTIONS_${name}_DOCKER_ACTIVE |
registry.username |
|
jreleaser.distributions.${name}.docker.${serverName}.username |
JRELEASER_DISTRIBUTIONS_${name}_DOCKER_${serverName}_USERNAME |
registry.password |
|
jreleaser.distributions.${name}.docker.${serverName}.password |
JRELEASER_DISTRIBUTIONS_${name}_DOCKER_${serverName}_PASSWORD |
repository.active |
|
jreleaser.distributions.${name}.docker.repository.active |
JRELEASER_DISTRIBUTIONS_${name}_DOCKER_REPOSITORY_ACTIVE |
repository.username |
|
jreleaser.distributions.${name}.docker.repository.username |
JRELEASER_DISTRIBUTIONS_${name}_DOCKER_REPOSITORY_USERNAME |
repository.token |
|
jreleaser.distributions.${name}.docker.repository.token |
JRELEASER_DISTRIBUTIONS_${name}_DOCKER_REPOSITORY_TOKEN |
repository.branch |
|
jreleaser.distributions.${name}.docker.repository.branch |
JRELEASER_DISTRIBUTIONS_${name}_DOCKER_REPOSITORY_BRANCH |
repository.branchPush |
|
jreleaser.distributions.${name}.docker.repository.branch.push |
JRELEASER_DISTRIBUTIONS_${name}_DOCKER_REPOSITORY_BRANCH_PUSH |
Substitute ${name} for the value of the named instance. |
Space (' '), underscore (_
), and dash (-
) will be replaced by dot (.
) to separate tokens in the System property.
Space (' '), dash (-
), and dot (.
) will be replaced by underscore (_
) to separate tokens in the environment variable,
such that:
${name} | System Property | Environment Variable |
---|---|---|
foobar |
|
|
fooBar |
|
|
foo bar |
|
|
foo-bar |
|
|
foo_bar |
|
|
foo.bar |
|
|
Tokens
The repository token environment variable must match with the chosen Release service. |
On GitHub, you can’t use the default
|
DownloadURL
JReleaser follows these rules to find the download URL to use for a given artifact:
-
if
artifact.extraProperties.dockerDownloadUrl
exists, use it. -
if
artifact.extraProperties.downloadUrl
exists, use it. -
if explicit
downloadUrl
is set ondocker
, use it. -
if
distribution.extraProperties.dockerDownloadUrl
exists, use it. -
if
distribution.extraProperties.downloadUrl
exists, use it. -
if
releaser.${release}.skipRelease
isfalse
then use the releaser’sdownloadUrl
. -
if
releaser.${release}.skipRelease
istrue
then look for a matching uploader given an extraProperty nameddownloadUrlFrom
onartifact
,distribution, `docker
(in that order). The value must be<uploaderType>:<uploaderName>
such as "artifactory:app" or "s3:uploads". -
fail if no suitable URL is found.
With no extra configuration from your side rule 6. will be chosen which is the suitable default that most projects need.
Example
Assuming the current version is 1.2.3
, and a distribution named app
, the above configuration will generate
a Dockerfile like the following one:
FROM azul/zulu-openjdk-alpine:8-jre
LABEL "org.opencontainers.image.title"="app"
LABEL "org.opencontainers.image.description"="Awesome App"
LABEL "org.opencontainers.image.url"="https://acme.com/app"
LABEL "org.opencontainers.image.licenses"="Apache-2.0"
LABEL "org.opencontainers.image.version"="1.2.3"
LABEL "org.opencontainers.image.revision"="de0266d314b91dd201765616e207d0a8706d0b99"
COPY assembly/* /
RUN unzip app-1.2.3.zip && \
rm app-1.2.3.zip && \
chmod +x app-1.2.3/bin/app
ENV PATH="${PATH}:/app-1.2.3/bin"
ENTRYPOINT ["/app-1.2.3/bin/app"]
Base Images
Different values for the default base image will be used depending on the distribution type:
-
azul/zulu-openjdk-alpine:#{distribution.java.version}-jre
for JAVA_BINARY and SINGLE_JAR distributions. -
ubuntu:latest
for JLINK distributions when the artifact has alinux
platform. -
alpine:latest
for JLINK distributions when the artifact has alinux_musl
platform. -
scratch
for NATIVE_IMAGE distributions.
Default Labels
JReleaser will add the following labels if they are not explicitly defined:
-
org.opencontainers.image.title = {{distributionName}}
-
org.opencontainers.image.description = {{projectDescription}}
-
org.opencontainers.image.url = {{projectLinkHomepage}}
-
org.opencontainers.image.licenses = {{projectLicense}}
-
org.opencontainers.image.version = {{projectVersion}}
-
org.opencontainers.image.revision = {{commitFullHash}}
You may use any Name Templates as part of the label value.
Generic Image Names
Some users might want to keep their image name as generic as possible. That can be accomplished simply by adding
a template to the imageNames
field.
project:
name: app
packagers:
docker:
active: ALWAYS
imageNames:
- "myuser/{{projectName}}"
[project]
name = "app"
[packagers.docker]
active = "ALWAYS"
imageNames = ["myuser/{{projectName}}"]
{
"project": {
"name": "app"
},
"packagers": {
"docker": {
"active": "ALWAYS",
"imageNames": [
"myuser/{{projectName}}"
]
}
}
}
<!-- project.artifactId = app -->
<jreleaser>
<packagers>
<docker>
<active>ALWAYS</active>
<imageNames>
<imageName>myuser/{{projectName}}</imageName>
</imageNames>
</docker>
</packagers>
</jreleaser>
// project.name = app
jreleaser {
packagers {
docker {
active = 'ALWAYS'
imageName('myuser/{{projectName}}')
}
}
}
This will build the following images:
-
myuser/app
Prerelease Image Names
A different set of images names will be automatically configured when the project is snapshot, to avoid possible clashes with production images.
JReleaser will look for the first image name that ends with :{{tagName}}
and discard the rest.
It will use {{repoOwner}}/{{distributionName}}:{{tagName}}
if no matching image name is found.
Keeping docker images updated for current major
Some users might want to when version to push docker tags :v1
, :v1.6
, :v1.6.4
and :latest
when v1.6.4
(for example) is built. That can be accomplished by using multiple image names:
project:
name: app
packagers:
docker:
active: ALWAYS
imageNames:
- "myuser/myimage:{{tagName}}"
- "myuser/myimage:v{{projectVersionMajor}}"
- "myuser/myimage:v{{projectVersionMajor}}.{{projectVersionMinor}}"
- "myuser/myimage:latest"
[project]
name = "app"
[packagers.docker]
active = "ALWAYS"
imageNames = [
"myuser/myimage:{{tagName}}",
"myuser/myimage:v{{projectVersionMajor}}",
"myuser/myimage:v{{projectVersionMajor}}.{{projectVersionMinor}}",
"myuser/myimage:latest"]
{
"project": {
"name": "app"
},
"packagers": {
"docker": {
"active": "ALWAYS",
"imageNames": [
"myuser/myimage:{{tagName}}",
"myuser/myimage:v{{projectVersionMajor}}",
"myuser/myimage:v{{projectVersionMajor}}.{{projectVersionMinor}}",
"myuser/myimage:latest"
]
}
}
}
<!-- project.artifactId = app -->
<jreleaser>
<packagers>
<docker>
<active>ALWAYS</active>
<imageNames>
<imageName>myuser/myimage:{{tagName}}</imageName>
<imageName>myuser/myimage:v{{projectVersionMajor}}</imageName>
<imageName>myuser/myimage:v{{projectVersionMajor}}.{{projectVersionMinor}}</imageName>
<imageName>myuser/myimage:latest</imageName>
</imageNames>
</docker>
</packagers>
</jreleaser>
// project.name = app
jreleaser {
packagers {
docker {
active = 'ALWAYS'
imageName('myuser/myimage:{{tagName}}')
imageName('myuser/myimage:v{{projectVersionMajor}}')
imageName('myuser/myimage:v{{projectVersionMajor}}.{{projectVersionMinor}}')
imageName('myuser/myimage:latest')
}
}
}
This will build the following images:
-
myuser/myimage:v1.6.4
-
myuser/myimage:v1
-
myuser/myimage:v1.6
-
myuser/myimage:latest
Additional Files
Any files placed inside #{docker.templateDirectory}/assembly
will be copied into the container at the root.
Multiple Dockerfile per Distribution
The previous sections explain how a single or multiple Docker images may be created for a single distribution using the
same Dockerfile. However, should you need to use several Dockerfiles with the same distribution then just add a specs
section and configure each spec
to your liking. Each spec
takes the same arguments as the docker
section plus an
extra element named matchers
that determines which distribution artifact should be used with that particular spec
.
Matchers are key/value pairs that can match the artifact’s platform
property and any of its extraProperties
.
This feature is useful when paired with an assembled Jlink distribution that defines more than one artifact that may be packaged with Docker. Here’s for example how JReleaser handles the case of generating cross-platform Java Runtimes with Jlink; there are 2 artifacts (the linux variants) that may be distributed with Docker, each one requiring different settings:
environment:
properties:
jdkPathPrefix: 'apps/jreleaser/build/jdks/zulu11.48.21-ca-jdk11.0.11'
assemble:
jlink:
jreleaser-standalone:
active: ALWAYS
java:
version: 11
mainClass: 'org.jreleaser.cli.Main'
imageName: '{{distributionName}}-{{projectEffectiveVersion}}'
executable: 'jreleaser'
moduleNames:
- java.base
- java.desktop
- java.management
- java.naming
- java.rmi
- java.security.jgss
- java.sql
targetJdks:
- path: '{{jdkPathPrefix}}-macosx_x64/zulu-11.jdk/Contents/Home'
platform: 'osx'
- path: '{{jdkPathPrefix}}-linux_x64'
platform: 'linux'
- path: '{{jdkPathPrefix}}-linux_musl_x64'
platform: 'linux_musl'
- path: '{{jdkPathPrefix}}-win_x64'
platform: 'windows'
mainJar:
path: 'apps/jreleaser/build/libs/jreleaser-{{projectVersion}}.jar'
jars:
- directory: 'apps/jreleaser/build/dependencies/flat'
include: '*.jar'
distributions:
# name must match!
jreleaser-standalone:
docker:
# inherited by specs
active: ALWAYS
# inherited by specs
registries:
- serverName: DEFAULT
# inherited by specs
labels:
'org.opencontainers.image.title': 'jreleaser'
# inherited by specs
postCommands:
- 'VOLUME /workspace'
# configure 2 specs
specs:
slim:
imageNames:
- 'jreleaser/jreleaser-{{dockerSpecName}}:{{tagName}}'
- 'jreleaser/jreleaser-{{dockerSpecName}}:latest'
# match by platform
matchers:
platform: 'linux'
preCommands:
- 'RUN apt-get update -y'
- 'RUN apt-get install unzip'
alpine:
imageNames:
- 'jreleaser/jreleaser-{{dockerSpecName}}:{{tagName}}'
- 'jreleaser/jreleaser-{{dockerSpecName}}:latest'
# match by platform
matchers:
platform: 'linux_musl'
preCommands:
- 'RUN apk add unzip'
This generates two different images:
-
jreleaser/jreleaser-slim:<tag>
withubuntu:latest
as base image. Packagesjreleaser-standalone-<version>-linux.zip
because of the matching platform. -
jreleaser/jreleaser-alpine:<tag>
withalpine:latest
as base image. Packagesjreleaser-standalone-<version>-linux_musl.zip
because of the matching platform.
External Login
In some cases it may recommended to perform login/lougout operations outside of JReleaser, for example using the
https://github.com/docker/login-action when running inside GitHub actions. When this is the case set the value of
externalLogin
to true
for the given registry or registries.
Templates
The default location for templates is:
src/jreleaser/distributions/<distribution-name>/docker
The default location for spec templates is:
src/jreleaser/distributions/<distribution-name>/docker/<spec>
You may place common files to all specs at
src/jreleaser/distributions/<distribution-name>/docker/ROOT
The following list shows the filenames that may be used to override default templates:
-
Dockerfile.tpl
-
Dockerfile-remote.tpl
Any additional files found in the template directories will be copied as is unless their filename ends with .tpl
in
which case Name Templates substitution will take place.
Templates may be initialized using the template
command
Skip Templates
You may skip any template files by defining a set of skip rules in the skipTemplates
property. For example, you may use
any of these expressions to skip a template named README.md.tpl
:
-
README.md.tpl
: matches the full template name -
README.md
: matches the transformed template name -
README.*
: matches using a regex
Skip Artifacts
If there is more than one matching artifact in a given distribution you may add a skipDocker
extra property
to the target artifact to mark it as skipped for packaging with docker.
Skip License
If there’s a matching LICENSE
file available at the root of the project it will be copied to the repository by default.
You may set an extra property named skipLicenseFile
on docker to skip this behavior.
Repository
The repository
section allows setting extra properties that may be used to provide additional hints when interacting
with the git repository that holds packager files.
GitLab
Define a projectIdentifier
property to directly locate the project associated with the repository, such as
packagers:
docker:
repository:
extraProperties:
projectIdentifier: 12345678
[packagers.docker]
repository.extraProperties.projectIdentifier = "12345678"
{
"packagers": {
"docker": {
"repository": {
"extraProperties": {
"projectIdentifier": "12345678"
}
}
}
}
}
<jreleaser>
<packagers>
<docker>
<repository>
<extraProperties>
<projectIdentifier>12345678</projectIdentifier>
</extraProperties>
</repository>
</docker>
</packagers>
</jreleaser>
jreleaser {
packagers {
docker {
repository {
extraProperties.put("projectIdentifier", "12345678")
}
}
}
}