Skip to content

Nickkr/VSLab-Master

Repository files navigation

Verteile Systeme Master Laboratory

WebShop implementation with microservices.

Run the application using docker compose

You can do the build and run in one command.

docker-compose up --build --detach

Using local compiled executables during development

When you have maven installed on your machine, you can configure the docker-compose build to use existing java executables. These java executables needs to be compiled with maven before you running docker-compose.

You can use the enviroment variable BUILD_FROM to select which dockerfile is used for the build. If you obmit this variable, then the build from maven sources is used by default.

  • with BUILD_FROM=MavenSources the source code is compiled during the docker build using the maven:3.6.3-openjdk-11-slim image. Therefore maven needs to download all dependencies, as it cannot reuse the hosts local repository. This might increase your build time.

    BUILD_FROM=MavenSources docker-compose build
  • with BUILD_FROM=ExecutableJar the pre-compiled jar executable is packed into the openjdk:11-jre-slim image. This requires you to compile the sources on the host system before the docker build.

    mvn clean package -DskipTests
    BUILD_FROM=ExecutableJar docker-compose build

Build and Startup script

You also can use the package-build-up.cmd script for compiling the sources with your local maven, building the docker images and start the services.

  • The maven pom in your working directory is used for compilation.
  • The first argument is passed to maven a artifactId to select the builded project, even if your working directory pom contains other projects.
  • The following arguments are passed to docker-compose up for starting other services, too.
  • You can pass the same arguments as for docker-compose build and docker-compose up, to specify a service.

Example usage:

  • Run it in your project folder without arguments, to build and start the whole application:

    package-build-up.cmd
  • Pass a service name to build and start this specific service, only. Its dependend services are included automatically by docker.

    package-and-up.cmd category-service
  • Pass a second service name to start this service, too. This only rebuild the category service, but starts the whole application.

    package-and-up.cmd category-service zuul-server

Detailed build instructions

  1. Optionally if you want to predownload used docker images, do a pull first.

    docker pull openjdk:11-jre-slim
    docker pull openjdk:11-slim
    docker pull maven:3.6.3-openjdk-11-slim
  2. Compile the sources

    mvn clean package -DskipTests
  3. Build the services

    BUILD_FROM=ExecutableJar docker-compose build
  4. Optionally removes containers, networks and the local MySql data storage volume for a fresh database initialization.

    • Pass the --rmi local to remove local images, from previous executions.
    • Pass the --remove-orphans to remove undefined service, from previous developments.
    docker-compose down --volumes --rmi local --remove-orphans
  5. Run the services

    docker-compose up --detach

Usage links

The Webshop API is provided by the Zuul server at http://localhost:8081/webshop-api/.

Open the following links to view:

API Documentation of the WebShop

The API is modeled with the RESTful API Modeling Language RAML. The file api.raml contains the documentation of the api.

Generating the API-Documentation

There are two ways to generate the API-Documentation

  1. Docker
  2. raml2html
    • cd documentation
    • (first time) npm install
    • npm run build or npm run build:watch to automatically build on changes
    • open the generated file api-docs.html

Initial development setup

Build Requirements

For local development you should have

Also check if your JAVA_HOME environment variable is configured correctly.

Generate some inital code

You can generate an initial Spring Boot Core project using Spring Initializr.

Follow the Guides to create some inital code.

Start your code

To run your application locally, goto to your working directory containing the pom.xml and:

  1. Start the database.

    docker-compose up --detach db
  2. Start the application using

    mvn spring-boot:run
  3. Check the console output, to see on which port Tomcat has started.

  4. Open localhost on this port http://localhost:$PORT/greeting?name=User and check for a response.

Authorization

Links

Keys Token

Body-Parameter für Token:

grant_type: password username: admin password: password scope: message.read

Further guides and tutorials

Spring Data JPA implement filtering with optional parameters:

Creating the composite service and call core services:

Eureka-Ribbon Discovery:

Microservice Security mit OAuth2:

More development related articles:

Reference Documentation

For further reference, please consider the following sections:

Guides

The following guides illustrate how to use some features concretely:

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •