Commit Graph

390 Commits

Author SHA1 Message Date
dreis2211
5db04da275 Use pattern matching for instanceof where appropriate
See gh-31475
2022-06-20 17:55:36 +01:00
dreis2211
fb45fc4819 Use Files.writeString() and Files.readString() where possible
See gh-31459
2022-06-20 09:05:09 +02:00
Andy Wilkinson
935d1264e0 Merge branch '2.6.x' into 2.7.x 2022-05-26 18:13:08 +01:00
Andy Wilkinson
3d203d0215 Polish 2022-05-26 17:30:39 +01:00
Andy Wilkinson
455ee0ce22 Merge branch '2.6.x' into 2.7.x
Closes gh-31177
2022-05-26 15:53:38 +01:00
Andy Wilkinson
ee45fd2fc8 Remove redundant throws declarations from internal APIs
Closes gh-31176
2022-05-26 15:47:35 +01:00
Andy Wilkinson
4cd850cfc0 Merge branch '2.6.x' into 2.7.x
Closes gh-30851
2022-05-03 15:17:13 +01:00
Andy Wilkinson
fa327a783d Merge branch '2.5.x' into 2.6.x
Closes gh-30850
2022-05-03 15:14:00 +01:00
Andy Wilkinson
4fd2e0c916 Polish "Fix typos"
See gh-30773
2022-05-03 14:09:53 +01:00
Andy Wilkinson
f6d24dc1a8 Fix typos
See gh-30773
2022-05-03 14:09:37 +01:00
Phillip Webb
dd5696b59b Update copyright year of changed files 2022-04-20 15:26:30 -07:00
Scott Frederick
f032690d0a Add support for CNB platform API 0.9
Fixes gh-30566
2022-04-13 16:09:32 -05:00
Scott Frederick
de321b00b7 Support podman for building images
Closes gh-30196
2022-03-11 16:39:07 -06:00
Scott Frederick
7ad538cd84 Add option to use configured Docker host in builder
This commit adds support for a `docker.bindHostToBuilder` option in
the Maven and Gradle image building goal and task.

Fixes gh-29384
2022-03-11 15:27:22 -06:00
Phillip Webb
26512f8ac6 Merge branch '2.6.x' into 2.7.x 2022-02-16 20:24:59 -08:00
Phillip Webb
5b4ec32645 Merge branch '2.5.x' into 2.6.x 2022-02-16 18:56:12 -08:00
Phillip Webb
9ab1b669d0 Polish 2022-02-16 17:56:07 -08:00
Moritz Halbritter
94d095ce1a Merge branch '2.6.x' into 2.7.x
Closes gh-29692
2022-02-09 14:10:41 +01:00
Moritz Halbritter
079ea41d6d Merge branch '2.5.x' into 2.6.x
Closes gh-29691
2022-02-09 14:09:33 +01:00
Moritz Halbritter
262db65a38 Ignore invalid stream types when reading log update events
See gh-29675
2022-02-09 14:03:02 +01:00
Phillip Webb
ce08b519b1 Merge branch '2.6.x' into 2.7.x 2022-02-02 10:37:55 -08:00
Phillip Webb
50e0e28155 Merge branch '2.5.x' into 2.6.x 2022-02-02 10:37:32 -08:00
Phillip Webb
2b40ce09d8 Update copyright year of changed files 2022-02-02 10:35:40 -08:00
Stephane Nicoll
f812b33cbd Merge branch '2.6.x' into 2.7.x
Closes gh-29613
2022-02-01 11:07:31 +01:00
Stephane Nicoll
136b5959c3 Merge branch '2.5.x' into 2.6.x
Closes gh-29612
2022-02-01 10:59:08 +01:00
Stephane Nicoll
7f17f819a6 Polish "Enforce use of BDDMockito"
See gh-29178
2022-02-01 10:03:18 +01:00
Yanming Zhou
b49418aaaf Enforce use of BDDMockito
1. Replace Mockito.verify*() with BDDMockito.then()
2. Replace Mockito.doReturn() with BDDMockito.willReturn()
3. Adjust checkstyle rule

See gh-29178
2022-02-01 09:37:15 +01:00
Scott Frederick
698eb94913 Merge branch '2.6.x' into 2.7.x
Closes gh-29554
2022-01-24 16:20:33 -06:00
Scott Frederick
909ef6d635 Merge branch '2.5.x' into 2.6.x
Closes gh-29553
2022-01-24 16:19:43 -06:00
Scott Frederick
000cbfa2d9 Set file permissions on all created test files
Closes gh-29551
2022-01-24 16:19:20 -06:00
Scott Frederick
3cb30cb283 Merge branch '2.6.x' into 2.7.x
Closes gh-28923
2021-12-07 14:10:46 -06:00
Scott Frederick
3555837845 Merge branch '2.5.x' into 2.6.x
Closes gh-28922
2021-12-07 14:10:28 -06:00
Scott Frederick
b0b2cd79b4 Use latest buildpack image tag when no tag is provided
Fixes gh-28921
2021-12-07 14:10:10 -06:00
Scott Frederick
5f14cffea3 Add support for CNB platform API 0.5 through 0.8
Fixes gh-28850
2021-12-01 14:05:20 -06:00
Andy Wilkinson
2a342ef416 Merge branch '2.5.x'
Closes gh-28662
2021-11-12 23:40:35 +00:00
Andy Wilkinson
5e4a502b2d Merge branch '2.4.x' into 2.5.x
Closes gh-28661
2021-11-12 20:31:25 +00:00
Andy Wilkinson
2cec3971d7 Prohibit unwanted dependencies in all modules not just starters
Closes gh-28658
2021-11-12 20:04:35 +00:00
Stephane Nicoll
9241f228d5 Add .gitattributes
Closes gh-28474
2021-10-28 15:31:40 +02:00
Stephane Nicoll
66553ac8c7 Add .gitattributes
Closes gh-28473
2021-10-28 15:27:49 +02:00
Stephane Nicoll
1b3f52d609 Harmonize line endings
See gh-27615
2021-10-28 15:22:57 +02:00
Scott Frederick
871468931f Polish "Add option to customize cache volume names when building an image"
See gh-28292
2021-10-19 15:38:12 -05:00
Julian Liebig
dc36346285 Add option to customize cache volume names when building an image
This commit adds configuration to the Maven and Gradle plugins to
allow specifying the names of build and launch cache volumes provided
to the CNB builder.

See gh-28292
2021-10-19 15:38:12 -05:00
Andy Wilkinson
48b1175559 Merge branch '2.5.x'
Closes gh-28263
2021-10-08 12:39:45 +01:00
Andy Wilkinson
d47260637b Merge branch '2.4.x' into 2.5.x
Closes gh-28262
2021-10-08 12:39:17 +01:00
Andy Wilkinson
c5d45585d9 Remove unnecessary overrides of finalize
Closes gh-28209
2021-10-08 12:39:00 +01:00
Scott Frederick
64c49003aa Polish "Add option to create tags for a built image"
See gh-27613
2021-09-28 15:32:27 -05:00
Rafael Ceccone
66f44b0c7f Add option to create tags for a built image
This commit adds configuration to the Maven and Gradle plugins to
allow specifying multiple tag to be created that refer to the built
image.

See gh-27613
2021-09-28 15:32:27 -05:00
dreis2211
cf0fcafd13 Polish
See gh-27940
2021-09-21 08:08:29 +02:00
Scott Frederick
a6d03279ca Merge branch '2.5.x'
Closes gh-27994
2021-09-14 16:45:58 -05:00
Scott Frederick
a540da11ad Merge branch '2.4.x' into 2.5.x
Closes gh-27993
2021-09-14 16:45:34 -05:00
Scott Frederick
c8ff874e91 Add builderFor label to ephemeral builder image
Adding a label to the ephemeral builder image cloned from the base
builder image eliminates contention between builds that are run
concurrently. Without this label, concurrent builds could result in
a race condition in the Docker daemon if the ephemeral builder image
shared by builds was deleted by both builds at exactly the same time.

Fixes gh-27888
2021-09-14 15:22:23 -05:00
Andy Wilkinson
fd2fbcb3c6 Merge branch '2.5.x'
Closes gh-27758
2021-08-18 18:28:34 +01:00
Andy Wilkinson
6d8ba3e8b1 Merge branch '2.4.x' into 2.5.x
Closes gh-27757
2021-08-18 17:56:32 +01:00
Andy Wilkinson
ffbd28b60a Polish "Polish access modifiers for test classes"
See gh-27736
2021-08-18 17:52:42 +01:00
izeye
8a425dedfd Polish access modifiers for test classes
See gh-27736
2021-08-18 17:38:40 +01:00
Scott Frederick
2178c281e9 Polish "Add network option for image building"
See gh-27486
2021-08-12 17:08:52 -05:00
Jeroen Meijer
8e6d03b221 Add network option for image building
This commit adds configuration to the Maven and Gradle plugins to
allow specifying the network mode to be provided to the image
building goal and task.

See gh-27486
2021-08-12 17:08:52 -05:00
Scott Frederick
9f001efa29 Adjust fat jar central directory to account for launch script
An upgrade to Apache Commons Compress allows the build plugins to write
the launch script to the fat jar as a proper preamble, making the file
compatible with more jar and zip tooling.

Fixes gh-22336
2021-07-19 15:02:42 -05:00
Stephane Nicoll
dc5acb0019 Remove deprecated code flagged for removal
Closes gh-27303
2021-07-14 11:50:01 +02:00
Scott Frederick
fba5ffc626 Fix FilePermissionsTests on Windows
See gh-26658
2021-06-08 15:58:03 -05:00
Scott Frederick
f560e86f03 Write buildpack directories to builder layer
When a custom buildpack is provided for image building, the contents
of the buildpack directory, tgz file, or image are copied as tar
entries to a new layer in the ephemeral builder image. Prior to this
commit, only file entries from the buildpack source were copied as
builder layer tar entries; intermediate directory entries from the
source were not copied. This results in directories being created in
the builder container using default permissions. This worked on most
Linux-like OSs where the default permissions allow others-read
access. On some OSs like Arch Linux where the default directory
permissions do not allow others-read, this prevented the lifecycle
processes from reading the buildpack files.

This commit explicitly creates all intermediate directory tar entries
in the builder image layer to ensure that the buildpack directories
and files can be read by the lifecycle processes.

Fixes gh-26658
2021-06-02 14:09:53 -05:00
Phillip Webb
d3f0f04f05 Merge branch '2.4.x'
Closes gh-26703
2021-05-28 14:53:27 -07:00
Phillip Webb
49d3ecc2b2 Merge branch '2.3.x' into 2.4.x
Closes gh-26702
2021-05-28 14:53:12 -07:00
Phillip Webb
617f7b9587 Improve ImageName/ImageReference parse performance
Update `ImageName` and `ImageReference` to use distinct regex patterns
to parse specific parts of the value. Prior to this commit a single
regex pattern was used which could hang given certain input strings.

Fixes gh-23115
2021-05-28 14:52:27 -07:00
weixsun
8a2be288a3 Remove unnecessary throws declaration in tests
See gh-26441
2021-05-17 09:31:51 +02:00
Scott Frederick
e9adb1ab88 Handle long file names in buildpack images
Fixes gh-26445
2021-05-12 18:14:56 -05:00
Scott Frederick
86303c017b Merge branch '2.4.x'
Closes gh-25938
2021-04-08 13:03:45 -05:00
Scott Frederick
9108b81bb2 Merge branch '2.3.x' into 2.4.x
Closes gh-25937
2021-04-08 13:03:26 -05:00
Scott Frederick
0ad7f76263 Preserve file permissions in images built by Gradle
This commit copies the file mode along with other attributes when
copying files from the source archive to the build container while
building an image using the Gradle plugin. This preserves file
permissions on any resources included in the source archive.

Fixes gh-25915
2021-04-08 12:56:41 -05:00
Phillip Webb
8c31d29acf Merge branch '2.4.x' 2021-03-30 09:29:59 -07:00
Phillip Webb
a28a3ae090 Merge branch '2.3.x' into 2.4.x 2021-03-30 09:25:46 -07:00
Phillip Webb
44b1751bb4 Merge branch '2.4.x'
Closes gh-25826
2021-03-29 15:48:20 -07:00
Phillip Webb
363f5829d1 Merge branch '2.3.x' into 2.4.x
Closes gh-25825
2021-03-29 15:46:50 -07:00
Phillip Webb
685b045c3d Polish 2021-03-18 14:49:52 -07:00
Scott Frederick
76e42ff96f Correct grouping of custom buildpacks
This commit corrects the order.toml file that is generated and added
to the builder when building an image using custom buildpacks with the
Maven or Gradle plugin in order to support buildpacks that depend on
detection as a group.

Fixes gh-25378
2021-02-23 13:56:57 -06:00
Scott Frederick
89555a8745 Add bindings option for image building
This commit adds configuration to the Maven and Gradle plugins to
allow a list of volume mount bindings to be provided to the image
building goal and task. This enables service bindings to be mounted
in the builder image that are recognized by buildpacks to support
custom certificates, build tool configuration, APM integration, and
other buildpack features.

Fixes gh-23518
2021-02-22 16:51:24 -06:00
Phillip Webb
4ad149e1e7 Protect against bad paths and URLs
See gh-21722
2021-02-18 16:23:56 -08:00
Scott Frederick
e3e229cc3d Remove unused import
See gh-21722
2021-02-18 17:39:59 -06:00
Scott Frederick
f54f784f80 Add buildpack option for image building
This commit adds configuration to the Maven and Gradle plugins to
allow a list of buildpacks to be provided to the image building
goal and task.

Fixes gh-21722
2021-02-18 17:28:25 -06:00
Andy Wilkinson
db781a0d84 Merge branch '2.4.x'
See gh-25077
2021-02-02 15:14:18 +00:00
Andy Wilkinson
788a42d694 Merge branch '2.3.x' into 2.4.x
See gh-25076
2021-02-02 15:12:27 +00:00
Andy Wilkinson
67479b6380 Add junit-platform-launcher dependency by convention
Closes gh-25074
2021-02-02 13:03:21 +00:00
Phillip Webb
d8b6960997 Merge branch '2.4.x'
Closes gh-25077
2021-02-01 16:08:57 -08:00
Phillip Webb
257608a3a3 Merge branch '2.3.x' into 2.4.x
Closes gh-25076
2021-02-01 16:03:43 -08:00
Phillip Webb
939b5dfc26 Add junit-platform-launcher dependency
Update `build.gradle` files to ensure that `junit-platform-launcher` is
a `testRuntimeOnly` dependency. This ensures that tests can be run from
Eclipse.

Closes gh-25074
2021-02-01 15:31:28 -08:00
Scott Frederick
9925c4ccd2 Merge branch '2.4.x'
Closes gh-24794
2021-01-12 17:50:55 -06:00
Scott Frederick
a9e711e503 Enforce builder and run images in the same registry
Previously, when an authenticated Docker builder registry was
configured in the Maven or Gradle plugin and the builder and run
images specified different registries, the authentication credentials
would be sent to both registries. This could cause confusion if both
registries don't recognize the same credentials. This commit enforces
that both images are in the same registry when authentication
is configured.

Fixes gh-24552
2021-01-12 17:50:28 -06:00
Stephane Nicoll
a6c6655c82 Polish "Upgrade to Jackson 2.12.0"
Guard breaking change to PropertyNamingStrategies so that we tolerate
older Jackson versions.

See gh-24415
2020-12-21 15:51:52 +01:00
Valery Yatsynovich
1f63b82c5b Upgrade to Jackson 2.12.0
See gh-24415
2020-12-21 15:27:44 +01:00
Scott Frederick
04a40a4c68 Provide content-length header to Docker API calls
Docker daemon authorization plugins reject POST or PUT requests that have a
content type `application/json` header but no content length header. This
commit ensures that a content length header is provided in these cases.

This is a cherry-pick of the changes in d5b2836ec9
which were lost in a forward-merge.

Fixes gh-23957
2020-10-28 17:31:27 -05:00
Scott Frederick
d5b2836ec9 Provide content-length header to Docker API calls
Docker daemon authorization plugins reject POST or PUT requests that have a
content type `application/json` header but no content length header. This
commit ensures that a content length header is provided in these cases.

Fixes gh-22840
2020-10-28 15:15:32 -05:00
Andy Wilkinson
2d8528d5bd Adapt to deprecation of StringUtils.isEmpty(Object)
See gh-23774
2020-10-22 17:09:33 +01:00
Scott Frederick
38984985d4 Add support for CNB platform API 0.4
This commit adds support for platform API 0.4 when invoking a CNB
builder in the Maven and Gradle plugins. If the builder advertises
that it supports platform API 0.4 then that version will be
requested when invoking lifecycle phases. Otherwise the plugins
will fall back to requesting platform API 0.3.

Requesting platform API 0.4 when invoking builder lifecycle phases
has the primary benefit of making it easier to pass command-line
arguments to the default process in the generated image.

Fixes gh-23692
2020-10-19 17:33:40 -05:00
Scott Frederick
5b1b03c56c Set platform API version when invoking image builder
The CNB specifications allow builders to support multiple platform
API versions. The supported versions are published in the builder
image metadata as an array of version numbers, while a single
supported version number was published in earlier builder metadata.

These changes read the supported versions from the builder metadata
and fall back to the single version if the array is not present.
A CNB_PLATFORM_API environment variable is set on each lifecycle
phase invocation to request a specific version as recommended in
the CNB platform spec.

Fixes gh-23682
2020-10-14 11:49:34 -05:00
Scott Frederick
0e7ab88491 Polish "Update default builder image"
See gh-23628
2020-10-12 17:07:33 -05:00
Emily Casey
461dc23c0c Update default builder image
This commit updates the default builder image used by the Maven
and Gradle plugins image-building goal and task to use the latest
Paketo builder image. The builder image is pulled from Docker Hub
instead of Google Container Registry by default.

See gh-23628
2020-10-12 17:06:42 -05:00
Scott Frederick
09b627d232 Add support for publishing docker images to a registry
This commit adds options to the Maven and Gradle plugins to publish
to a Docker registry the image generated by the image-building goal
and task.

The Docker registry auth configuration added in an earlier commit
was modified to accept separate auth configs for the builder/run
image and the generated image, since it is likely these images will
be stored in separate registries or repositories with distinct
auth required for each.

Fixes gh-21001
2020-10-07 16:51:33 -05:00
Scott Frederick
54288678d1 Configure Docker host in build plugins
This commit adds the ability to configure the Maven and Gradle
plugins to use a remote Docker daemon using build file
configuration, as an alternative to setting environment variables
to specify remote host connection details.

Fixes gh-23400
2020-09-18 13:51:20 -05:00
Phillip Webb
27095d9043 Polish 2020-09-17 00:31:00 -07:00
Scott Frederick
86fa8144f5 Polish "Support authentication to private Docker registry"
See gh-22972
2020-09-16 16:04:21 -05:00
姜为
e8f555e13d Support authentication to private docker registry
This commit adds the ability to configure Docker image registry
authentication credentials in the Maven and Gradle plugins. The
authentication credentials are passed to the Docker daemon with
all daemon API calls, and the daemon forwards the credentials to the
image registry when necessary. This makes it possible to use
builder and run images stored in a private Docker registry.

See gh-22972
2020-09-16 16:03:40 -05:00
Scott Frederick
b70d0dd5ac Merge branch '2.3.x'
Closes gh-23134
2020-08-28 17:04:57 -05:00
Scott Frederick
bc1834bfdf Ensure layer digest hashes contain 64 characters
This commit ensures that encoded digest hashes for Docker image
layers are zero-padded to the required 64 characters length.

Fixes gh-23132
2020-08-28 17:04:34 -05:00
Scott Frederick
ccabc1a4c9 Merge branch '2.3.x'
Closes gh-23133
2020-08-28 15:18:30 -05:00
Scott Frederick
4f1b4c98ae Fail on Docker image load with empty response
In some cases, a call to the Docker image load API will fail but
return a 200 OK response status code and an empty response. This
commit detects that the response from this call is empty and
treats this condition as an error instead of a silent failure.

Fixes gh-23130
2020-08-28 15:18:02 -05:00
dreis2211
33cd875cb8 Simplify InputStream assertions
See gh-23052
2020-08-24 11:35:17 +02:00
Scott Frederick
ee41d71ea8 Merge branch '2.3.x'
Closes gh-23016
2020-08-19 16:12:44 -05:00
Scott Frederick
56bc0eb9e0 Use canonical path for CNB builder lifecycle binaries
This commit changes the path used to invoke lifecycle binaries in
CNB builders from `/lifecycle` to `/cnb/lifecycle` to conform to
the CNB spec. This will ensure the build plugin image-building
goals and tasks are compatible with future versions of builders
that may not support both paths.

See gh-23009
2020-08-19 16:11:59 -05:00
Scott Frederick
6b15822cb1 Polish "Add pullPolicy option for image building"
See gh-22736
2020-08-12 15:16:38 -05:00
anshlykov
c7449b57ce Add pullPolicy option for image building
This commit adds a pullPolicy option to the configuration of the Maven
plugin spring-boot:build-image goal and the Gradle plugin bootBuildImage
task. The new option gives users control over pulling the builder image
and run image from a remote image registry to the local Docker daemon.

See gh-22736
2020-08-12 15:16:38 -05:00
Andy Wilkinson
969dd35e45 Upgrade to Mockito 3.4.6
Closes gh-22838
2020-08-10 15:22:03 +01:00
Scott Frederick
f247fec310 Merge branch '2.3.x'
Closes gh-22735
2020-08-04 15:30:17 -05:00
Scott Frederick
21b2dd2740 Allow empty env entries when building an image
Prior to this commit, an entry in the environment map provided to the
build plugin image building goal or task that had a null value would
result in a failure with a message that was difficult to diagnose.

This commit treats env map entries with a null value as an empty
entry to prevent the failure and also make it easier to provide an
explicit empty entry in the Maven XML.

Fixes gh-22703
2020-08-04 15:29:29 -05:00
dreis2211
e49e2dfff1 Use Supplier variants of Assert methods
See gh-22699
2020-08-03 15:06:13 +02:00
Phillip Webb
da69286838 Merge branch '2.3.x' 2020-07-22 17:39:27 -07:00
Phillip Webb
d2a7808098 Polish 2020-07-22 17:25:04 -07:00
Scott Frederick
e6318f83b2 Merge branch '2.3.x'
Closes gh-22349
2020-07-15 15:17:16 -05:00
Scott Frederick
bc88af8e53 Restore accidentally deleted line 2020-07-15 15:14:23 -05:00
Scott Frederick
210282260e Fail on bootBuildImage with launch script
This commit adds a check to the support code for the Gradle plugin
bootBuildImage task to ensure that the jar file that will be passed
to a builder is readable and has a valid directory. This prevents a
situation where the jar file cannot be read because it is prepended
with a launch script, and the builder does not receive any files to
process.

Notes have also been added to the Gradle plugin documentation to warn
against using a bootJar launchScript configuration and bootBuildImage
together, as well as caveats about launchScript that match the Maven
plugin documentation.

Fixes gh-22223
2020-07-15 14:58:11 -05:00
Andy Wilkinson
3d2f67f0be Merge branch '2.3.x'
Closes gh-22304
2020-07-10 15:36:49 +01:00
Andy Wilkinson
f18b657ff9 Fix handling of DOCKER_HOST that begins with unix://
Fixes gh-22300
2020-07-10 15:31:55 +01:00
Andy Wilkinson
160d8e49e3 Merge branch '2.3.x'
Closes gh-22180
2020-07-01 11:44:00 +01:00
Andy Wilkinson
9317135690 Improve error handling when builder image isn't a builder
Fixes gh-22179
2020-07-01 11:42:36 +01:00
Phillip Webb
301ec12a0c Merge branch '2.3.x' 2020-06-22 22:37:25 -07:00
Phillip Webb
f296f57401 Rename ImageReferenceParser to Regex
Rename `ImageReferenceParser` to `Regex` and remove state. The regular
expressions are now used directly by the `ImageName` and
`ImageReference` classes with the values accessed directly from the
`Matcher`.

See gh-21495
2020-06-22 22:36:46 -07:00
Scott Frederick
39b2d01541 Merge branch '2.3.x'
Closes gh-22037
2020-06-19 15:43:59 -05:00
dreis2211
a6e8561391 Catch more generic FileSystemException in NamedPipeSocket
See gh-22035
2020-06-19 15:41:20 -05:00
Scott Frederick
73b737c7d8 Merge branch '2.3.x'
Closes gh-22017
2020-06-18 15:11:07 -05:00
Scott Frederick
28643e4d2d Validate image references before passing to CNB builder
Prior to this commit, an image name or run image name derived from
the project name or provided by the user would be passed to the CNB
builder without validation by the Maven plugin build-image goal or
Gradle plugin bootBuildImage task. This could lead to error messages
from the plugins that are difficult to understand and diagnose.

This commit makes parsing of the image names more strict, based on
the grammar implemented by the Docker go library. This provides
validation of the image names before passing them to the builder,
with a more descriptive error message when parsing and validation
fails.

Fixes gh-21495
2020-06-18 15:09:57 -05:00
Andy Wilkinson
07fb4b065d Merge branch '2.3.x'
Closes gh-21940
2020-06-16 10:10:38 +01:00
Andy Wilkinson
0de466e06e Require dependency on s-b-dependencies to use its constraints
Previously, Spring Boot's modules published Gradle Module Metadata
(GMM) the declared a platform dependency on spring-boot-dependencies.
This provided versions for each module's own dependencies but also had
they unwanted side-effect of pulling in spring-boot-dependencies
constraints which would influence the version of other dependencies
declared in the same configuration. This was undesirable as users
should be able to opt in to this level of dependency management, either
by using the dependency management plugin or by using Gradle's built-in
support via a platform dependency on spring-boot-dependencies.

This commit reworks how Spring Boot's build uses
spring-boot-dependencies and spring-boot-parent to provide its own
dependency management. Configurations that aren't seen by consumers are
configured to extend a dependencyManagement configuration that has an
enforced platform dependency on spring-boot-parent. This enforces
spring-boot-parent's version constraints on Spring Boot's build without
making them visible to consumers. To ensure that the versions that
Spring Boot has been built against are visible to consumers, the
Maven publication that produces pom files and GMM for the published
modules is configured to use the resolved versions from the module's
runtime classpath.

Fixes gh-21911
2020-06-16 08:50:21 +01:00
Scott Frederick
838cfc529f Merge branch '2.3.x'
Closes gh-21933
2020-06-15 16:17:39 -05:00
Scott Frederick
6119d69679 Add runImage option for image building
This commit adds a runImage property to the Maven plugin build-image
goal and the Gradle bootBuildImage task. The property allows the user
to override the run image reference provided in the builder metadata
with an alternate run image. The runImage property can be specified
in the build file or on the command line.

Fixes gh-21534
2020-06-15 16:08:56 -05:00
Phillip Webb
3892f4402a Merge branch '2.3.x'
Closes gh-21895
2020-06-11 12:32:41 -07:00
Phillip Webb
1e7da4d3ca Allow digest builder references
Update `BuildRequest` to also allow digest based references.

Closes gh-21879
2020-06-11 12:31:29 -07:00
Scott Frederick
9d9a501b17 Merge branch '2.3.x'
Closes gh-21892
2020-06-11 11:55:20 -05:00
Scott Frederick
7a2939f129 Use non-blocking I/O for Docker API
This commit changes the NamedPipeSocket used for communication with
a local Docker daemon to use a non-blocking AsynchronousByteChannel
instead of a blocking RandomAccessFile, modeled after a similar
change to the docker-java project. This eliminates the potential for
a blocking call to hang indefinitely.

Fixes gh-21672
2020-06-11 11:53:52 -05:00
Phillip Webb
5f79bd2a09 Merge branch '2.3.x'
Closes gh-21734
2020-06-06 11:08:30 -07:00
dreis2211
2b5569f054 Polish
See gh-21732
2020-06-06 11:07:21 -07:00
Scott Frederick
87f5894a9a Merge branch '2.3.x'
Closes gh-21685
2020-06-03 16:54:37 -05:00
Scott Frederick
29253264b4 Improve Docker API 5xx error messages
This commit improves the error messages returned by the Spring Boot
build plugins when a 5xx status code is returned from the Docker
API while attempting to build an image. If the error response has
contents containing a JSON structure with a "message" key, the value
associated with that key will be included in the exception message
and in the build plugin output error.

Fixes gh-21515
2020-06-03 16:53:44 -05:00
Phillip Webb
502e2a4c64 Polish 2020-06-01 14:27:39 -07:00
Scott Frederick
7722394e19 Provide better error message if Docker is not running
Previously, if the Spring Boot build plugins got a connection error
when attempting to communicate with a Docker daemon (for example,
when the daemon isn't running), the error message made it appear that
the daemon returned an HTTP error code. This commit makes a connection
error distinct from an HTTP error response code to make it easier for
the user to diagnose the root cause of the problem.

Fixes gh-21554
2020-05-29 12:37:06 -05:00
Scott Frederick
ed4a7d4ba0 Use default tag when pulling run image
Prior to this commit, a default tag of 'latest' was used when no tag
was included in the builder image name used when building an image in
the Maven and Gradle plugins, but the tag for the run image was left
empty if it was not provided. This resulted in errors when pulling
the run image from an image repository. This commit applies the
same tag defaulting logic to the run image name.

Fixes gh-21532
2020-05-21 17:28:59 -05:00
Phillip Webb
12381467da Polish 2020-05-13 16:48:51 -07:00
Scott Frederick
90ce472252 Support local socket path in DOCKER_HOST
Prior to this commit, if a DOCKER_HOST environment variable was present
when attempting to communicate with a Docker daemon, it was assumed
that the value of that variable was an address that could be used to
create an HTTP connection to a remote daemon. In some cases, the value
of the variable is the path to a local socket file, which would cause
the HTTP connection to fail.

This commit adds additional validation of the value of the DOCKER_HOST
environment variable to determine whether it is a remote address or
a local socket file and create the appropriate connection type.

Fixes gh-21173
2020-05-12 16:11:27 -05:00
Scott Frederick
35bc82a693 Use CNB creator all-in-one lifecycle
This commit modifies the buildpack platform invocation logic used by
the build plugins to invoke the single creator lifecycle introduced in
the CNB API 0.3, instead of invoking discrete lifecycle phases
separately. It also removes support for CNB API 0.2.

Fixes gh-21273
2020-05-08 17:03:47 -05:00
Scott Frederick
0cb090766f Fix typos in mock tests data 2020-04-29 18:08:34 -05:00
Scott Frederick
f3d717e97a Use paketo-buildpacks/builder as default builder
This commit changes the default builder image from
`cloudfoundry/cnb:bionic-platform-api-0.2` to
`gcr.io/paketo-buildpacks/builder:base-platform-api-0.3`. It also
uses a `paketo-buildpacks/builder` image instead of a
`cloudfoundry/cnb` image to test compatibility with lifecycle v2
and uses paketo naming instead of cloudfoundry when mocking builder
interactions.

Some adjustments to lifecycle phases were also made to align more
closely with the pack CLI.

Fixes gh-21066
2020-04-29 14:28:25 -05:00
Phillip Webb
ad1248e4ec Replace "folder" with "directory"
Consistently use the term "directory" instead of "folder"

Closes gh-21218
2020-04-28 19:20:24 -07:00
dreis2211
4b0a31acf8 Delete Toml class
See gh-21129
2020-04-28 11:01:00 +01:00
dreis2211
5eb5bf0a2d Polish
See gh-21009
2020-04-25 08:54:47 +02:00
Johnny Lim
29717423a3 Remove this keyword on member method invocations
See gh-21007
2020-04-25 08:49:44 +02:00
dreis2211
4b9986d790 Remove unused fields in tests
See gh-20926
2020-04-13 13:46:43 +02:00
Cicio Flaviu
7f1655e5cb Add package-info to buildpack.platform.docker.ssl
See gh-20913
2020-04-10 08:57:23 -05:00
Phillip Webb
ffd499fdc7 Attempt to fix failing Windows test 2020-04-06 23:02:12 -07:00
Phillip Webb
5b374e833b Cleanup paths to fix tests running on Windows 2020-04-06 20:33:33 -07:00
Scott Frederick
cc2852ce79 Polish 2020-04-01 18:43:11 -05:00
Scott Frederick
a01c8452cb Support CNB builder platform API 0.3
This commit adds support for Cloud Native Buildpacks builder platform
API 0.3, which is the latest platform API available currently. Support
for platform API 0.1 has been removed, adopting the policy of the pack
CLI to support the current platform API version and one version prior.

Fixes gh-20757
2020-04-01 17:18:46 -05:00
Scott Frederick
bb9e37e119 Use platform API builder image tags
CNB builder images are now being tagged in a manner that indicates
the version of the platform API implemented. This allows Spring Boot
to default to a builder tag that guarantees API compatibility while
allowing for updates to bundled buildpacks.

Fixes gh-20171
2020-04-01 16:18:05 -05:00
Phillip Webb
4dad56a491 Restructure and polish docker code
Restructure and polish docker code to fix a package tangle and
provide better separation of concerns.
2020-04-01 11:51:33 -07:00
Scott Frederick
ed6e54218d Support remote Docker daemon for building images
Prior to this commit, the build plugin goal/task for building images
required a locally running Docker daemon that was accessed via a
non-networked socket or pipe.

This commit adds support for remote Docker daemons at a location
specified by the environment variable `DOCKER_HOST`. Additional
environment variables `DOCKER_TLS_VERIFY` and `DOCKER_CERT_PATH`
are recognized for configuring a secure TLS connection to the daemon.

Fixes gh-20538
2020-03-30 17:06:02 -05:00
Phillip Webb
0717de723f Polish 2020-03-23 20:03:44 -07:00
dreis2211
9588188800 Use isEmpty() where possible
See gh-20370
2020-03-03 18:33:26 -05:00
Scott Frederick
296a13a479 Fix unit test case formatting 2020-02-27 16:43:56 -06:00
Scott Frederick
b00ed5b143 Remove unused imports 2020-02-27 16:17:19 -06:00
Scott Frederick
ada0741e10 Polish Docker client exception handling 2020-02-27 16:09:30 -06:00
Mike Smithson
6f095d6fec Improve error message from image building
Translate IOException to DockerException for a more meaningful error
message when the Docker daemon is not available.

Fixes gh-20151
2020-02-27 15:51:58 -06:00
dreis2211
4f824bf9ad Fix duplicate words
See gh-20210
2020-02-18 13:34:56 +01:00
Scott Frederick
e294d26458 Set ephemeral builder container creation to a fixed date
This commit fixes the `Created` date and time of the ephemeral builder
container image at the Windows epoch plus one second
(1980-01-01T00:00:01Z). This date matches the created date of the builder
image and influences the created date of the resulting image. Using
a fixed date for images ensures that the digest is consistent for all
images with the same version.

Fixes gh-20126
2020-02-12 13:55:54 -06:00
Scott Frederick
191dce3f5e Set Spring Boot version in ephemeral builder
This commit adds a `createdBy` structure to the metadata of the ephemeral
builder container image that identifies Spring Boot as the creator of the
image, along with the Spring Boot version.

See gh-20126
2020-02-12 13:31:21 -06:00
Scott Frederick
12c640e133 Upgrade default image builder version
This commit upgrades the default CNB builder image from
cloudfoundry/cnb:0.0.43-bionic to cloudfoundry/cnb:0.0.53-bionic.
It also adds integration tests for the Maven and Gradle plugins
to verify both versions are supported.
2020-02-06 17:24:29 -06:00
Scott Frederick
d07062652e Add support for CNB platform API v0.2
Cloud Native Buildpacks platform API version 0.2 introduced
two breaking changes: the order of invoking the restore and analyze
phases was reversed, and the cache phase was removed in favor of
distributing caching across other phases.

This commit adds support for Cloud Native Buildpacks builders that
implement platform API version 0.2, while maintaining compatibility
with builders that implement Lifecycle version platform API
version 0.1.

Closes gh-19829
2020-02-06 17:24:29 -06:00
Phillip Webb
cbacab5e26 Polish 2020-01-30 17:14:36 -08:00
Phillip Webb
234c5033d4 Polish whitespace 2020-01-30 17:09:49 -08:00
Scott Frederick
b281af0b9b Remove adding of existing layers to EphemeralBuilder
Layers were being added to the EphemeralBuilder each time one was
created, but those layers already existed in the base builder image.

Closes gh-19832
2020-01-30 16:34:02 -06:00
Andy Wilkinson
2725264be1 Polishing formatting of DockerApi 2020-01-30 14:08:45 +00:00
Andy Wilkinson
28442b5ca5 Lower the minimum required Docker API version to 1.24
Closes gh-19945
2020-01-30 13:57:18 +00:00
Andy Wilkinson
54b3f480b4 Use posix long names when creating tar archive for image building
Fixes gh-19964
2020-01-30 13:31:27 +00:00
Scott Frederick
c6a6024062 Stop image building on error from builder
Previously, the image builder used by the build tool plugins ignored
errors from lifecycle phases and continued with subsequent phases.

This commit inspects the status of the builder container after each
lifecycle phase and aborts the image building process if the exit
status of the container after any phase is non-zero.

Fixes #19949
2020-01-29 17:51:32 -06:00
dreis2211
d8e2349e47 Use Supplier variants of Assert
See gh-19864
2020-01-28 15:04:11 +01:00
Andy Wilkinson
63b736d1f0 Fix NPE when waiting for named socket path to become available
Fixes gh-19941
2020-01-27 11:38:19 +00:00
Stephane Nicoll
3290313eb7 Fix Docker socket creation on Windows
Closes gh-19908
2020-01-27 07:29:16 +01:00
Andy Wilkinson
0a9fe65443 Use line endings on all OSs when writing image config JSON
Previously \r\n was used on Windows and \n was used on other
platforms. This resulted in different JSON content being written to
the archive. As the config's entry name is the SHA-256 hash of its
content, it also resulted in the entry name being different.

This commit updates the JSON that's written into the archive to use
\n line endings, irrespective of the OS on which the image is being
built.

See gh-19828
2020-01-23 14:37:06 +00:00
Andy Wilkinson
a0b4cdee44 Make line ending expectations in TotalProgressBarTests OS-independent
See gh-19828
2020-01-23 14:14:14 +00:00
Stephane Nicoll
105db66553 Polish 2020-01-23 14:04:19 +01:00
Andy Wilkinson
0bd0b2a6c0 Add support for building OCI images using the Gradle plugin
Closes gh-19831
2020-01-23 10:52:57 +00:00
Phillip Webb
e0013454b5 Use parentheses when declaring dependencies
Update all dependencies declarations to use the form `scope(reference)`
rather than `scope reference`.

Prior to this commit we declared dependencies without parentheses unless
we were forced to add them due to an `exclude`.
2020-01-22 16:02:38 -08:00
Phillip Webb
0209cd3e4c Polish quote form used in Gradle scripts
Replace Gradle single quote strings with the double quote form
whenever possible. The change helps to being consistency to the
dependencies section where mostly single quotes were used, but
occasionally double quotes were required due to `${}` references.
2020-01-22 15:49:52 -08:00
Phillip Webb
e28338d6cd Rename spring-boot-cloudnativebuildpack
Rename the `spring-boot-cloudnativebuildpack` module to
`spring-boot-buildpack-platform` and update the the package
name to `org.springframework.boot.buildpack.platform`.

Closes gh-19851
2020-01-22 11:01:32 -08:00