Allow image application directory to be configurable
An `applicationDirectory` option on the Maven `spring-boot:build-image` goal and the Gradle `bootBuildImage` task can be configured to set the location that will be used to upload application contents to the builder image, and will contain the application contents in the generated image. Closes gh-34786
This commit is contained in:
@@ -270,6 +270,16 @@ public abstract class BootBuildImage extends DefaultTask {
|
||||
@Option(option = "createdDate", description = "The date to use as the created date of the image")
|
||||
public abstract Property<String> getCreatedDate();
|
||||
|
||||
/**
|
||||
* Returns the directory that contains application content in the image. When
|
||||
* {@code null}, a default location will be used.
|
||||
* @return the application directory
|
||||
*/
|
||||
@Input
|
||||
@Optional
|
||||
@Option(option = "applicationDirectory", description = "The directory containing application content in the image")
|
||||
public abstract Property<String> getApplicationDirectory();
|
||||
|
||||
/**
|
||||
* Returns the Docker configuration the builder will use.
|
||||
* @return docker configuration.
|
||||
@@ -316,6 +326,7 @@ public abstract class BootBuildImage extends DefaultTask {
|
||||
request = customizeCaches(request);
|
||||
request = request.withNetwork(getNetwork().getOrNull());
|
||||
request = customizeCreatedDate(request);
|
||||
request = customizeApplicationDirectory(request);
|
||||
return request;
|
||||
}
|
||||
|
||||
@@ -406,4 +417,12 @@ public abstract class BootBuildImage extends DefaultTask {
|
||||
return request;
|
||||
}
|
||||
|
||||
private BuildRequest customizeApplicationDirectory(BuildRequest request) {
|
||||
String applicationDirectory = getApplicationDirectory().getOrNull();
|
||||
if (applicationDirectory != null) {
|
||||
return request.withApplicationDirectory(applicationDirectory);
|
||||
}
|
||||
return request;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user