Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration of the toolbox.sh script and associated unit tests to install the SonarQube development environment #62

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .default.docker.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
MAVEN_BUILDER_VERSION=3-openjdk-17-slim
SONARQUBE_VERSION=10.6.0-community
POSTGRES_VERSION=12
DOCKER_BUILDKIT=1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put a comment for these 2 options, please

COMPOSE_DOCKER_CLI_BUILD=1
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

# Ensure BAT files will always be checked out with CRLFs (regardless of the
# OS they were checked out on).
*.bat text eol=crlf
*.bat text eol=crlf
11 changes: 8 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
# Ignore IDE files
*.iml
.idea

# Ignore all files and folders starting with ".", except a few exceptions
.*
!.gitignore
!.gitattributes
!.github/
!.default.docker.env

# Ignore generated files
target
bin
dependency-reduced-pom.xml

# Ignore IDE files
*.iml
release.properties
pom.xml.*
tests/__pycache__
19 changes: 10 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
ARG MAVEN_BUILDER=3-openjdk-17-slim
ARG SONARQUBE_VERSION=10.6.0-community
# syntax=docker/dockerfile:1

FROM maven:${MAVEN_BUILDER} AS builder
ARG MAVEN_BUILDER_VERSION
ARG SONARQUBE_VERSION
ARG ECOCODE_SRC_PATH=/usr/src/ecocode
ARG SONARQUBE_PLUGINS_PATH=/opt/sonarqube/extensions/plugins/

COPY . /usr/src/ecocode
FROM maven:${MAVEN_BUILDER_VERSION} AS builder

WORKDIR /usr/src/ecocode
COPY src src/
COPY pom.xml tool_build.sh ./
COPY . ${ECOCODE_SRC_PATH}

RUN ./tool_build.sh
WORKDIR ${ECOCODE_SRC_PATH}
RUN ${ECOCODE_SRC_PATH}/toolbox.sh build

FROM sonarqube:${SONARQUBE_VERSION}
COPY --from=builder /usr/src/ecocode/target/ecocode-*.jar /opt/sonarqube/extensions/plugins/
COPY --from=builder ${ECOCODE_SRC_PATH}/target/ecocode-*.jar ${SONARQUBE_PLUGINS_PATH}
USER sonarqube
16 changes: 8 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
---
name: sonarqube_ecocode_java

services:
sonar:
build: .
build:
context: .
dockerfile: Dockerfile
args:
- MAVEN_BUILDER_VERSION=${MAVEN_BUILDER_VERSION}
- SONARQUBE_VERSION=${SONARQUBE_VERSION}
container_name: sonar_ecocode_java
ports:
- ":9000"
Expand All @@ -16,18 +21,13 @@ services:
SONAR_JDBC_PASSWORD: sonar
SONAR_JDBC_URL: jdbc:postgresql://db:5432/sonarqube
SONAR_ES_BOOTSTRAP_CHECKS_DISABLE: 'true'
env_file:
dedece35 marked this conversation as resolved.
Show resolved Hide resolved
- path: ./.default.docker.env
required: true
- path: ./.override.docker.env
required: false
volumes:
- "extensions:/opt/sonarqube/extensions"
- "logs:/opt/sonarqube/logs"
- "data:/opt/sonarqube/data"

db:
image: postgres:12
image: postgres:${POSTGRES_VERSION}
container_name: postgresql_ecocode_java
networks:
- sonarnet
Expand Down
137 changes: 137 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# toolbox.sh

## Overview

This toolbox enables you to install the SonarQube dev environment.

## Index

* [docker_env_source](#dockerenvsource)
* [docker_build](#dockerbuild)
* [init](#init)
* [start](#start)
* [stop](#stop)
* [clean](#clean)
* [display_logs](#displaylogs)
* [build](#build)
* [compile](#compile)
* [release](#release)
* [release_push](#releasepush)
* [display_help](#displayhelp)

### docker_env_source

Export environment variables from .default.docker.env file.

#### Exit codes

* **0**: If successful.
* **1**: If the environment file cannot be found.

### docker_build

Build Docker services.

#### Exit codes

* **0**: If successful.
* **1**: If an error was encountered retrieving environment variables.
* **2**: If an error has been encountered when building services.

### init

Building the ecoCode plugin and creating containers.

#### Exit codes

* **0**: If successful.
* **1**: If an error was encountered when building project code in the target folder.
* **2**: If an error was encountered retrieving environment variables.
* **3**: If an error was encountered during container creating.

### start

Starting Docker containers.

#### Exit codes

* **0**: If successful.
* **1**: If the ecoCode plugin is not present in the target folder.
* **2**: If an error was encountered retrieving environment variables.
* **3**: If an error was encountered during container startup.

### stop

Stopping Docker containers.

#### Exit codes

* **0**: If successful.
* **1**: If an error was encountered retrieving environment variables.
* **2**: If an error was encountered during container shutdown.

### clean

Stop and remove containers, networks and volumes.

#### Exit codes

* **0**: If successful.
* **1**: If an error was encountered retrieving environment variables.
* **2**: If an error was encountered during deletion.

### display_logs

Display Docker container logs.

#### Exit codes

* **0**: If successful.
* **1**: If an error was encountered retrieving environment variables.

### build

Compile and package source code with maven.

#### Exit codes

* **0**: If successful.
* **1**: If an error was encountered when building source code.
* **2**: If the ecoCode plugin in target directory cannot be found.

### compile

Compile source code with maven.

#### Exit codes

* **0**: If successful.
* **1**: If an error was encountered when compiling the source code.

### release

Use maven plugin release to prepare locally next release and next SNAPSHOT.

#### Exit codes

* **0**: If successful.
* **1**: If an error is encountered when prepare the release.
* **2**: If an error is encountered when cleaning files.

### release_push

Create a push and a new branch with commits previously prepared

#### Exit codes

* **0**: If successful.
* **1**: If the last commit tag does not match the last git tag.

### display_help

Display help.

#### Exit codes

* **0**: If successful.

20 changes: 20 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
site_name: ecoCode-java
christopherlouet marked this conversation as resolved.
Show resolved Hide resolved
repo_url: https://github.com/green-code-initiative/ecoCode-java/
site_description: Documentation based on ecoCode bash scripts
nav:
- index.md
theme:
name: material
palette:
scheme: slate
primary: purple
accent: cyan
features:
- navigation.tabs
- navigation.tabs.sticky
- navigation.sections
plugins:
- search
- include_dir_to_nav:
sort_file: true
sort_directory: true
Loading
Loading