Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

Commit

Permalink
Merge pull request #14 from IT-REX-Platform/dev
Browse files Browse the repository at this point in the history
Merge from dev
  • Loading branch information
Well5a authored Mar 31, 2021
2 parents 42b6f12 + 6397145 commit 15ad3ce
Show file tree
Hide file tree
Showing 33 changed files with 1,737 additions and 328 deletions.
39 changes: 4 additions & 35 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,19 @@ pipeline {
agent { label agentLabel }

stages {
stage('check java') {
steps {
sh 'java -version'
}
}

stage('clean') {
steps { sh 'chmod +x gradlew'
sh './gradlew clean --no-daemon'
}
}

stage('nohttp') {
steps {
sh './gradlew checkstyleNohttp --no-daemon'
}
}

stage('backend tests') {
stage('tests') {
steps {
sh './gradlew check jacocoTestReport -PnodeInstall --no-daemon'
junit '**/build/**/TEST-*.xml'
}
}

stage('packaging') {
steps {
sh './gradlew bootJar -x test -Pprod -PnodeInstall --no-daemon'
archiveArtifacts artifacts: '**/build/libs/*.jar', fingerprint: true
}
}

stage('quality analysis') {
when {
branch 'dev'
Expand All @@ -65,21 +46,9 @@ pipeline {
}
steps {
echo 'Deploying....'
sh './gradlew jibBuildTar'
sh 'mkdir -p /srv/Backend/quizservice'
sh 'rm -rf /srv/Backend/quizservice/*'
sh 'cd ./build && mv jib-image.tar /srv/Backend/quizservice/quizservice.tar'
sh 'touch /srv/Backend/quizservice/deploy'
}
}

stage('release') {
when { allOf { branch 'dev'; triggeredBy 'UserIdCause' } }
steps {
sshagent (credentials: ['jenkins']) {
echo 'Pushing dev to main'
sh 'git push git@github.com:IT-REX-Platform/QuizService.git dev:main'
}
sh './gradlew jibDockerBuild'
sh 'docker-compose rm -svf quizservice'
sh 'docker-compose up -d --build --remove-orphans'
}
}
}
Expand Down
138 changes: 16 additions & 122 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,143 +1,37 @@
# QuizService

This application was generated using JHipster 6.10.5, you can find documentation and help at [https://www.jhipster.tech/documentation-archive/v6.10.5](https://www.jhipster.tech/documentation-archive/v6.10.5).

This is a "microservice" application intended to be part of a microservice architecture, please refer to the [Doing microservices with JHipster][] page of the documentation for more information.

This application is configured for Service Discovery and Configuration with the JHipster-Registry. On launch, it will refuse to start if it is not able to connect to the JHipster-Registry at [http://localhost:8761](http://localhost:8761). For more information, read our documentation on [Service Discovery and Configuration with the JHipster-Registry][].

## Development

To start your application in the dev profile, run:

```
./gradlew
```

For further instructions on how to develop with JHipster, have a look at [Using JHipster in development][].

### Doing API-First development using openapi-generator

[OpenAPI-Generator]() is configured for this application. You can generate API code from the `src/main/resources/swagger/api.yml` definition file by running:

```bash
./gradlew openApiGenerate
```
## Architecture Documentation

Then implements the generated delegate classes with `@Service` classes.
Documentation of the whole IT-Rex system can be found [here](https://github.com/IT-REX-Platform/Wiki/wiki/Application-Architecture).

To edit the `api.yml` definition file, you can use a tool such as [Swagger-Editor](). Start a local instance of the swagger-editor using docker by running: `docker-compose -f src/main/docker/swagger-editor.yml up -d`. The editor will then be reachable at [http://localhost:7742](http://localhost:7742).

Refer to [Doing API-First development][] for more details.

## Building for production

### Packaging as jar

To build the final jar and optimize the QuizService application for production, run:

```
./gradlew -Pprod clean bootJar
```

To ensure everything worked, run:

```
java -jar build/libs/*.jar
```
Especially relevant documentation for the internal data model of this service:
* [User Role Model](https://github.com/IT-REX-Platform/Wiki/wiki/Application-Architecture--Data-Model--User)
* [Quiz Data Model](https://github.com/IT-REX-Platform/Wiki/wiki/Application-Architecture--Data-Model--Quiz)

Refer to [Using JHipster in production][] for more details.

### Packaging as war

To package your application as a war in order to deploy it to an application server, run:

```
./gradlew -Pprod -Pwar clean bootWar
```

## Testing

To launch your application's tests, run:

```
./gradlew test integrationTest jacocoTestReport
```

For more information, refer to the [Running tests page][].

### Code quality

Sonar is used to analyse code quality. You can start a local Sonar server (accessible on http://localhost:9001) with:

```
docker-compose -f src/main/docker/sonar.yml up -d
```
## Development

You can run a Sonar analysis with using the [sonar-scanner](https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner) or by using the gradle plugin.
Documentation of the recommended development environment setup can be found [here](https://github.com/IT-REX-Platform/Wiki/wiki/Development--Environment-Setup).

Then, run a Sonar analysis:
To start your application in the dev profile, run:

```
./gradlew -Pprod clean check jacocoTestReport sonarqube
./gradlew -Pdev bootRun
```

For more information, refer to the [Code quality page][].

## Using Docker to simplify development (optional)

You can use Docker to improve your JHipster development experience. A number of docker-compose configuration are available in the [src/main/docker](src/main/docker) folder to launch required third party services.

For example, to start a mongodb database in a docker container, run:
The service can be provided as a Docker image. To build the Docker image and load it into your local registry execute:

```
docker-compose -f src/main/docker/mongodb.yml up -d
./gradlew -Pdev jibDockerBuild
```

To stop it and remove the container, run:

```
docker-compose -f src/main/docker/mongodb.yml down
```
Further documentation on how to start the service can be found [here](https://github.com/IT-REX-Platform/Wiki/wiki/Development--How-to-start-a-backend-service).

You can also fully dockerize your application and all the services that it depends on.
To achieve this, first build a docker image of your app by running:

```
./gradlew bootJar -Pprod jibDockerBuild
```
## JHipster

Then run:
This application was generated using JHipster 6.10.5, you can find documentation and help at [https://www.jhipster.tech/documentation-archive/v6.10.5](https://www.jhipster.tech/documentation-archive/v6.10.5).

```
docker-compose -f src/main/docker/app.yml up -d
```
This is a "microservice" application intended to be part of a microservice architecture, please refer to the [Doing microservices with JHipster][] page of the documentation for more information.

For more information refer to [Using Docker and Docker-Compose][], this page also contains information on the docker-compose sub-generator (`jhipster docker-compose`), which is able to generate docker configurations for one or several JHipster applications.

## Continuous Integration (optional)

To configure CI for your project, run the ci-cd sub-generator (`jhipster ci-cd`), this will let you generate configuration files for a number of Continuous Integration systems. Consult the [Setting up Continuous Integration][] page for more information.

[jhipster homepage and latest documentation]: https://www.jhipster.tech
[jhipster 6.10.5 archive]: https://www.jhipster.tech/documentation-archive/v6.10.5
[doing microservices with jhipster]: https://www.jhipster.tech/documentation-archive/v6.10.5/microservices-architecture/
[using jhipster in development]: https://www.jhipster.tech/documentation-archive/v6.10.5/development/
[service discovery and configuration with the jhipster-registry]: https://www.jhipster.tech/documentation-archive/v6.10.5/microservices-architecture/#jhipster-registry
[using docker and docker-compose]: https://www.jhipster.tech/documentation-archive/v6.10.5/docker-compose
[using jhipster in production]: https://www.jhipster.tech/documentation-archive/v6.10.5/production/
[running tests page]: https://www.jhipster.tech/documentation-archive/v6.10.5/running-tests/
[code quality page]: https://www.jhipster.tech/documentation-archive/v6.10.5/code-quality/
[setting up continuous integration]: https://www.jhipster.tech/documentation-archive/v6.10.5/setting-up-ci/
[openapi-generator]: https://openapi-generator.tech
[swagger-editor]: https://editor.swagger.io
[doing api-first development]: https://www.jhipster.tech/documentation-archive/v6.10.5/doing-api-first-development/
This application is configured for Service Discovery and Configuration with the JHipster-Registry. On launch, it will refuse to start if it is not able to connect to the JHipster-Registry at [http://localhost:8761](http://localhost:8761). For more information, read our documentation on [Service Discovery and Configuration with the JHipster-Registry][].
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ plugins {
}

group = "de.uni_stuttgart.it_rex.quiz"
version = "0.0.1-SNAPSHOT"
version = "1.0.0"

description = ""

Expand Down
46 changes: 46 additions & 0 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
version: "2"
services:
quizservice:
image: quizservice
environment:
- _JAVA_OPTIONS=-Xmx512m -Xms256m
- "SPRING_PROFILES_ACTIVE=prod,swagger"
- MANAGEMENT_METRICS_EXPORT_PROMETHEUS_ENABLED=true
- "EUREKA_CLIENT_SERVICE_URL_DEFAULTZONE=http://admin:$${jhipster.registry.password}@jhipster-registry:8761/eureka"
- "SPRING_CLOUD_CONFIG_URI=http://admin:$${jhipster.registry.password}@jhipster-registry:8761/config"
- "SPRING_DATA_MONGODB_URI=mongodb://quizservice-mongodb:27017"
- SPRING_DATA_MONGODB_DATABASE=QuizService
- "SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_OIDC_ISSUER_URI=http://keycloak:9080/auth/realms/jhipster"
- SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_OIDC_CLIENT_ID=internal
- SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_OIDC_CLIENT_SECRET=internal
- JHIPSTER_SLEEP=5
- JHIPSTER_REGISTRY_PASSWORD=admin
restart: always
depends_on:
- quizservice-mongodb
networks:
- it-rex

quizservice-mongodb:
image: mongo:4.2.7
restart: always
ports:
- 27017:27017
networks:
- it-rex

mongo-express:
image: mongo-express
restart: always
ports:
- 8090:8081
environment:
- ME_CONFIG_MONGODB_SERVER=quizservice-mongodb
# ME_CONFIG_MONGODB_ADMINUSERNAME: root
# ME_CONFIG_MONGODB_ADMINPASSWORD: example
networks:
- it-rex

networks:
it-rex:
external: true
33 changes: 33 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: "2"
services:
quizservice:
image: quizservice
environment:
- _JAVA_OPTIONS=-Xmx512m -Xms256m
- SPRING_PROFILES_ACTIVE=prod,swagger
- MANAGEMENT_METRICS_EXPORT_PROMETHEUS_ENABLED=true
- EUREKA_CLIENT_SERVICE_URL_DEFAULTZONE=http://admin:$${jhipster.registry.password}@jhipster-registry:8761/eureka
- SPRING_CLOUD_CONFIG_URI=http://admin:$${jhipster.registry.password}@jhipster-registry:8761/config
- SPRING_DATA_MONGODB_URI=mongodb://quizservice-mongodb:27017
- SPRING_DATA_MONGODB_DATABASE=QuizService
- SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_OIDC_ISSUER_URI=http://129.69.217.173:9080/auth/realms/jhipster
- SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_OIDC_CLIENT_ID=internal
- SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_OIDC_CLIENT_SECRET=internal
- JHIPSTER_SLEEP=5 # gives time for other services to boot before the application
restart: always
depends_on:
- quizservice-mongodb
networks:
- it-rex

quizservice-mongodb:
image: mongo:4.2.7
restart: always
ports:
- "27017:27017"
networks:
- it-rex

networks:
it-rex:
external: true
Empty file modified gradlew
100644 → 100755
Empty file.

This file was deleted.

Loading

0 comments on commit 15ad3ce

Please sign in to comment.