Skip to content

Latest commit

 

History

History
108 lines (79 loc) · 3.76 KB

local-development.md

File metadata and controls

108 lines (79 loc) · 3.76 KB

Local Development

Starting the db, keycloak and Elastic using the .env file

Create env variables that are needed in docker-compose file and update to required values.

$ cp release-raccoon-app/.env.dist release-raccoon-app/.env

NOTE: The images in docker-compose.yml are currently set for development on arm CPUs, commented you will find the amd64 counterparts.

From the root of the project run:

source release-raccoon-app/.env
docker compose --env-file ./release-raccoon-app/.env -f docker/docker-compose.yml up -d

Setting up liquibase

For db schema migrations Liquibase is used. Prior to the first run you will need to generate two tables used to track liquibase versions.

To create the two tables needed run the following against your sql database.

create table DATABASECHANGELOG
(
    ID            varchar(255) not null,
    AUTHOR        varchar(255) not null,
    FILENAME      varchar(255) not null,
    DATEEXECUTED  datetime     not null,
    ORDEREXECUTED int          not null,
    EXECTYPE      varchar(10)  not null,
    MD5SUM        varchar(35)  null,
    DESCRIPTION   varchar(255) null,
    COMMENTS      varchar(255) null,
    TAG           varchar(255) null,
    LIQUIBASE     varchar(20)  null,
    CONTEXTS      varchar(255) null,
    LABELS        varchar(255) null,
    DEPLOYMENT_ID varchar(10)  null
);

create table DATABASECHANGELOGLOCK
(
    ID          int          not null
        primary key,
    LOCKED      bit          not null,
    LOCKGRANTED datetime     null,
    LOCKEDBY    varchar(255) null
);

Alternatively, you can install and use the liquibase executable directly like so:

sdk install liquibase
liquibase --driver=org.mariadb.jdbc.Driver --changeLogFile=release-raccoon-app/src/main/resources/db/changelog/db.changelog-x.x.x.sql --url="jdbc:mariadb://localhost:3305/raccoondb" --username=${DB_USERNAME} --password=${DB_PASSWORD} generateChangeLog

Setting up Keycloak

Access the Keycloak Admin Console login with the password used by the docker-compose. The realm we will be using is RaccoonRealm and is defined in realm. It is mounted to the container on start time. You will need to create a new user in order to connect. You also need to create a secret (Clients > release-raccoon > Credentials > Regenerate Secret) which you will need to pass as quarkus.oidc.credentials.secret to the properties. You should be good to start the quarkus app.

In case after a docker restart the redirect back from keycloak stops working in dev mode, you might need to regenerate a quarkus.oidc.credentials.secret and plug it into the properties again.

Running the application in dev mode

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

./mvnw compile quarkus:dev -pl release-raccoon-app

Packaging and running the application

The application can be packaged using:

./mvnw package

It produces the release.raccoon-0.0.1-SNAPSHOT-runner.jar file in the /target directory. Be aware that it’s not an über-jar as the dependencies are copied into the target/lib directory.

If you want to build an über-jar, execute the following command:

./mvnw package -Dquarkus.package.type=uber-jar

The application is now runnable using java -jar target/release.raccoon-0.0.1-SNAPSHOT-runner.jar.

Testing

For testing we rely on testcontainers:

sudo ln -s $HOME/.docker/run/docker.sock /var/run/docker.sock