forked from unikraft/catalog
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(examples): Introduce Hello in Java as example
Introduce a Hello Java program as binary compatibility run. Install Java and build program using `Dockerfile`. Then run it with the `base` kernel images from `../../kernels/`. Add typical files for a bincompat app: * `Kraftfile`: build / run rules, including pulling the `base` image * `Dockerfile`: filesystem, including binary and libraries * `Makefile`: used to generate the root filesystem from the `Dockerfile` rules * `README.md`: instructions to set up, build and run the application * `config.yaml`: configuration file to generate scripts to the application * `Hello.java`: the Java program `config.yaml` is used to generate run scripts using the `../../utils/bincompat/generate.py` script. The kernels in `../../kernels` are generated by running the `../../utils/bincompat/base-build-all.sh` script while inside the `../../library/base/` directory. Signed-off-by: Razvan Deaconescu <[email protected]>
- Loading branch information
Showing
7 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/rootfs/ | ||
/rootfs.cpio | ||
/run-qemu* | ||
/run-fc* | ||
/kraft-run-* | ||
/fc*.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
FROM --platform=linux/x86_64 debian:bookworm AS build | ||
|
||
RUN set -xe ; \ | ||
apt -yqq update ; \ | ||
apt -yqq install default-jre ; \ | ||
apt -yqq install default-jdk | ||
|
||
WORKDIR /src | ||
|
||
COPY ./Hello.java /src/Hello.java | ||
|
||
RUN javac Hello.java | ||
|
||
FROM scratch | ||
|
||
COPY --from=build /lib/x86_64-linux-gnu/libc.so.6 /lib/x86_64-linux-gnu/libc.so.6 | ||
COPY --from=build /lib/x86_64-linux-gnu/libstdc++.so.6 /lib/x86_64-linux-gnu/libstdc++.so.6 | ||
COPY --from=build /lib/x86_64-linux-gnu/libm.so.6 /lib/x86_64-linux-gnu/libm.so.6 | ||
COPY --from=build /usr/lib/x86_64-linux-gnu/libz.so.1 /usr/lib/x86_64-linux-gnu/libz.so.1 | ||
COPY --from=build /lib/x86_64-linux-gnu/libgcc_s.so.1 /lib/x86_64-linux-gnu/libgcc_s.so.1 | ||
COPY --from=build /lib64/ld-linux-x86-64.so.2 /lib64/ld-linux-x86-64.so.2 | ||
|
||
COPY --from=build /usr/lib/jvm/java-17-openjdk-amd64 /usr/lib/jvm/java-17-openjdk-amd64 | ||
COPY --from=build /usr/lib/jvm/java-17-openjdk-amd64/lib/libjli.so /lib/x86_64-linux-gnu/libjli.so | ||
|
||
COPY --from=build /src/Hello.class /Hello.class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
public class Hello { | ||
public static void main(String[] args) { | ||
System.out.println("Hello, World!"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
spec: v0.6 | ||
|
||
name: hello-java | ||
|
||
runtime: index.unikraft.io/unikraft.org/base:latest | ||
|
||
rootfs: ./Dockerfile | ||
|
||
cmd: ["/usr/lib/jvm/java-17-openjdk-amd64/bin/java", "Hello"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
IMAGE_NAME = unikraft-java | ||
CMD = /usr/lib/jvm/java-17-openjdk-amd64/bin/java Hello | ||
|
||
include ../../utils/bincompat/docker.Makefile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Hello World on Java | ||
|
||
This directory contains the definition to run a helloworld program with [Python3](https://www.python.org/) on Unikraft in binary compatibility mode. | ||
|
||
Follow the instructions in the common `README.maintainers.md` file in the root of the repository to set up and configure the application. | ||
|
||
## Quick Run | ||
|
||
Use `kraft` to run the image: | ||
|
||
```console | ||
kraft run -M 512M | ||
``` | ||
|
||
Once executed, it will run the `helloworld.py` script and print "Hello, World!". | ||
|
||
## Scripted Run | ||
|
||
Use the scripted runs, detailed in the `README.maintainers.md` file. | ||
Once executed, scripts will run the `helloworld.py` script and print "Hello, World!". |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
networking: False | ||
accel: True | ||
memory: 1048 | ||
kerneldir: ../../kernels |