There are more opportunities to run applications on Docker containers. Startup time is important when operating in a container. When running Java, it runs on the JVM, but it takes some time to start this JVM.
Quarkus introduced this time is a framework that realizes fast startup by creating a binary for native using GraalVM.
--Java 8 and above --Maven 3.5.3 and above
From here graalvm-ce-1.0.0-rc13-macos-amd64.tar.gz Please download (as of March 12, 2019).
Unzip it and put the whole folder in / Library / Java / JavaVirtualMachines.
Set the GraalVM environment variable (GRAALVM_HOME).
.bash_profile
GRAALVM_HOME=/Library/Java/JavaVirtualMachines/graalvm-ce-1.0.0-rc13-macos-amd64/Contents/Home
$ mvn io.quarkus:quarkus-maven-plugin:0.11.0:create \
-DprojectGroupId=jp.acme \
-DprojectArtifactId=getting-started \
-DclassName="org.acme.quickstart.GreetingResource" \
-Dpath="/hello"
Executing the above command will create a Maven project as shown below.
#Start in development mode
$ mvn compile quarkus:dev
Hot reload can be achieved by booting in development mode. Check the operation with the following command.
$ curl http://localhost:8080/hello
$ mvn package -Pnative -Dnative-image.docker-build=true
option | Contents |
---|---|
-Pnative | Specify when generating a natively executable binary |
-Dnative-image.docker-build=true | Specify when generating a native binary that matches the OS on Docker |
Since we want to start it on Docker this time, also specify `` -Dnative-image.docker-build = true```.
It will take some time to build, probably because it generates native binaries.
$ docker build -f src/main/docker/Dockerfile -t <Image name> .
$ docker run -i --rm -p 8080:8080 <Image name>
2019-03-12 01:29:01,328 INFO [io.quarkus](main) Quarkus 0.11.0 started in 0.004s. Listening on: http://0.0.0.0:8080
2019-03-12 01:29:01,328 INFO [io.quarkus](main) Installed features: [cdi, resteasy]
What you should pay attention to here is the startup time.
If you check the log after startup, it says `Quarkus 0.11.0 started in 0.004s`
.
In other words, you can see that it started in 0.004 seconds. It is early.
By using Quarkus, the application on the container starts up overwhelmingly faster. Quarkus itself has just come out, so I think it will be difficult to put it to practical use in production, but as development progresses and more information is available, I think there will be more opportunities for it to become practical. I'm looking forward to it in the future.
You can also add extensions to Quarkus. For example, the default is JavaEE standard CDI, but Spring-based CDI can be used. We will share information while investigating this area as well.
-QUARKUS (head family site) -Quarkus: Introducing a new method to launch Java apps at high speed on a container
Recommended Posts