Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
5fc3526
implement containerization support for native image bundles
dominikmascherbauer Apr 18, 2023
b72e133
no output if container exists already, refactoring, check tool version
dominikmascherbauer Apr 18, 2023
89e1ba1
add and change bundle options
dominikmascherbauer Apr 18, 2023
d03923c
improve containerized bundle creation and writing, combine replacing …
dominikmascherbauer Apr 20, 2023
c922a31
remove image option for bundles and compute image name from hash
dominikmascherbauer Apr 25, 2023
9c0f571
Use SubstrateUtil.digest for generating Dockerfile hash
dominikmascherbauer Apr 27, 2023
bcbd2cb
Improve tool availability check
dominikmascherbauer Apr 27, 2023
9384123
Rework option parsing for extended bundle options
dominikmascherbauer Apr 27, 2023
5fa8b50
Extract common functionality for processes
dominikmascherbauer Apr 27, 2023
3eaf9d4
Adjust warning and info messages for container tools
dominikmascherbauer Apr 27, 2023
2bb166b
Update default dockerfile to ol8 based dockerfile
dominikmascherbauer Apr 27, 2023
6eb3f07
Fix missing bundlePath error on bundle-create
dominikmascherbauer May 2, 2023
fa08752
Pass environment variables to container
dominikmascherbauer May 3, 2023
69bc254
Add support for static builds in containers
dominikmascherbauer May 4, 2023
e9b0394
Quote mount calls and environment variables for containers to escape …
dominikmascherbauer May 4, 2023
d0b4b0a
Store default Dockerfiles as resource files
dominikmascherbauer May 20, 2023
9247431
Extract extended option parsing to separate function
dominikmascherbauer May 20, 2023
de4f98b
Use java.nio.file.Files#writeString
dominikmascherbauer May 20, 2023
31f8608
Use try-with-resource blocks for reading process results
dominikmascherbauer May 20, 2023
8e2b7a2
Fix style issues
dominikmascherbauer May 23, 2023
30bfb5c
Executable bundle first draft
dominikmascherbauer May 17, 2023
1690ddc
Add copyright header
dominikmascherbauer May 23, 2023
b9678ca
Fix environment variable sanitation on containerized builds
dominikmascherbauer May 24, 2023
95929be
Copy ConfigurationParser and JSONParser and adjust for bundle launcher
dominikmascherbauer May 24, 2023
4b3a02f
Parse bundle launcher commandline arguments
dominikmascherbauer May 25, 2023
906ce75
Fix crash on containerized dry-runs
dominikmascherbauer May 30, 2023
e81c0e2
Stricter checks for run json and add main class if no executable was …
dominikmascherbauer May 30, 2023
99dff39
Fix bundle launcher environment loading, make bundle launcher with na…
dominikmascherbauer Jun 1, 2023
a9efd76
Switch to allow list for run arguments
dominikmascherbauer Jun 1, 2023
f831509
Copy launcher class files from resources to bundle
dominikmascherbauer Jun 7, 2023
4da3052
Extract BundleSupport functionality to BundleLauncher
dominikmascherbauer Jun 7, 2023
5e26dd6
Fix executing bundles created with -jar and executing bundles with ad…
dominikmascherbauer Jun 12, 2023
0dd4244
Use Hosted options for creating run.json, Overwrite bundle launcher f…
dominikmascherbauer Jun 19, 2023
5b2992e
Always create a dockerfile for bundles
dominikmascherbauer Jun 19, 2023
be57ee2
Rework bundle launcher
dominikmascherbauer Jun 19, 2023
cf32db3
Add container support for executable bundles
dominikmascherbauer Jun 19, 2023
175ab88
Use ContainerSupport for building containerized native image bundles
dominikmascherbauer Jun 20, 2023
cfc34e1
Replace paths for containerized bundle execution inplace
dominikmascherbauer Jun 22, 2023
37ff3f9
Fix command creation for container bundle execution
dominikmascherbauer Jun 22, 2023
a9f2eb4
Refactoring for containerized builds, Adjust access modifier, Fix ski…
dominikmascherbauer Jul 4, 2023
efbe842
Add GPL License Header for Dockerfiles
dominikmascherbauer Jul 5, 2023
1e9fadc
Fix style issues
dominikmascherbauer Jul 5, 2023
d36d481
Fix style issue
dominikmascherbauer Jul 5, 2023
f46ad7b
Fix formatting issues
dominikmascherbauer Jul 5, 2023
1f81353
Update help-extra with extended bundle options
dominikmascherbauer Jul 6, 2023
d0f86cb
Add help text for bundle launcher
dominikmascherbauer Jul 6, 2023
854a608
Add launcher option tags for APIOption Annotation
dominikmascherbauer Jul 19, 2023
6a5a431
Use launcherOption tag to collect arguments for executing a bundle wi…
dominikmascherbauer Jul 19, 2023
186f0c6
Tweak launcher option parsing
dominikmascherbauer Jul 19, 2023
613e9ae
Force containerized bundle build if bundled native image was built in…
dominikmascherbauer Jul 19, 2023
7da5063
Fix muslc containerized builds, Rename forceContainerBuild
dominikmascherbauer Jul 19, 2023
a8212d7
Tweak launcher option parsing
dominikmascherbauer Jul 19, 2023
5b50e02
Fix style issues and build error
dominikmascherbauer Jul 20, 2023
6e70a31
Fix logging errors
dominikmascherbauer Jul 24, 2023
1dbe52a
Suppress checkstyle rule for custom log messages in bundle launcher
dominikmascherbauer Jul 24, 2023
1198a04
Fix bundle launcher help text
dominikmascherbauer Aug 9, 2023
afe057a
Update Bundles.md with description of new features
dominikmascherbauer Aug 9, 2023
77968a8
Fix typos in bundle documentation
dominikmascherbauer Aug 9, 2023
cb9a248
Update CHANGELOG.md with new features
dominikmascherbauer Aug 9, 2023
18e33cf
Bugfixes
dominikmascherbauer Aug 11, 2023
4ee078e
Parse extended options with constant strings
dominikmascherbauer Aug 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
170 changes: 153 additions & 17 deletions docs/reference-manual/native-image/Bundles.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions substratevm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ This changelog summarizes major changes to GraalVM Native Image.
* (GR-46740) Add support for foreign downcalls (part of "Project Panama") on the AMD64 platform.
* (GR-27034) Add `-H:ImageBuildID` option to generate Image Build ID, which is a 128-bit UUID string generated randomly, once per bundle or digest of input args when bundles are not used.
* (GR-47647) Add `-H:±UnlockExperimentalVMOptions` for unlocking access to experimental options similar to HotSpot's `-XX:UnlockExperimentalVMOptions`. Explicit unlocking will be required in a future release, which can be tested with the env setting `NATIVE_IMAGE_EXPERIMENTAL_OPTIONS_ARE_FATAL=true`. For more details, see [issue #7105](https://github.com/oracle/graal/issues/7105).
* (GR-43920) Add support for executing native image bundles as jar files with extra options `--with-native-image-agent` and `--container`.
* (GR-43920) Add `,container[=<container-tool>]`, `,dockerfile=<dockerfile>` and `,dry-run` options to `--bundle-create`and `--bundle-apply`.

## GraalVM for JDK 17 and GraalVM for JDK 20 (Internal Version 23.0.0)
* (GR-40187) Report invalid use of SVM specific classes on image class- or module-path as error. As a temporary workaround, `-H:+AllowDeprecatedBuilderClassesOnImageClasspath` allows turning the error into a warning.
Expand Down
1 change: 1 addition & 0 deletions substratevm/mx.substratevm/mx_substratevm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,7 @@ def _native_image_launcher_extra_jvm_args():
'--features=com.oracle.svm.driver.APIOptionFeature',
'--initialize-at-build-time=com.oracle.svm.driver',
'--link-at-build-time=com.oracle.svm.driver,com.oracle.svm.driver.metainf',
'-H:IncludeResources=com/oracle/svm/driver/launcher/.*',
] + svm_experimental_options([
'-H:-ParseRuntimeOptions',
])
Expand Down
19 changes: 19 additions & 0 deletions substratevm/mx.substratevm/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,7 @@
],
"dependencies": [
"com.oracle.svm.hosted",
"com.oracle.svm.driver.launcher",
],
"requires" : [
"jdk.management",
Expand All @@ -857,6 +858,23 @@
"jacoco" : "exclude",
},

"com.oracle.svm.driver.launcher": {
"subDir": "src",
"sourceDirs": [
"src",
"resources"
],
"checkstyle": "com.oracle.svm.hosted",
"workingSets": "SVM",
"annotationProcessors": [
"compiler:GRAAL_PROCESSOR",
"SVM_PROCESSOR",
],
"javaCompliance" : "17+",
"spotbugs": "false",
"jacoco" : "exclude",
},

"com.oracle.svm.junit": {
"subDir": "src",
"sourceDirs": [
Expand Down Expand Up @@ -1690,6 +1708,7 @@
"mainClass": "com.oracle.svm.driver.NativeImage",
"dependencies": [
"com.oracle.svm.driver",
"com.oracle.svm.driver.launcher",
"svm-compiler-flags-builder",
],
"distDependencies": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ public class NativeImageClassLoaderOptions {

public static final String AddReadsFormat = "<module>=<target-module>(,<target-module>)*";

@APIOption(name = "add-exports", extra = true, valueSeparator = {APIOption.WHITESPACE_SEPARATOR, '='})//
@APIOption(name = "add-exports", extra = true, launcherOption = true, valueSeparator = {APIOption.WHITESPACE_SEPARATOR, '='})//
@Option(help = "Value " + AddExportsAndOpensFormat + " updates <module> to export <package> to <target-module>, regardless of module declaration." +
" <target-module> can be ALL-UNNAMED to export to all unnamed modules.")//
public static final HostedOptionKey<LocatableMultiOptionValue.Strings> AddExports = new HostedOptionKey<>(LocatableMultiOptionValue.Strings.build());

@APIOption(name = "add-opens", extra = true, valueSeparator = {APIOption.WHITESPACE_SEPARATOR, '='})//
@APIOption(name = "add-opens", extra = true, launcherOption = true, valueSeparator = {APIOption.WHITESPACE_SEPARATOR, '='})//
@Option(help = "Value " + AddExportsAndOpensFormat + " updates <module> to open <package> to <target-module>, regardless of module declaration.")//
public static final HostedOptionKey<LocatableMultiOptionValue.Strings> AddOpens = new HostedOptionKey<>(LocatableMultiOptionValue.Strings.build());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,16 @@ public static class Options {

private static final char VALUE_SEPARATOR = ':';

@APIOption(name = {"-ea", "-enableassertions"}, valueSeparator = VALUE_SEPARATOR, valueTransformer = RuntimeAssertionsOptionTransformer.Enable.class, defaultValue = "", //
@APIOption(name = {"-ea", "-enableassertions"}, launcherOption = true, valueSeparator = VALUE_SEPARATOR, valueTransformer = RuntimeAssertionsOptionTransformer.Enable.class, defaultValue = "", //
customHelp = "also -ea[:[packagename]...|:classname] or -enableassertions[:[packagename]...|:classname]. Enable assertions with specified granularity at run time.")//
@APIOption(name = {"-da", "-disableassertions"}, valueSeparator = VALUE_SEPARATOR, valueTransformer = RuntimeAssertionsOptionTransformer.Disable.class, defaultValue = "", //
@APIOption(name = {"-da",
"-disableassertions"}, launcherOption = true, valueSeparator = VALUE_SEPARATOR, valueTransformer = RuntimeAssertionsOptionTransformer.Disable.class, defaultValue = "", //
customHelp = "also -da[:[packagename]...|:classname] or -disableassertions[:[packagename]...|:classname]. Disable assertions with specified granularity at run time.")//
@Option(help = "Enable or disable Java assert statements at run time") //
public static final HostedOptionKey<LocatableMultiOptionValue.Strings> RuntimeAssertions = new HostedOptionKey<>(LocatableMultiOptionValue.Strings.build());

@APIOption(name = {"-esa", "-enablesystemassertions"}, customHelp = "also -enablesystemassertions. Enables assertions in all system classes at run time.") //
@APIOption(name = {"-dsa", "-disablesystemassertions"}, kind = APIOption.APIOptionKind.Negated, //
@APIOption(name = {"-esa", "-enablesystemassertions"}, launcherOption = true, customHelp = "also -enablesystemassertions. Enables assertions in all system classes at run time.") //
@APIOption(name = {"-dsa", "-disablesystemassertions"}, launcherOption = true, kind = APIOption.APIOptionKind.Negated, //
customHelp = "also -disablesystemassertions. Disables assertions in all system classes at run time.") //
@Option(help = "Enable or disable Java system assertions at run time") //
public static final HostedOptionKey<Boolean> RuntimeSystemAssertions = new HostedOptionKey<>(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,26 @@ public static boolean parseOnce() {
@Option(help = "Build statically linked executable (requires static libc and zlib)")//
public static final HostedOptionKey<Boolean> StaticExecutable = new HostedOptionKey<>(false);

@APIOption(name = "libc")//
@Option(help = "Selects the libc implementation to use. Available implementations: glibc, musl, bionic")//
public static final HostedOptionKey<String> UseLibC = new HostedOptionKey<>(null) {
@Override
public String getValueOrDefault(UnmodifiableEconomicMap<OptionKey<?>, Object> values) {
if (!values.containsKey(this)) {
return Platform.includedIn(Platform.ANDROID.class)
? "bionic"
: System.getProperty("substratevm.HostLibC", "glibc");
}
return (String) values.get(this);
}

@Override
public String getValue(OptionValues values) {
assert checkDescriptorExists();
return getValueOrDefault(values.getMap());
}
};

@APIOption(name = "target")//
@Option(help = "Selects native-image compilation target (in <OS>-<architecture> format). Defaults to host's OS-architecture pair.")//
public static final HostedOptionKey<String> TargetPlatform = new HostedOptionKey<>("") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@
*/
boolean extra() default false;

/**
* This option should be stored in a native image bundle and passed to the jvm when executed
* with {@code com.oracle.svm.driver.launcher.BundleLauncher}.
*/
boolean launcherOption() default false;

/**
* Make a boolean option part of a group of boolean options.
**/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
This native image bundle can be used to launch the bundled application.

Usage: java -jar bundle-file [options] [bundle-application-options]

where options include:

--with-native-image-agent[,update-bundle[=<new-bundle-name>]]
runs the application with a native-image-agent attached
'update-bundle' adds the agents output to the bundle-files classpath.
'=<new-bundle-name>' creates a new bundle with the agent output instead.
Note 'update-bundle' requires native-image to be installed

--container[=<container-tool>][,dockerfile=<Dockerfile>]
sets up a container image for execution and executes the bundled application
from inside that container. Requires podman or rootless docker to be installed.
If available, 'podman' is preferred and rootless 'docker' is the fallback. Specifying
one or the other as '=<container-tool>' forces the use of a specific tool.
'dockerfile=<Dockerfile>': Use a user-provided 'Dockerfile' instead of the Dockerfile
bundled with the application

--verbose enable verbose output
--help print this help message
Loading