Skip to content

Commit

Permalink
Merge pull request #243 from com-pas/develop
Browse files Browse the repository at this point in the history
New release
  • Loading branch information
Dennis Labordus authored Aug 8, 2022
2 parents 212a35c + 2a06d48 commit c499986
Show file tree
Hide file tree
Showing 18 changed files with 406 additions and 249 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ jobs:
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Set up JDK 1.11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
java-version: '17'

- name: Create custom Maven Settings.xml
uses: whelk-io/maven-settings-xml-action@v20
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ jobs:
shell: bash
# Extra the tagname form the git reference, value of GITHUB_REF will be something like refs/tags/<tag_name>.
run: echo "##[set-output name=tagname;]$(echo ${GITHUB_REF##*/})"
- name: Set up JDK 1.11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
java-version: '17'

- name: Create custom Maven Settings.xml
uses: whelk-io/maven-settings-xml-action@v20
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/sonarcloud-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ jobs:
with:
fetch-depth: 0

- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
java-version: '17'
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
Expand Down
20 changes: 18 additions & 2 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.1/apache-maven-3.8.1-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SPDX-License-Identifier: Apache-2.0
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/5925/badge)](https://bestpractices.coreinfrastructure.org/projects/5925)
[![Slack](https://raw.githubusercontent.com/com-pas/compas-architecture/master/public/LFEnergy-slack.svg)](http://lfenergy.slack.com/)

# compas-scl-data-service
# CoMPAS SCL Data Service

Service to store and retrieve the SCL XML to a database.

Expand All @@ -21,8 +21,9 @@ to [documentation](doc/compas-scl-data-service.md).

There are currently two database implementations available.

- For more information about the BaseX Implementation go to [BaseX](doc/basex.md). (Profile activated by default.)
- For more information about the PostgreSQL Implementation go to [PostgreSQL](doc/postgresql.md).
- For more development information about the BaseX Implementation go to [BaseX](doc/basex.md). (Profile activated by
default.)
- For more development information about the PostgreSQL Implementation go to [PostgreSQL](doc/postgresql.md).

> **Note:** When switching between implementation it's a good practise to first execute a maven clean to remove
> old dependencies from the target directory in the app module.
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/docker/Dockerfile-basex.jvm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
###
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.6

ARG JAVA_PACKAGE=java-11-openjdk-headless
ARG JAVA_PACKAGE=java-17-openjdk-headless
ARG RUN_JAVA_VERSION=1.3.8
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'
# Install java and the run-java script
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/docker/Dockerfile-postgresql.jvm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
###
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.6

ARG JAVA_PACKAGE=java-11-openjdk-headless
ARG JAVA_PACKAGE=java-17-openjdk-headless
ARG RUN_JAVA_VERSION=1.3.8
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'
# Install java and the run-java script
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import javax.ws.rs.core.MediaType;
import java.util.Arrays;
import java.util.Comparator;
import java.util.stream.Collectors;

import static org.lfenergy.compas.scl.data.rest.Constants.READ_ROLE;

Expand Down Expand Up @@ -54,7 +53,7 @@ public TypeListResponse list(@HeaderParam("Authorization") String authHeader) {
.filter(sclFileType -> roles.contains(sclFileType.name() + "_" + READ_ROLE))
.map(sclFileType -> new Type(sclFileType.name(), sclFileType.getDescription()))
.sorted(Comparator.comparing(Type::getDescription))
.collect(Collectors.toList()));
.toList());
return response;
}

Expand Down
74 changes: 56 additions & 18 deletions doc/basex.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,31 @@ Below environment variable(s) can be used to configure the connection to BaseX,

## Development

### Application depends on a running BaseX instance
### Building the application

You can use Maven to build the application and see if all tests are working using:

```shell script
./mvnw clean verify
```

This should normally be enough to also run the application, but there were cases that we need to build using:

```shell script
./mvnw clean install
```

This to make the local modules available for the app module to run the application.

### Running the application in dev mode

You can run your application in dev mode that enables live coding using:

```shell script
./mvnw -DskipTests=true -Dquarkus.profile=dev-basex package io.quarkus:quarkus-maven-plugin::dev
```

#### Application depends on a running BaseX instance

Check [basexhttp on DockerHub](https://hub.docker.com/r/basex/basexhttp) for a running BaseX docker container. This is
needed when running the SCL Data Service locally. Not needed to run the tests.
Expand All @@ -37,34 +61,48 @@ docker run --rm --name compas_basex \
> **Note:** Replace <BASEX-DIR> with a directory on your local machine, for instance "~/basex".
> All data will be stored in this directory under "data". This way data isn't lost after stopping the docker container.
### Building the application
#### Application depends on a running KeyCloak instance

You can run the following command to build the BaseX version of the application.
Beside a BaseX Database there is also a KeyCloak instance need to be running on port 8089 by default.
See [README.md](../README.md#security) for default values, if custom keycloak is used.

```shell script
./mvnw clean verify
```
There is a preconfigured keycloak instance available in
the [CoMPAS Deployment Repository](https://github.com/com-pas/compas-deployment). This repository can be cloned and
when going to this directory the following command can be executed to create a local Docker Image with configuration.

### Running the application in dev mode
```shell
cd <CoMPAS Deployment Repository Directory>/compas/keycloak
docker build -t compas_keycloak .
```

You can run your application in dev mode that enables live coding using:
There is now a Docker Image `compas_keycloak` created that can be started using the following command

```shell script
./mvnw -DskipTests=true -Dquarkus.profile=dev-basex package io.quarkus:quarkus-maven-plugin::dev
```shell
docker run --rm --name compas_keycloak \
-p 8089:8080
-d compas_keycloak:latest
```

### Creating a native executable
### Creating a Docker image with native executable

You can create a native executable using:
The releases created in the repository will create a docker image with a native executable. If you're running a Linux
system it's possible to create and run the executable locally. You can create a Docker image with native executable
using:

```shell script
./mvnw -P native package
./mvnw package -Pnative-image
```

This will run the native executable build in a container. In the native profile the property
"quarkus.native.container-build" is set to 'true'.

You can then execute your native executable with: `./app/target/basex-quarkus-app/app-local-SNAPSHOT-runner`

If you want to learn more about building native executables, please see https://quarkus.io/guides/maven-tooling.html
and https://quarkus.io/guides/writing-native-applications-tips.
### Creating a Docker image with JVM executable

There is also a profile to create a Docker Image which runs the application using a JVM. You can create a Docker Image
with JVM executable using:

```shell script
./mvnw package -Pjvm-image
```

The JVM Image can also (temporary) be created by the release action if there are problems creating or running the
native executable.
8 changes: 7 additions & 1 deletion doc/compas-scl-data-service.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,10 @@ There a some BaseX specific choices made in storing the SCL.

### PostgreSQL

TODO
There a some PostgreSQL choices made in storing the SCL.

- For the PostgreSQL version we use FlyWay to maintain the database schema.
- All SCL XML Files are stored in a table called `scl_file`.
- For every new version of an SCL XML File a new record is created.
- The full XML is stored in a text field `scl_data`.
- We can use the XPath function of PostgreSQL to retrieve extra info from the XML.
77 changes: 58 additions & 19 deletions doc/postgresql.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,31 @@ Table: scl_file

## Development

### Application depends on a running PostgreSQL instance
### Building the application

You can use Maven to build the application and see if all tests are working using:

```shell script
./mvnw clean verify
```

This should normally be enough to also run the application, but there were cases that we need to build using:

```shell script
./mvnw clean install
```

This to make the local modules available for the app module to run the application.

### Running the application in dev mode

You can run your application in dev mode that enables live coding using:

```shell script
./mvnw -DskipTests=true -Dquarkus.profile=dev-postgresql package io.quarkus:quarkus-maven-plugin::dev
```

#### Application depends on a running PostgreSQL instance

Check [PostgreSQL on DockerHub](https://hub.docker.com/_/postgres?tab=description) for a running PostgreSQL docker
container. Use the following command to start the docker container.
Expand All @@ -56,36 +80,51 @@ docker run --rm --name compas_postgresql \
```

> **Note:** Replace <LOCAL-DATA-DIR> with a directory on your local machine, for instance "~/postgres".
> All data will be stored in this directory under "compas". This way data isn't lost after stopping the docker container.
> All data will be stored in this directory under "compas". This way data isn't lost after stopping the docker
> container.
### Building the application
#### Application depends on a running KeyCloak instance

You can run the following command to build the PostgreSQL version of the application.
Beside a PostgreSQL Database there is also a KeyCloak instance need to be running on port 8089 by default.
See [README.md](../README.md#security) for default values, if custom keycloak is used.

```shell script
./mvnw clean verify
```
There is a preconfigured keycloak instance available in
the [CoMPAS Deployment Repository](https://github.com/com-pas/compas-deployment). This repository can be cloned and
when going to this directory the following command can be executed to create a local Docker Image with configuration.

### Running the application in dev mode
```shell
cd <CoMPAS Deployment Repository Directory>/compas/keycloak
docker build -t compas_keycloak .
```

You can run your application in dev mode that enables live coding using:
There is now a Docker Image `compas_keycloak` created that can be started using the following command

```shell script
./mvnw -DskipTests=true -Dquarkus.profile=dev-postgresql package io.quarkus:quarkus-maven-plugin::dev
```shell
docker run --rm --name compas_keycloak \
-p 8089:8080
-d compas_keycloak:latest
```

### Creating a native executable
### Creating a Docker image with native executable

You can create a native executable using:
The releases created in the repository will create a docker image with a native executable. If you're running a Linux
system it's possible to create and run the executable locally. You can create a Docker image with native executable
using:

```shell script
./mvnw -P native package
./mvnw package -Pnative-image
```

This will run the native executable build in a container. In the native profile the property
"quarkus.native.container-build" is set to 'true'.

You can then execute your native executable with: `./app/target/postgresql-quarkus-app/app-local-SNAPSHOT-runner`

If you want to learn more about building native executables, please see https://quarkus.io/guides/maven-tooling.html
and https://quarkus.io/guides/writing-native-applications-tips.
### Creating a Docker image with JVM executable

There is also a profile to create a Docker Image which runs the application using a JVM. You can create a Docker Image
with JVM executable using:

```shell script
./mvnw package -Pjvm-image
```

The JVM Image can also (temporary) be created by the release action if there are problems creating or running the
native executable.
15 changes: 7 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ SPDX-License-Identifier: Apache-2.0

<properties>
<maven.compiler.parameters>true</maven.compiler.parameters>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.release>17</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

Expand All @@ -26,7 +25,7 @@ SPDX-License-Identifier: Apache-2.0

<compas.core.version>0.9.1</compas.core.version>

<quarkus.platform.version>2.10.2.Final</quarkus.platform.version>
<quarkus.platform.version>2.11.2.Final</quarkus.platform.version>
<jaxb-impl.version>2.3.6</jaxb-impl.version>
<microprofile-openapi-api.version>3.0</microprofile-openapi-api.version>
<slf4j.version>1.7.36</slf4j.version>
Expand Down Expand Up @@ -181,11 +180,11 @@ SPDX-License-Identifier: Apache-2.0
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.2</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
Expand Down
Loading

0 comments on commit c499986

Please sign in to comment.