yuuki1967 / bookstore_v3

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Demo Bookstore v3

This is a simple Maven project that builds a standalone JAR which contains a Jetty webserver and a simple bookstore servlet. The application is able to be built into a container and then available to be deployed as an Azure Web App.

bookstore

The Workflow files in this repository provide the following features:

  • Pull Requests code is built and tested using Maven and a Docker container published
  • Code QL scanning performed on each push
  • Each time a container is built, scanning of the containers will be performed and reported back in the security findings
  • Ability to deploy from a PR into review environment using labels:
    • deploy to test
    • deploy to qa
    • deploy to staging
  • Azure review environments are destroyed once PR is closed (using Ansible triggered from deployment transitions)
  • Any commit to the default branch main will result in the prod Azure web application being updated to the latest code (Continuous Delivery)

For a step-by-step guide see: Bookstore Demo

Running the Web Application locally

You can run the web application locally using Maven for development purposes, which can be done either directly if you have Maven and a JDK installed, or inside a container that has Maven and JDK installed.

GitHub Codespaces

This repository is configured with GitHub Codespaces to make it easy to start with a development environment fully configured.

The container used for the development environment is available from https://github.com/octodemo/container-java-development and is publically available. There are multiple versions of this, all with the tags providing a specific combination of tools for various cloud vendors. By default you will get a container with:

  • Maven 3.6.3 or later
  • JDK 11
  • Azure CLI tools

Running locally:

To build the software run the following command:

$ mvn package

This will generate a jar file at target/bookstore-v2-1.0.0-SNAPSHOT.jar directory that when run with the command java -jar target/bookstore-v2-1.0.0-SNAPSHOT.jar will run the jetty web server. The logs from the jar file should report the url to access the web server on, which is port 8080 by default.

Running in a Docker container:

The Codespace is configured to build and execute the container as a tasks.

  • docker: build container will build the java project and then the container for you, prompting for details along the way
  • docker: run container will allow you to run the container that you built allowing you to select the port that is bound to (8080 by default).

Building and running the container locally without the tasks in GitHub Codespaces can be done using the following;

  • mvn package
  • docker build . --build-arg VERSION=1.0.0-SNAPSHOT --tag bookstore:latest (update to the correct version that mvn package will build for you)
  • docker run -p 8080:8080 bookstore:latest to execute the container and bind to port 8080 to serve requests from

Flow diagram

The flow diagram below depicts the Actions' workflows that are pre-configured, the events that trigger each of them and the different Azure environments that are spinned up during the demo.

Azure_Bookstore_Demo drawio

Update for building and running it on MacOS M1

modify the version
$ mvn package
$ docker build . --build-arg VERSION=1.0.0-SNAPSHOT --tag bookstore-v3:latest
$ docker run -p 8080:8080 bookstore-v3:latest

About

License:MIT License


Languages

Language:Java 54.3%Language:HCL 21.9%Language:HTML 8.9%Language:Shell 8.4%Language:Dockerfile 3.5%Language:Bicep 3.0%