Skip to content
Snippets Groups Projects
Commit 7dd2a285 authored by Zachary Sabourin's avatar Zachary Sabourin
Browse files

feat: Update build process

parent 930b0ca1
No related branches found
No related tags found
1 merge request!4feat: Update build process
......@@ -41,3 +41,5 @@ secret.properties
volumes/
node_modules/
src/test/resources/schemas/
/.apt_generated/
/.apt_generated_tests/
SHELL = /bin/bash
pre-setup:;
@echo "Creating environment file from template"
@rm -f .env && envsubst < config/.env.sample > .env
setup:;
@echo "Generating secret files from templates using environment file + variables"
@source .env && rm -f ./config/application/secret.properties && envsubst < config/application/secret.properties.sample | tr -d '\r' > config/application/secret.properties
dev-start:;
mvn compile -e quarkus:dev -Dconfig.secret.path=$$PWD/config/application/secret.properties
clean:;
mvn clean
docker compose down
compile-java: generate-spec;
mvn compile package
compile-java-quick: generate-spec;
......@@ -12,8 +22,8 @@ generate-spec: install-yarn validate-spec;
yarn run generate-json-schema
validate-spec: install-yarn;
compile-start: compile-quick;
docker-compose down
docker-compose build
docker-compose up
docker compose down
docker compose build
docker compose up -d
start-spec: validate-spec;
yarn run start
\ No newline at end of file
# eclipsefdn-mailing-lists-api
Eclipse Foundation API service for the retrieval of active mailing list data for projects within our ecosystem.
Eclipse Foundation API service for the retrieval of active mailing list data for projects within our ecosystem.
## Dependencies to run
## Starting a development environment
- Docker-compose
- Maven
- Java version 11
- NPM
Requirements:
[^ Top](#eclipsefdn-mailing-lists-api)
## Setup
### MariaDB
* Docker
* Java 11 >
* mvn
* node.js + npm
* make
* Running MariaDB instance
If the user does not have a copy of the Eclipse database already present, the SQL file under `config/mariadb/ddl.sql` can be used to create the table structure required for the application.
1. In MariaDB instance, create a new database called `eclipse` as that is what is configured out of the box. The table definitions for the database can be found under `./config/mariadb/ddl.sql`.
2. Run `make pre-setup`. This command will setup a basic .env file, using some basic variables used in Eclipse development to accelerate the generation of secret files.
3. Ensure that the `.env` file properties reflect the connection settings used for the MariaDB instance and the credentials needed to access the DB created in step 1.
4. Run `make setup` to finish the setup process for this API, generating the secret file under `./config/application/secret.properties`.
5. Run `compile-start` or `make compile-start-headless`. The first option binds the docker containers to the current terminal, and ends the processes when the terminal is closed. The second option starts the docker containers as part of the daemon and persists beyond the terminal session.
Note: This step is not needed if using docker-compose, as the container will create its own tables as needed.
### API Configuration
As part of the set up, you will need to create a `secret.properties` file within the `./config` folder and set up the secrets that are required to run the application. If named `secret.properties`, the file should be ignored by Github automatically, making it less risky that credentials are accidentally uploaded to a branch.
The fields required to run are the datasource and OIDC properties. The datasource properties should be a set of user credentials that can write to a local mariadb instance. Within that mariadb instance, a database that follows the guidelines in the [MariaDB setup section](#mariadb) should exist. Once created, a JDBC URL can now be formed for the new database. This URL should follow the pattern below, with port not always required (depending on your local setup and proxy settings). This will be set in the `secret.properties` file.
You can run your application in dev mode that enables live coding using:
```bash
make dev-start
```
quarkus.datasource.jdbc.url = jdbc:mariadb://<host><:port?>/<databaseName>
```
Once this is set, set the `quarkus.datasource.username` and `quarkus.datasource.password` fields to the user with access to the given database in the `secret.properties` file.
The other half of secret configuration is setting up the OIDC credentials for connecting to a keycloak server. This server will require a realm to be set up for access. Using the name `rem_realm` is easiest as it requires no changes to the configuration to work.
The `quarkus.oidc.auth-server-url` property in the `secret.properties` file will need to be updated. The value set should be the public realm address for your server and realm. The rest of the endpoints will be taken care of by the wellknown endpoint available in Keycloak, and don't need to be configured. For the dockerized service, this should be set to your local IP address (note, not your public address). This can be retrieved from your IP configuration application and added in the format displayed in the `sample.secret.properties` file.
Inside that realm, create a client and update the `quarkus.oidc.client-id` property within the `secret.properties` file. Inside that client, open the settings and go to the credentials tab. The secret will need to be copied and set into the `secret.properties` file in the `quarkus.oidc.credentials.client-secret.value` property. For proper reading and usage of development data, 3 users should be created and added to the realm with the usernames `user1`, `user2`, and `user3`.
export MAILING_LISTS_MARIADB_USERNAME=$MARIADB_USERNAME
export MAILING_LISTS_MARIADB_PASSWORD=$MARIADB_PASSWORD
export MAILING_LISTS_MARIADB_HOST=$MARIADB_HOST
export MAILING_LISTS_MARIADB_PORT=$MARIADB_PORT
export MAILING_LISTS_OAUTH_CLIENT_ID=sample
export MAILING_LISTS_OAUTH_CLIENT_CREDENTIALS=sample
export CONFIG_SECRET_PATH=$PWD/config/application/application.secret.properties
## Required for authenticated requests to profile API
quarkus.oidc-client.client-id=$MAILING_LISTS_OAUTH_CLIENT_ID
quarkus.oidc-client.credentials.secret=$MAILING_LISTS_OAUTH_CLIENT_CREDENTIALS
quarkus.datasource.username=$MAILING_LISTS_MARIADB_USERNAME
quarkus.datasource.password=$MAILING_LISTS_MARIADB_PASSWORD
quarkus.datasource.jdbc.url=jdbc:mariadb://$MAILING_LISTS_MARIADB_HOST:$MAILING_LISTS_MARIADB_PORT/eclipse
config.secret.path=$CONFIG_SECRET_PATH
\ No newline at end of file
quarkus.datasource.username = sample
quarkus.datasource.password = sample
quarkus.datasource.jdbc.url=jdbc:mariadb://mariadb/eclipse
## Accounts.eclipse.org eclipsefdn_view_all_profiles scope access client
quarkus.oidc-client.client-id=sample
quarkus.oidc-client.credentials.secret=sample
\ No newline at end of file
......@@ -11,7 +11,7 @@ services:
- CONFIG_SECRET_PATH=/var/run/secrets/secret.properties
- VIRTUAL_PORT=8090
volumes:
- ./config/secret.properties:/var/run/secrets/secret.properties
- ./config/application/secret.properties:/var/run/secrets/secret.properties
deploy:
restart_policy:
condition: on-failure
......@@ -26,12 +26,14 @@ services:
depends_on:
- mariadb
mariadb:
profiles:
- full
image: mariadb:latest
command: --max_allowed_packet=100000000
ports:
- '3306:3306'
environment:
MYSQL_ROOT_PASSWORD: ${REM_MYSQL_PASSWORD}
MYSQL_ROOT_PASSWORD: ${MAILING_LISTS_MARIADB_PASSWORD}
MYSQL_DATABASE: eclipse
volumes:
- ./config/mariadb/ddl.sql:/docker-entrypoint-initdb.d/ddl.sql
......
......@@ -6,7 +6,7 @@
<artifactId>eclipsefdn-mailing-lists</artifactId>
<version>1.0.0-SNAPSHOT</version>
<properties>
<eclipse-api-version>0.6.1-SNAPSHOT</eclipse-api-version>
<eclipse-api-version>0.6.5-SNAPSHOT</eclipse-api-version>
<surefire-plugin.version>2.22.1</surefire-plugin.version>
<compiler-plugin.version>3.8.1</compiler-plugin.version>
<maven.compiler.target>11</maven.compiler.target>
......
quarkus.log.level=INFO
quarkus.http.port=8090
quarkus.http.cors=true
security.csrf.enabled=true
security.csrf.distributed-mode.default-provider=false
## DATASOURCE CONFIG
eclipse.db.default.limit=10
......@@ -9,6 +11,7 @@ eclipse.db.default.limit.max=100
quarkus.datasource.db-kind=mariadb
quarkus.datasource.jdbc.min-size = 5
quarkus.datasource.jdbc.max-size = 15
quarkus.oidc.enabled=false
accounts/mp-rest/url=https://api.eclipse.org
quarkus.oauth2.enabled=false
......@@ -19,6 +22,6 @@ quarkus.oidc-client.grant.type=client
quarkus.oidc-client.scopes=eclipsefdn_view_all_profiles
# Tells Quarkus which objects are associated with what databases (used to generate entity tables internally)
quarkus.hibernate-orm.packages=org.eclipsefoundation.mailing.dto
quarkus.hibernate-orm.packages=org.eclipsefoundation.mailing.dto,org.eclipsefoundation.persistence.dto
quarkus.hibernate-orm.datasource=<default>
quarkus.hibernate-orm.physical-naming-strategy=org.eclipsefoundation.mailing.config.DefaultPhysicalNamingStrategy
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment