Skip to content

Commit

Permalink
Migrate airbyte-bootloader to Micronaut
Browse files Browse the repository at this point in the history
  • Loading branch information
jdpgrailsdev committed Jan 5, 2023
1 parent 13369cf commit 9b05e22
Show file tree
Hide file tree
Showing 21 changed files with 1,329 additions and 828 deletions.
5 changes: 4 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ BASIC_AUTH_PASSWORD=password
BASIC_AUTH_PROXY_TIMEOUT=600

### DATABASE ###
# Airbyte Bootloader environment variables
BOOTLOADER_MIGRATION_BASELINE_VERSION=0.29.0.001
RUN_DATABASE_MIGRATION_ON_STARTUP=true

# Airbyte Internal Job Database, see https://docs.airbyte.io/operator-guides/configuring-airbyte-db
DATABASE_USER=docker
DATABASE_PASSWORD=docker
Expand Down Expand Up @@ -115,4 +119,3 @@ OTEL_COLLECTOR_ENDPOINT="http://host.docker.internal:4317"

USE_STREAM_CAPABLE_STATE=true
AUTO_DETECT_SCHEMA=false

4 changes: 4 additions & 0 deletions .env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ WORKERS_MICRONAUT_ENVIRONMENTS=control-plane
CRON_MICRONAUT_ENVIRONMENTS=control-plane
AUTO_DETECT_SCHEMA=false

# Airbyte Bootloader environment variables
BOOTLOADER_MIGRATION_BASELINE_VERSION=0.29.0.001
RUN_DATABASE_MIGRATION_ON_STARTUP=true

# Sentry
SENTRY_DSN=""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
This application runs at start up for Airbyte. It is responsible for making sure that the environment is upgraded and in a good state. e.g. It makes sure the database has been migrated to the correct version.

## Entrypoint
* BootloaderApp.java - has the main method for running the bootloader.
* Application.java - has the main method for running the bootloader.
48 changes: 43 additions & 5 deletions airbyte-bootloader/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@ plugins {
}

dependencies {
annotationProcessor platform(libs.micronaut.bom)
annotationProcessor libs.bundles.micronaut.annotation.processor

implementation platform(libs.micronaut.bom)
implementation libs.bundles.micronaut

// Ensure that the versions defined in deps.toml are used
// instead of versions from transitive dependencies
implementation (libs.flyway.core) {
force = true
}
implementation (libs.jooq) {
force = true
}

implementation project(':airbyte-config:init')
implementation project(':airbyte-config:config-models')
implementation project(':airbyte-config:config-persistence')
Expand All @@ -11,19 +26,42 @@ dependencies {
implementation project(':airbyte-protocol:protocol-models')
implementation project(':airbyte-persistence:job-persistence')

implementation libs.temporal.sdk
implementation libs.flyway.core
testAnnotationProcessor platform(libs.micronaut.bom)
testAnnotationProcessor libs.bundles.micronaut.test.annotation.processor

testImplementation libs.platform.testcontainers.postgresql
testImplementation libs.bundles.micronaut.test
testImplementation libs.bundles.junit
testImplementation libs.junit.jupiter.system.stubs
testImplementation libs.platform.testcontainers.postgresql
}

mainClassName = 'io.airbyte.bootloader.Application'

application {
applicationName = "airbyte-bootloader"
mainClass = 'io.airbyte.bootloader.BootloaderApp'
applicationName = project.name
mainClass = mainClassName
applicationDefaultJvmArgs = ['-XX:+ExitOnOutOfMemoryError', '-XX:MaxRAMPercentage=75.0']
}

Properties env = new Properties()
rootProject.file('.env.dev').withInputStream { env.load(it) }

run {
// default for running on local machine.
env.each { entry ->
environment entry.getKey(), entry.getValue()
}

environment 'AIRBYTE_ROLE', System.getenv('AIRBYTE_ROLE')
environment 'AIRBYTE_VERSION', env.VERSION
environment 'DATABASE_URL', 'jdbc:postgresql://localhost:5432/airbyte'
}

test {
// Required to enable mocked beans
systemProperty("mockito.test.enabled", "true")
}

// produce reproducible archives
// (see https://docs.gradle.org/current/userguide/working_with_files.html#sec:reproducible_archives)
tasks.withType(AbstractArchiveTask) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.bootloader;

import io.micronaut.context.ApplicationContext;
import io.micronaut.runtime.Micronaut;
import lombok.extern.slf4j.Slf4j;

/**
* Main application entry point responsible for starting the server and invoking the bootstrapping
* of the Airbyte environment.
*/
@Slf4j
public class Application {

public static void main(final String[] args) {
try {
final ApplicationContext applicationContext = Micronaut.run(Application.class, args);
final Bootloader bootloader = applicationContext.getBean(Bootloader.class);
bootloader.load();
System.exit(0);
} catch (final Exception e) {
log.error("Unable to bootstrap Airbyte environment.", e);
System.exit(-1);
}
}

}
Loading

0 comments on commit 9b05e22

Please sign in to comment.