igorzg / payara-micro-docker-starter-kit

Java ee microservices starter-kit with payara-micro and docker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Java EE micro service starter kit with docker, payara micro, arquillian on AWS Cloud

  • This is complete example how to setup java ee ready for micro service AWS Cloud deployment with AWS elastic beanstalk and AWS Code pipeline via AWS Code Build

Requirements:

  1. JDK 1.8
  2. Gradle 3.x
  3. Docker
  4. AWS Cli

Setting up properties

Before changing properties you need to setup:

  • AWS IAM user account with Elastic Beanstalk / EC2 Container read write permissions.
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "s3:PutObject",
                "s3:GetObject",
                "s3:ListBucket",
                "s3:GetObjectVersion"
            ],
            "Resource": "arn:aws:s3:::elasticbeanstalk-*"
        },
        {
            "Sid": "VisualEditor1",
            "Effect": "Allow",
            "Action": [
                "ecr:GetDownloadUrlForLayer",
                "ecr:GetAuthorizationToken",
                "ecr:UploadLayerPart",
                "elasticbeanstalk:CreateApplicationVersion",
                "ecr:ListImages",
                "ecr:PutImage",
                "ecr:BatchGetImage",
                "ecr:CompleteLayerUpload",
                "ecr:DescribeImages",
                "elasticbeanstalk:DescribeApplicationVersions",
                "ecr:DescribeRepositories",
                "ecr:InitiateLayerUpload",
                "ecr:BatchCheckLayerAvailability",
                "ecr:GetRepositoryPolicy"
            ],
            "Resource": "*"
        }
    ]
}
  • EC2 Container Registry and Elastic Beanstalk Single environment application with docker engine

Change aws config in gradle.properties:

groupName=icoder
awsECRName=YOUR_EC_REPOSITORY_NAME
awsId=YOUR_AWS_ID
awsEBSApp=YOUR_ELASTIC_BEANSTALK_APPLICATION_NAME
awsRegion=eu-central-1

Building project

gradle clean build -Penv=local

Starting embedded server

Server will be running on default port 8080

gradle startServer

Starting unit tests:

gradle test

Starting integration test with arquillian:

Before tests docker compose hast to be started because you may need an local data store which you can run in docker.

Run compose once:

gradle dockerCompose

Then start tests:

gradle itest

Starting/stopping docker server

gradle startDocker
gradle stopDoker

Publishing to ecr repository

This command creates elastic beanstalk application deployment version and publish baked container to EC2 Container Repository:

gradle clean publishToECR -Penv=prod 

Example running apps manually:

You can simply run them as jar applications or you can configure your ide to run jar application so you can debug it.

gradle build -Penv=local
java -jar ./pajara-micro.jar --deploy ./build/libs/starter-1.0.0.war

note if you did not download payara micro run

gradle downloadPayaraMicro

About

Java ee microservices starter-kit with payara-micro and docker

License:MIT License


Languages

Language:Java 100.0%