Document Docker changes

This commit is contained in:
Andres Almiray
2021-05-11 02:27:11 +02:00
parent 9fe500ebaa
commit 6dd3610159
8 changed files with 249 additions and 77 deletions

View File

@@ -169,10 +169,13 @@ working directory at the `/workspace` volume, for example assuming the current d
[source]
----
$ docker run -it --rm -v `(pwd)`:/workspace jreleaser/jreleaser-slim:<tag> <command> [<args>]
$ docker run -it --rm -v `(pwd)`:/workspace \
jreleaser/<image>:<tag> <command> [<args>]
----
NOTE: The `--basedir` argument will be automatically set to `--basedir=/workspace`.
Where image may be `jreleaser-slim`, `jreleaser-alpine`.
NOTE: The `jreleaser` command will be automatically executed inside `/workspace`.
You may also need to map environment variables to the container, such as `JRELEASER_PROJECT_VERSION`,
`JRELEASER_GITHUB_TOKEN`, or others depending on your setup. Refer to the xref:configuration:index.adoc[] pages.

View File

@@ -421,7 +421,7 @@ jreleaser {
// Used to determine packager templates.
// Supported values are = [JAVA_BINARY, SINGLE_JAR, JLINK, NATIVE_IMAGE].
// icon:exclamation-triangle[]
type = 'JAVA_BINARY'
distributionType = 'JAVA_BINARY'
// Name of the executable launcher.
// If left undefined, will use ${distribution.name}.

View File

@@ -876,6 +876,7 @@ The following names are related to xref:configuration:packagers/homedocker.adoc[
| Key | Description
| dockerBaseImage | the base Docker image
| dockerLabels | a list of formatted labels
| dockerSpecName | tha name of the current Docker spec
|===
Additionally, every key/value from `docker.extraProperties` is mapped with `docker` as key prefix and the capitalized

View File

@@ -36,7 +36,7 @@ packagers:
# The base Docker image to use.
# icon:dot-circle[] icon:file-alt[]
baseImage: "alpine:3.13.5"
baseImage: "alpine:latest"
# A list of image names.
# If unspecified, a single image `{{repoOwner}}/{{distributionName}}:{{tagName}}`
@@ -125,7 +125,7 @@ TOML::
# The base Docker image to use.
# icon:dot-circle[] icon:file-alt[]
baseImage = "alpine:3.13.5"
baseImage = "alpine:latest"
# A list of image names.
# If unspecified, a single image `{{repoOwner}}/{{distributionName}}:{{tagName}}`
@@ -212,7 +212,7 @@ JSON::
// The base Docker image to use.
// icon:dot-circle[] icon:file-alt[]
"baseImage": "alpine:3.13.5",
"baseImage": "alpine:latest",
// A list of image names.
// If unspecified, a single image `{{repoOwner}}/{{distributionName}}:{{tagName}}`
@@ -326,7 +326,7 @@ Maven::
The base Docker image to use.
icon:dot-circle[] icon:file-alt[]
-->
<baseImage>alpine:3.13.5</baseImage>
<baseImage>alpine:latest</baseImage>
<!--
A list of image names.
@@ -455,7 +455,7 @@ jreleaser {
// The base Docker image to use.
// icon:dot-circle[] icon:file-alt[]
baseImage = 'alpine:3.13.5'
baseImage = 'alpine:latest'
// A list of image names.
// If unspecified, a single image `{{repoOwner}}/{{distributionName}}:{{tagName}}`
@@ -557,7 +557,7 @@ ENTRYPOINT ["/app-1.2.3/bin/app"]
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.
* `alpine:3.13.5` for JLINK distributions.
* `alpine:latest` for JLINK distributions.
* `scratch` for NATIVE_IMAGE distributions.
== Default Labels
@@ -787,3 +787,108 @@ This will build the following images:
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:
[tabs]
====
YAML::
+
[source,yaml]
[subs="+macros"]
----
environment:
properties:
jdkPathPrefix: 'apps/jreleaser/build/jdks/zulu11.48.21-ca-jdk11.0.11'
assemble:
jlinks:
jreleaser-standalone:
active: always
extraProperties:
sdkmanSkip: true
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': '{{repoOwner}}'
# inherited by specs
postCommands:
- 'VOLUME /workspace'
# configure 2 specs
specs:
slim:
imageNames:
- '{{repoOwner}}/{{repoOwner}}-{{dockerSpecName}}:{{tagName}}'
- '{{repoOwner}}/{{repoOwner}}-{{dockerSpecName}}:latest'
# match by platform
matchers:
platform: 'linux'
preCommands:
- 'RUN apt-get update -y'
- 'RUN apt-get install unzip'
alpine:
imageNames:
- '{{repoOwner}}/{{repoOwner}}-{{dockerSpecName}}:{{tagName}}'
- '{{repoOwner}}/{{repoOwner}}-{{dockerSpecName}}:latest'
# match by platform
matchers:
platform: 'linux_musl'
preCommands:
- 'RUN apk add unzip'
----
====
This generates two different images:
* `jreleaser/jreleaser-slim:<tag>` with `ubuntu:latest` as base image. Packages
`jreleaser-standalone-<version>-linux.zip` because of the matching platform.
* `jreleaser/jreleaser-alpine:<tag>` with `alpine:latest` as base image. Packages
`jreleaser-standalone-<version>-linux_musl.zip` because of the matching platform.

View File

@@ -47,3 +47,6 @@ release:
----
TIP: You may use `latest` to pull the latest stable release or `early-access` to pull the latest snapshot.
There is more than one jreleaser image available. Available images are listed xref:tools:jreleaser-docker.adoc[here].

View File

@@ -9,6 +9,11 @@ is used to create both release and snapshot releases:
[subs="verbatim"]
.jreleaser.yml
----
# Define properties we'll use later in this file
environment:
properties:
jdkPathPrefix: 'apps/jreleaser/build/jdks/zulu11.48.21-ca-jdk11.0.11'
# General information about this project
project:
name: jreleaser
@@ -85,7 +90,7 @@ announce:
sdkman:
active: release
# Configure a cross-platform Jlink assembly & distribution
# Configure a cross-platform Jlink assembly
assemble:
jlinks:
jreleaser-standalone:
@@ -94,8 +99,8 @@ assemble:
sdkmanSkip: true
java:
version: 11
mainClass: org.jreleaser.cli.Main
imageName: 'jreleaser-standalone-{{projectEffectiveVersion}}'
mainClass: 'org.jreleaser.cli.Main'
imageName: '{{distributionName}}-{{projectEffectiveVersion}}'
executable: 'jreleaser'
moduleNames:
- java.base
@@ -112,19 +117,21 @@ assemble:
- jdk.security.jgss
- org.openjsse
targetJdks:
- path: 'apps/jreleaser/build/jdks/zulu11.48.21-ca-jdk11.0.11-macosx_x64/zulu-11.jdk/Contents/Home'
platform: osx
- path: 'apps/jreleaser/build/jdks/zulu11.48.21-ca-jdk11.0.11-linux_x64'
platform: linux
- path: 'apps/jreleaser/build/jdks/zulu11.48.21-ca-jdk11.0.11-win_x64'
platform: windows
- 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'
# Configure 3 distributions
# Configure 4 distributions
distributions:
# Distribution 1 is of type JAVA_BINARY
jreleaser:
@@ -164,29 +171,50 @@ distributions:
- path: plugins/{{distributionName}}/build/distributions/{{distributionName}}-{{projectVersion}}.zip
transform: '{{distributionName}}/{{distributionName}}-{{projectEffectiveVersion}}.zip'
# Distribution 2 is of type SINGLE_JAR
# Distribution 3 is of type SINGLE_JAR
jreleaser-tool-provider:
type: SINGLE_JAR
executable: jreleaser
java:
# A different Java version is required to run this distribution
version: 11
docker:
# Always active
active: always
imageNames:
- '{{repoOwner}}/{{projectName}}-slim:{{tagName}}'
- '{{repoOwner}}/{{projectName}}-slim:latest'
postCommands:
- 'VOLUME /workspace'
registries:
# Will publish to hub.docker.com
- serverName: DEFAULT
username: jreleaser
artifacts:
# Transform the artifact name
- path: apps/jreleaser-tool-provider/build/libs/jreleaser-tool-provider-{{projectVersion}}.jar
transform: 'jreleaser-tool-provider/jreleaser-tool-provider-{{projectEffectiveVersion}}.jar'
- path: apps/{{distributionName}}/build/libs/{{distributionName}}-{{projectVersion}}.jar
transform: '{{distributionName}}/{{distributionName}}-{{projectEffectiveVersion}}.jar'
# Distribution 4 is of type JLINK
# Name matches the assembled Jlink distribution
jreleaser-standalone:
docker:
# inherited by specs
active: always
# inherited by specs
registries:
- serverName: DEFAULT
# inherited by specs
labels:
'org.opencontainers.image.title': '{{repoOwner}}'
# inherited by specs
postCommands:
- 'VOLUME /workspace'
# configure 2 specs
specs:
slim:
imageNames:
- '{{repoOwner}}/{{repoOwner}}-{{dockerSpecName}}:{{tagName}}'
- '{{repoOwner}}/{{repoOwner}}-{{dockerSpecName}}:latest'
# match by platform
matchers:
platform: 'linux'
preCommands:
- 'RUN apt-get update -y'
- 'RUN apt-get install unzip'
alpine:
imageNames:
- '{{repoOwner}}/{{repoOwner}}-{{dockerSpecName}}:{{tagName}}'
- '{{repoOwner}}/{{repoOwner}}-{{dockerSpecName}}:latest'
# match by platform
matchers:
platform: 'linux_musl'
preCommands:
- 'RUN apk add unzip'
files:
artifacts:

View File

@@ -2,7 +2,7 @@
Executes a JReleaser workflow as a command-line interface (CLI).
[source,bash]
[source]
----
$ jreleaser -h
Usage: jreleaser [-hV] [COMMAND]
@@ -90,7 +90,7 @@ The following commands are supported:
=== init
[source,bash]
[source]
----
$ jreleaser init -h
Usage: jreleaser init [-dhioqVw] [-b=<basedir>] [-f=<format>]
@@ -112,7 +112,7 @@ The file will be generated at `<basedir>` if specified, otherwise at the current
=== config
[source,bash]
[source]
----
$ jreleaser config -h
Usage: jreleaser config [-adfhiqVw] [-b=<basedir>] [-c=<configFile>]
@@ -137,7 +137,7 @@ If `--basedir` is undefined then the command assumes it's the same directory tha
=== template
[source,bash]
[source]
----
$ jreleaser template -h
Usage: jreleaser template [-dhioqsVw] [-b=<basedir>] ([-an=<announcerName>] |
@@ -181,7 +181,7 @@ The value of `--tool-name` must match any of the available xref:configuration:pa
=== assemble
[source,bash]
[source]
----
$ jreleaser assemble -h
Usage: jreleaser assemble [-dhiqVw] [-an=<assemblerName>] [-b=<basedir>]
@@ -216,7 +216,7 @@ This command must be invoked separatedly from the others as some of the assmeble
=== changelog
[source,bash]
[source]
----
$ jreleaser changelog -h
Usage: jreleaser changelog [-dhiqVw] [-b=<basedir>] [-c=<configFile>]
@@ -239,7 +239,7 @@ If `--basedir` is undefined then the command assumes it's the same directory tha
=== checksum
[source,bash]
[source]
----
$ jreleaser checksum -h
Usage: jreleaser checksum [-dhiqVw] [-b=<basedir>] [-c=<configFile>]
@@ -262,7 +262,7 @@ If `--basedir` is undefined then the command assumes it's the same directory tha
=== sign
[source,bash]
[source]
----
$ jreleaser sign -h
Usage: jreleaser sign [-dhiqVw] [-b=<basedir>] [-c=<configFile>]
@@ -285,7 +285,7 @@ If `--basedir` is undefined then the command assumes it's the same directory tha
=== upload
[source,bash]
[source]
----
Usage: jreleaser upload [-dhiqVwy] [-b=<basedir>] [-c=<configFile>]
[-un=<uploaderName>] [-ut=<uploaderType>]
@@ -321,32 +321,32 @@ mutations should occur when this mode is activated.
You may invoke this command in the following ways:
Upload all artifacts:
[source,bash]
[source]
----
$ jreleaser upload
----
Upload all artifacts to all configured Artifactory uploaders:
[source,bash]
[source]
----
$ jreleaser upload --uploader-type artifactory
----
Upload all artifacts with all uploaders with matching name:
[source,bash]
[source]
----
$ jreleaser upload --uploader-name mine
----
Upload all artifacts to a matching Artifactory uploader:
[source,bash]
[source]
----
$ jreleaser upload --uploader-type artifactory --uploader-name mine
----
=== release
[source,bash]
[source]
----
$ jreleaser release -h
Usage: jreleaser release [-dhiqVwy] [--auto-config] [--changelog-formatted]
@@ -426,7 +426,7 @@ mutations should occur when this mode is activated.
=== prepare
[source,bash]
[source]
----
$ jreleaser prepare -h
Usage: jreleaser prepare [-dhiqVw] [-b=<basedir>] [-c=<configFile>]
@@ -459,32 +459,32 @@ The value of `--tool-name` must match any of the available xref:configuration:pa
You may invoke this command in the following ways:
Prepare all distributions:
[source,bash]
[source]
----
$ jreleaser prepare
----
Prepare a single distribution with all configured tools:
[source,bash]
[source]
----
$ jreleaser prepare --distribution-name app
----
Prepare all distributions with a single tool:
[source,bash]
[source]
----
$ jreleaser prepare --tool-name brew
----
Prepare a single distribution with a single tool:
[source,bash]
[source]
----
$ jreleaser prepare --distribution-name app --tool-name brew
----
=== package
[source,bash]
[source]
----
$ jreleaser package -h
Usage: jreleaser package [-dhiqVwy] [-b=<basedir>] [-c=<configFile>]
@@ -518,25 +518,25 @@ The value of `--tool-name` must match any of the available xref:configuration:pa
You may invoke this command in the following ways:
Package all distributions:
[source,bash]
[source]
----
$ jreleaser package
----
Package a single distribution with all configured tools:
[source,bash]
[source]
----
$ jreleaser package --distribution-name app
----
Package all distributions with a single tool:
[source,bash]
[source]
----
$ jreleaser package --tool-name brew
----
Package a single distribution with a single tool:
[source,bash]
[source]
----
$ jreleaser package --distribution-name app --tool-name brew
----
@@ -546,7 +546,7 @@ mutations should occur when this mode is activated.
=== publish
[source,bash]
[source]
----
$ jreleaser publish -h
Usage: jreleaser publish [-dhiqVwy] [-b=<basedir>] [-c=<configFile>]
@@ -580,25 +580,25 @@ The value of `--tool-name` must match any of the available xref:configuration:pa
You may invoke this command in the following ways:
Publish all distributions:
[source,bash]
[source]
----
$ jreleaser publish
----
Publish a single distribution with all configured tools:
[source,bash]
[source]
----
$ jreleaser publish --distribution-name app
----
Publish all distributions with a single tool:
[source,bash]
[source]
----
$ jreleaser publish --tool-name brew
----
Publish a single distribution with a single tool:
[source,bash]
[source]
----
$ jreleaser publish --distribution-name app --tool-name brew
----
@@ -608,7 +608,7 @@ mutations should occur when this mode is activated.
=== announce
[source,bash]
[source]
----
$ jreleaser announce -h
Usage: jreleaser announce [-dhiqVwy] [-an=<announcerName>] [-b=<basedir>]
@@ -638,13 +638,13 @@ The value of `--announcer-name` must match any of the available xref:configurati
You may invoke this command in the following ways:
Announce with all configured announcers:
[source,bash]
[source]
----
$ jreleaser announce
----
Announce with a single announcer:
[source,bash]
[source]
----
$ jreleaser announce --announcer-name brew
----
@@ -654,7 +654,7 @@ mutations should occur when this mode is activated.
=== full-release
[source,bash]
[source]
----
$ jreleaser full-release -h
Usage: jreleaser full-release [-dhiqVwy] [-b=<basedir>] [-c=<configFile>]

View File

@@ -1,10 +1,12 @@
= JReleaser Docker Image
= JReleaser Docker Images
== jreleaser-slim
image:https://dockeri.co/image/jreleaser/jreleaser-slim[link="https://hub.docker.com/r/jreleaser/jreleaser-slim"]
Wraps the xref:jreleaser-cli.adoc[] with an Ubuntu based docker image:
link:https://hub.docker.com/r/jreleaser/jreleaser-slim[jreleaser/jreleaser-slim]. This image may be used to run
JReleaser without having a pre-installed Java runtime on your system.
Wraps the xref:jreleaser-cli.adoc[] with an Ubuntu based Docker image:
link:https://hub.docker.com/r/jreleaser/jreleaser-slim[jreleaser/jreleaser-slim]. +
This image may be used to run JReleaser without having a pre-installed Java runtime on your system.
IMPORTANT: Additional packaging options such as xref:configuration:packagers/snap.adoc[Snapcraft] and
xref:configuration:packagers/chocolatey.adoc[] are not available in this mode.
@@ -16,12 +18,42 @@ starting point:
[source]
----
$ docker run -it --rm -v `(pwd)`:/workspace jreleaser/jreleaser-slim:<tag> <command> [<args>]
$ docker run -it --rm -v `(pwd)`:/workspace \
jreleaser/jreleaser-slim:<tag> <command> [<args>]
----
NOTE: The `--basedir` argument will be automatically set to `--basedir=/workspace`.
NOTE: The `jreleaser` command will be automatically executed inside `/workspace`.
You may also need to map environment variables to the container, such as `JRELEASER_PROJECT_VERSION`,
`JRELEASER_GITHUB_TOKEN`, or others depending on your setup.
You can find the tag listing link:hub.docker.com/r/jreleaser/jreleaser-slim/tags[here].
== jreleaser-alpine
image:https://dockeri.co/image/jreleaser/jreleaser-alpine[link="https://hub.docker.com/r/jreleaser/jreleaser-alpine"]
Wraps the xref:jreleaser-cli.adoc[] with an Alpine based Docker image:
link:https://hub.docker.com/r/jreleaser/jreleaser-alpine[jreleaser/jreleaser-alpine]. +
This image may be used to run JReleaser without having a pre-installed Java runtime on your system.
IMPORTANT: Additional packaging options such as xref:configuration:packagers/snap.adoc[Snapcraft] and
xref:configuration:packagers/chocolatey.adoc[] are not available in this mode.
Every command exposed by xref:jreleaser-cli.adoc[] can be invoked with this image.
You must mount the working directory at the `/workspace` volume, for example assuming the current directory is the
starting point:
[source]
----
$ docker run -it --rm -v `(pwd)`:/workspace \
jreleaser/jreleaser-alpine:<tag> <command> [<args>]
----
NOTE: The `jreleaser` command will be automatically executed inside `/workspace`.
You may also need to map environment variables to the container, such as `JRELEASER_PROJECT_VERSION`,
`JRELEASER_GITHUB_TOKEN`, or others depending on your setup.
You can find the tag listing link:hub.docker.com/r/jreleaser/jreleaser-alpine/tags[here].