From e2d1a9144b2fd29c2d0cad4e4470ab9a93cbcf9b Mon Sep 17 00:00:00 2001 From: Mirco Date: Thu, 11 Jul 2024 21:36:24 +0200 Subject: [PATCH] [skip ci] Dockerize section, how to handle different Dockerfile stages --- doc/dev_notes.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/doc/dev_notes.md b/doc/dev_notes.md index 5024faf..8697cbc 100644 --- a/doc/dev_notes.md +++ b/doc/dev_notes.md @@ -39,6 +39,43 @@ build graalvm binary curl -X GET localhost:8080 2. graalvm native-image compilation ./gradlew nativeCompile -Dvaadin.productionMode=true //-H:ConfigurationFileDirectories=/path/to/config-dir/ notwendig falls nicht in src/main/resources/META-INF/native-image/ +``` + +``` +Dockerizing -> image/Dockerfile + +install buildx-plugin by binary to use build-native-stage only with DOCKER_BUILDKIT: +- https://github.com/docker/buildx/releases/download/v0.15.1/buildx-v0.15.1.linux-amd64 +- sha256sum buildx-v0.15.1.linux-amd64 +- move to file: mv buildx-v0.15.1.linux-amd64 $HOME/.docker/cli-plugins/docker-buildx +- chmod x $HOME/.docker/cli-plugins/docker-buildx + +further: + It could be either build jar file or graalvm binary + + (1)build-jar-stage + docker build --tag=meapp-jar --target=build-jar-stage . + (2)ENTRYPOINT as run-jar-stage + docker build --tag=run-meapp-jar --target=run-jar-stage + + (3)build-native-stage + DOCKER_BUILDKIT=1 docker build --tag=meapp-native --target= build-native-stage . + (4)ENTRYPOINT as run-native-stage + DOCKER_BUILDKIT=1 docker build --tag=meapp-run-native --target=run-native-stage . + +Test images: + docker run -e MEMBERNAMES=er,sie,es -p 8080:8080 run-jar-stage:latest + docker run -e MEMBERNAMES=er,sie,es -p 8080:8080 run-native-stage:latest + +Buildkit caching: + export DOCKER_BUILDKIT=1 + --build-arg BUILDKIT_INLINE_CACHE=1 + (1)docker build --tag=meapp-jar --target=build-jar-stage --build-arg BUILDKIT_INLINE_CACHE=1 . + (2)docker build --tag=meapp-run-jar --target=run-jar-stage --build-arg BUILDKIT_INLINE_CACHE=1 . + (3)docker build --tag=meapp-native --target=build-native-stage --build-arg BUILDKIT_INLINE_CACHE=1 . + (4)docker build --tag=meapp-run-native --target=run-native-stage --build-arg BUILDKIT_INLINE_CACHE=1 . + + ```