Giter VIP home page Giter VIP logo

java-example-application's Introduction

Java Example application

Java 8 example application.

  • Spring boot v2.3.8
  • Java 8 (OpenJDK)
  • Dependencies:
    • spring-boot-starter-actuator
    • spring-boot-starter-web
    • spring-boot-starter-test
    • micrometer-registry-prometheus
  • Graceful shutdown
  • Liveness&Readiness probes
  • Actuator endpoints enabled:
    • health
    • info
    • env
    • loggers
    • metrics
    • prometheus
  • Standardized, layered Dockerfile
  • standardized configuration management:
    • configurations under src/main/resources/application.yaml
    • You can choose a profile using the environment variable ACTIVE_PROFILES.
  • The container is run with the user app (UID 1000, GID 1000) to avoid the root user

Docker Image Build

The Dockerfile specifies how the image is created. This file creates a layered image, click here for more info. The base image is eclipse-temurin:8u342-b07-jre-focal.

Docker entrypoint bin/docker-entrypoint.sh.

Docker build command docker build -t <tag> .

Actuator

Spring Boot Actuator enabled on src/main/resources/application.properties:

management.endpoints.web.exposure.include = health, info, env, loggers, metrics, prometheus, configprops

Connect to a Database

You can connect a MySQL database by activating the spring profile db. The environment variable is ACTIVE_PROFILES=db. In the default behaviour, no database is connected. You can also set other environment variables:

DB_URL default value localhost:3306

DB_USER default value user

DB_PASSWORD default value password

Rest Interface

The application exposes the default context path /test-app/v1.

The class TestController exposes some test endpoints.

For example, you can get the instance id calling GET localhost:8080/test-app/v1/app/id

AWSCodeBuild

You can build this project with AWSCodeBuild. The configuration file under the root directory is buildspec.yml. This file builds the maven project and uploads a docker image to Elastic Container Registry.

Remember to define your Elastic Container Registry parameters AWS_DEFAULT_REGION,AWS_ACCOUNT_ID,AWS_DEFAULT_REGION,IMAGE_TAG.

java-example-application's People

Contributors

ivanopassari avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.