From a5d1da404ec96973dd2bbfee1b044148b163b029 Mon Sep 17 00:00:00 2001 From: Public copy <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 6 Dec 2024 21:41:42 +0000 Subject: [PATCH] automated commit Signed-off-by: Public copy <41898282+github-actions[bot]@users.noreply.github.com> --- images/gradle/README.md | 73 ++++++++++++++++++++++++++----------- images/gradle/metadata.yaml | 2 +- images/jre/config/main.tf | 6 ++- 3 files changed, 58 insertions(+), 23 deletions(-) diff --git a/images/gradle/README.md b/images/gradle/README.md index f3ffb4a10..5c0e0327b 100644 --- a/images/gradle/README.md +++ b/images/gradle/README.md @@ -15,7 +15,7 @@ # Chainguard Image for gradle -Minimal image with [Gradle](https://gradle.org/) build system. +Chainguard Image with [Gradle](https://gradle.org/), an open source build system for Java, Android, and Kotlin. Chainguard Images are regularly-updated, minimal container images with low-to-zero CVEs. @@ -32,37 +32,68 @@ Be sure to replace the `ORGANIZATION` placeholder with the name used for your or -## Using gradle +## Compatibility Notes -Chainguard gradle images come with different versions of OpenJDK, ensure you choose the correct image tag for your application needs. In these examples we will use a Chainguard gradle image based on OpenJDK 11. +Chainguard's Gradle image is comparable to the [official Gradle image on Docker Hub](https://hub.docker.com/_/gradle). Like most other Chainguard images, the Gradle image has few-to-zero CVEs and does not run as the root user. Additionally, the Chainguard Gradle image's default entrypoint is `/usr/bin/gradle`. -__NOTE__: if you are running Docker on Mac M1 you may experience intermittent container high CPU and container / JVM crashes. There have been [reports](https://github.com/metanorma/metanorma-docker/issues/126) of this behaviour and also affects non Chainguard images. It is expected that using `arm` based images will address the problem which is in development for Chainguard images. When running the examples below you might experince gradle builds hanging. If you do, you can `docker ps` and `docker kill $PID` and retry. This is not an ideal experience and will be improved. +## Getting Started -Check the gradle version +Chainguard Gradle images come with different versions of OpenJDK; ensure you choose the correct image tag for your application needs. + +> [!NOTE] +> If you are running Docker on Mac M1 you may experience intermittent container high CPU and container / JVM crashes. There have been [reports](https://github.com/metanorma/metanorma-docker/issues/126) of this behavior, which is known to also affect non-Chainguard images. It is expected that using ARM based images, which are in development for Chainguard images, will address the problem. When running the examples below you might experience Gradle builds hanging. If you do, you can `docker ps` and `docker kill $PID` and retry. + +To use the Chainguard Gradle image with Docker, run commands that follow this syntax: + +```shell +docker run cgr.dev/chainguard/gradle:latest-dev +``` + +For example, to run an existing project you have on your local machine, you could run a command like the following: + +```shell +docker run -v "${PWD}":/home/build/project -w /home/build/project cgr.dev/chainguard/gradle:latest run +``` + +To show the Gradle image building and running a sample application, we will use the `latest-dev` variant of the image, which includes a shell. + +First, run the image with the `-it` and `entrypoint=/bin/sh` arguments to access the shell: + +```shell +docker run -it --entrypoint=/bin/sh cgr.dev/chainguard/gradle:latest-dev +``` + +From within the container, run the `init` task to build a `Hello World!` example application: + +``` +gradle init --type java-application --use-defaults ``` - % docker run gradle --version -Welcome to Gradle 8.0.1-20230224000000+0000! +This example specifies that the `init` task should build a Java application with the default settings. -Here are the highlights of this release: - - Improvements to the Kotlin DSL - - Fine-grained parallelism from the first build with configuration cache - - Configurable Gradle user home cache cleanup +``` +. . . +BUILD SUCCESSFUL in 3s +``` ------------------------------------------------------------- -Gradle 8.0.1-20230224000000+0000 ------------------------------------------------------------- +Then, use the `run` task to run the newly built application: -Build time: 2023-02-24 00:00:00 UTC -Revision: 68959bf76cef4d28c678f2e2085ee84e8647b77a +``` +gradle run +``` +``` +. . . -Kotlin: 1.8.10 -Groovy: 3.0.13 -Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021 -JVM: 11.0.18-internal (wolfi 11.0.18-internal+0-wolfi-r1) -OS: Linux 5.15.49-linuxkit aarch64 +> Task :app:run +Hello World! ``` + + +## Documentation and Resources + +* [Gradle User Manual](https://docs.gradle.org/current/userguide/userguide.html) +* [Gradle Build Tool GitHub Repository](https://github.com/gradle/gradle) ## Contact Support diff --git a/images/gradle/metadata.yaml b/images/gradle/metadata.yaml index 5b5156708..82483c89b 100644 --- a/images/gradle/metadata.yaml +++ b/images/gradle/metadata.yaml @@ -3,7 +3,7 @@ image: cgr.dev/chainguard/gradle logo: https://storage.googleapis.com/chainguard-academy/logos/gradle.svg endoflife: "" console_summary: "" -short_description: Minimal image with [Gradle](https://gradle.org/) build system. +short_description: Chainguard Image with [Gradle](https://gradle.org/), an open source build system for Java, Android, and Kotlin. compatibility_notes: "" readme_file: README.md upstream_url: https://github.com/gradle/gradle diff --git a/images/jre/config/main.tf b/images/jre/config/main.tf index deed9a04b..88ee7eefd 100644 --- a/images/jre/config/main.tf +++ b/images/jre/config/main.tf @@ -12,6 +12,10 @@ variable "environment" { default = {} } +variable "entrypoint-command" { + default = "/usr/bin/java" +} + module "accts" { source = "../../../tflib/accts" run-as = var.run-as @@ -33,7 +37,7 @@ output "config" { "JAVA_HOME" : "/usr/lib/jvm/default-jvm" }, var.environment) entrypoint = { - command = "/usr/bin/java" + command = var.entrypoint-command } }) }