From 75febb393a09318f55aa693cdd9a4ac1fe370636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Vrba?= Date: Sat, 5 Oct 2024 08:44:57 +0200 Subject: [PATCH] Move migrations to make the application graalvm-compatible --- api/build.gradle.kts | 13 +++++++------ api/src/main/resources/application.yml | 5 +++-- .../migration}/V0__create_users.sql | 0 .../migration}/V1__create_guilds_and_channels.sql | 0 .../migration}/V2__create_patterns.sql | 0 .../migration}/V3__create_matched_patterns.sql | 0 .../migration}/V4__create_matches.sql | 0 .../migration}/V5__drop_patterns.sql | 0 .../migration}/V6__add_row_id_to_matches.sql | 0 9 files changed, 10 insertions(+), 8 deletions(-) rename api/src/main/resources/{migrations => db/migration}/V0__create_users.sql (100%) rename api/src/main/resources/{migrations => db/migration}/V1__create_guilds_and_channels.sql (100%) rename api/src/main/resources/{migrations => db/migration}/V2__create_patterns.sql (100%) rename api/src/main/resources/{migrations => db/migration}/V3__create_matched_patterns.sql (100%) rename api/src/main/resources/{migrations => db/migration}/V4__create_matches.sql (100%) rename api/src/main/resources/{migrations => db/migration}/V5__drop_patterns.sql (100%) rename api/src/main/resources/{migrations => db/migration}/V6__add_row_id_to_matches.sql (100%) diff --git a/api/build.gradle.kts b/api/build.gradle.kts index a6ec3fb..edf0d7f 100644 --- a/api/build.gradle.kts +++ b/api/build.gradle.kts @@ -1,3 +1,5 @@ +import io.micronaut.gradle.docker.NativeImageDockerfile + plugins { id("com.github.johnrengelman.shadow") version "8.1.1" id("io.micronaut.application") version "4.4.2" @@ -39,17 +41,18 @@ dependencies { testImplementation("org.testcontainers:testcontainers") } - application { mainClass = "dev.vrba.dubs.Application" } + java { sourceCompatibility = JavaVersion.toVersion("21") targetCompatibility = JavaVersion.toVersion("21") } - -graalvmNative.toolchainDetection = false +graalvmNative { + toolchainDetection = false +} micronaut { runtime("netty") @@ -72,9 +75,7 @@ micronaut { } } - -tasks.named("dockerfileNative") { +tasks.named("dockerfileNative") { jdkVersion = "21" } - diff --git a/api/src/main/resources/application.yml b/api/src/main/resources/application.yml index 8f7464e..a81930b 100644 --- a/api/src/main/resources/application.yml +++ b/api/src/main/resources/application.yml @@ -2,6 +2,9 @@ micronaut: application: name: dubs-bot-api + server: + port: ${PORT:8080} + serde: serialization: inclusion: always @@ -59,8 +62,6 @@ flyway: datasources: default: enabled: true - locations: - - classpath:migrations jpa: default: diff --git a/api/src/main/resources/migrations/V0__create_users.sql b/api/src/main/resources/db/migration/V0__create_users.sql similarity index 100% rename from api/src/main/resources/migrations/V0__create_users.sql rename to api/src/main/resources/db/migration/V0__create_users.sql diff --git a/api/src/main/resources/migrations/V1__create_guilds_and_channels.sql b/api/src/main/resources/db/migration/V1__create_guilds_and_channels.sql similarity index 100% rename from api/src/main/resources/migrations/V1__create_guilds_and_channels.sql rename to api/src/main/resources/db/migration/V1__create_guilds_and_channels.sql diff --git a/api/src/main/resources/migrations/V2__create_patterns.sql b/api/src/main/resources/db/migration/V2__create_patterns.sql similarity index 100% rename from api/src/main/resources/migrations/V2__create_patterns.sql rename to api/src/main/resources/db/migration/V2__create_patterns.sql diff --git a/api/src/main/resources/migrations/V3__create_matched_patterns.sql b/api/src/main/resources/db/migration/V3__create_matched_patterns.sql similarity index 100% rename from api/src/main/resources/migrations/V3__create_matched_patterns.sql rename to api/src/main/resources/db/migration/V3__create_matched_patterns.sql diff --git a/api/src/main/resources/migrations/V4__create_matches.sql b/api/src/main/resources/db/migration/V4__create_matches.sql similarity index 100% rename from api/src/main/resources/migrations/V4__create_matches.sql rename to api/src/main/resources/db/migration/V4__create_matches.sql diff --git a/api/src/main/resources/migrations/V5__drop_patterns.sql b/api/src/main/resources/db/migration/V5__drop_patterns.sql similarity index 100% rename from api/src/main/resources/migrations/V5__drop_patterns.sql rename to api/src/main/resources/db/migration/V5__drop_patterns.sql diff --git a/api/src/main/resources/migrations/V6__add_row_id_to_matches.sql b/api/src/main/resources/db/migration/V6__add_row_id_to_matches.sql similarity index 100% rename from api/src/main/resources/migrations/V6__add_row_id_to_matches.sql rename to api/src/main/resources/db/migration/V6__add_row_id_to_matches.sql