ModeratorElection/doc/dev_notes.md

4.6 KiB
Raw Blame History

ToDo

HowTo BUILD jar?

Failed within local: ./gradle build
java -jar build/libs/ModeratorElection.jar -> localhost:6333 "White Label..."-Error

=> ./gradlew clean build -Pvaadin.productionMode
..in ide dev: ./gradlew clean vaadinPrepareFrontend
-x processTestAot - exclude, skip tests

https://docs.spring.io/spring-boot/gradle-plugin/aot.html
Processing Tests
The AOT engine can be applied to JUnit 5 tests that use Springs Test Context Framework. 
Suitable tests are processed by the 'processTestAot' task to generate 
'ApplicationContextInitializer' code. As with application AOT processing, the 'BeanFactory' 
is fully prepared at build-time. As with 'processAot', the 'processTestAot' task is 'JavaExec' 
subclass and can be configured as needed to influence this processing.
The 'nativeTest' task of the GraalVM Native Image plugin is automatically configured to 
use the output of the 'processAot' and 'processTestAot' tasks.
For production:
* install.sh 
    git clone --single-branch --branch main https://repo.prod.meissa.de/meissa/ModeratorElection.git /usr/local/src/ModeratorElection
     
build graalvm binary
1. First build jar locally, and get META-INF with   
    ./gradlew clean build -Pvaadin.productionMode -x processTestAot
    MEMBERNAMES=er,sie,es java -agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image -jar build/libs/ModeratorElection-0.0.1-SNAPSHOT.jar 
    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 .



gu available
https://docs.oracle.com/en/graalvm/enterprise/21/docs/reference-manual/graalvm-updater/#component-installation
vaadin 24.3.3, after npm audit fix during image build: 
npm warn deprecated workbox-google-analytics@7.0.0: It is not compatible with newer versions of GA starting with v4, as long as you are using GAv3 it should be ok, but the package is not longer being maintained  
npm warn deprecated sourcemap-codec@1.4.8: Please use @jridgewell/sourcemap-codec instead  
npm warn deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.  
npm warn deprecated rollup-plugin-terser@7.0.2: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-terser  
npm warn deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported
Refresh, Singleton Issue
https://github.com/vaadin/flow/issues/9376
https://mvysny.github.io/cant-move-node/
https://vaadin.com/forum/t/unregistered-node-was-not-found-based-on-its-id-the-tree-is-most-likely-co/161068
https://vaadin.com/docs/v14/flow/integrations/spring/tutorial-spring-scopes
    => @PreserveOnRefresh annotation in MainView.java does the trick
ddadevops anpassung, dass src code ins docker image übergeben werden kann - ohne git clone