I wrote it in, but it's over, so I moved to article 5 2019/03/16
Quarkus Java framework. As a feature, it generates a binary for native and starts up very quickly.
--Java 8 and above --Maven 3.5.3 and above
Seems to be
GraalVM Install GraalVM Set in .bash_profile etc.
export GRAALVM_HOME=[Installation folder]/Contents/Home
Execute project creation command according to the formula of Quarkus
mvn io.quarkus:quarkus-maven-plugin:0.11.0:create \
-DprojectGroupId=org.acme \
-DprojectArtifactId=getting-started \
-DclassName="org.acme.quickstart.GreetingResource" \
-Dpath="/hello"
Created according to the official start guide The source is included by default, so it works as it is Officially it says that we will add an API or something like this, so we will do it as it is It's important to understand the commands when moving
Local launch
mvn compile quarkus:dev
jar creation
mvn package
jar start
java -jar target/getting-started-1.0-SNAPSHOT-runner.jar
Native binary creation
mvn package -Pnative
Native binary launch
./target/quarkus-quickstart-runner
Container creation
mvn package -Pnative -Dnative-image.docker-build=true
docker build
docker build -f src/main/docker/Dockerfile -t quarkus .
run
docker run -i --rm -p 8080:8080 quarkus
It worked the same for local, jar, binary and docker
$ curl http://localhost:8080/hello/greeting/quarkus
hello quarkus
Now that you have created a docker image, you can even deploy it to AWS ECS.
Create a new repository with the name "quarkus"
Command execution according to "Display push command" of the created repository
aws ecr get-login --no-include-email --region ap-northeast-1
##A login command will be issued, so execute it as it is
##Tag the created image
docker tag quarkus:latest xxxxxxx.dkr.ecr.ap-northeast-1.amazonaws.com/quarkus:latest
## push
docker push xxxxxxx.dkr.ecr.ap-northeast-1.amazonaws.com/quarkus:latest
Success if pushed on ECR
Creating task definitions from ECS Created by entering what is defined in ECR in the image It may be good to play with EXPOSE in the Dockerfile, but it seems that the default is 8080. Port mapping is set at 80 80 80
Choose to create a cluster Create with EC2 by freely selecting the instance type, number of instances, etc. Matsu until EC2 becomes active
Select Run Task from the Tasks tab to run
Wait for a while and it will become RUNNING
Enter the instance with ssh and check Received at 80 and mapped to 8080
$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
29c1fb97dc07 xxxxxxx.dkr.ecr.ap-northeast-1.amazonaws.com/quarkus "./application -Dqua…" 9 seconds ago Up 8 seconds 0.0.0.0:80->8080/tcp ecs-quarkus-5-quarkus-e491bef2eefec1fcfc01
0187c98c619b amazon/amazon-ecs-agent:latest "/agent" About an hour ago Up About an hour ecs-agent
Seen from the browser
http://[EC2 public DNS]/hello/greeting/quarkus
It was displayed!
Quarkus started up so quickly that it felt like it was already running. I usually use Java, but I promised that it would take a long time to start, so it's quite fresh. ECS took some time to create at first, but I'm glad I managed to do it It was hard to get along with what a cluster or task was. .. .. After that, at the port mapping, if you do dynamic mapping at first, the port will shift and it will not work. .. .. When updating
--Write Java --Docker image creation --Push to ECR --Task definition (revision creation) in ECS --Update revision with service update
I wonder if it feels like
Recommended Posts