Until you run Quarkus and run docker image on Amazon ECS

Another site

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.

Prerequisites

--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

New project

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"

Implementation

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

Deploy to AWS side

Now that you have created a docker image, you can even deploy it to AWS ECS.

ECR creation

Create a new repository with the name "quarkus"

Image push

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

Task creation

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

570dbdee79d13c11f76eb76746411c12.jpg

462c242304492b7be7726ee289ea0451.jpg

4b566c405019460beb9fc6ea122a3293.jpg

Cluster creation

Choose to create a cluster Create with EC2 by freely selecting the instance type, number of instances, etc. Matsu until EC2 becomes active a9d948c74ad61c6ba18018c1f59b8730.jpg

Task execution

Select Run Task from the Tasks tab to run 10208d5eaa7026ca42782fa2915af10d.jpg

Wait for a while and it will become RUNNING 670d7cf11665e5b5b8a996b5d126f51c.jpg

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

Connection confirmation

Seen from the browser

http://[EC2 public DNS]/hello/greeting/quarkus

69be9989a2ab0cf1959a48784034d466.jpg

It was displayed!

Impressions

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

Until you run Quarkus and run docker image on Amazon ECS
Until you run apache on ubuntu on docker
Until you run CuPy (v11.1) on Ubuntu 20.04
Enable Docker build cache on GitHub Action and deploy to Amazon ECS
Run phpunit on Docker
Until you try running Apache Kafka with docker image
Run Rubocop and RSpec on CircleCI and deploy to ECS
Ssh to Ubuntu on VirtualBox on your Mac and do it until you install Docker
Until you start nginx on CentOS using Docker on Mac OS
Run VS Code on Docker
Run openvpn on Docker (windows)
Until you build the docker environment and start / stop the Ubuntu container
Create a Docker Image for redoc-cli and register it on Docker Hub
[GCP] Until you push the local Docker image to the Container Registry
Run (provisionally) a Docker image with ShellCommandActivity on AWS Data Pipeline
Install openjdk8 on Docker image (Debian)
Run lambda with custom docker image
Steps to run docker on Mac
Run puppeteer-core on Heroku (Docker edition)
Run React on a Docker container
Run the AWS CLI on Docker
How to run JavaFX on Docker
Run GUI application on Docker container
Deploy Flask's Docker image on Heroku
Run PureScript on a Docker container
2. Create Docker image and register Registry
If you get stuck with PHPStorm and xdebug on docker. trouble shooting
Publish Docker Image on GitHub Package Registry
Install docker and docker-compose on Alpine Linux
Customize OpenFOAM v8 Docker Image on Mac
Run NordVPN on Docker (Windows) Ubuntu container
Run Embulk on Docker to convert files
Let's run Servlet on Amazon Corretto now
Run SystemSpec (RSpec) and Rubocop on CircleCI
Try the Docker environment on AWS ECS
Run Ubuntu + ROS with Docker on Mac
Run Docker environment Rails MySQL on Heroku. devise and hiding the twitter API
If you have trouble uploading Wordpress image files with KUSANAGI Runs on Docker