Skip to content

Commit

Permalink
[docker] publish a simple image
Browse files Browse the repository at this point in the history
  • Loading branch information
Le Gall, Benoit committed Aug 14, 2024
1 parent 240d44b commit 8b2986c
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,9 @@ jobs:
JRELEASER_GPG_PASSPHRASE: ${{ secrets.GNUPG_PASSPHRASE }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GNUPG_PRIVATE_KEY }}
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Containerize
run: ./gradlew jib -Djib.console='plain'
env:
DOCKER_USR: ${{ secrets.DOCKER_USR }}
DOCKER_PSW: ${{ secrets.DOCKER_PSW }}
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ plugin-grgit = "5.2.2"
plugin-jreleaser = "1.13.1"
plugin-micronaut = "4.4.2"
plugin-google-protobuf = "0.9.4"
plugin-jib = "3.4.2"

[libraries]
mockito-inline = { module = "org.mockito:mockito-inline", version.ref = "mockito-inline" }
Expand All @@ -21,3 +22,4 @@ grgit = { id = "org.ajoberstar.grgit:grgit-gradle", version.ref = "plugin-grgit"
jreleaser = { id = "org.jreleaser:jreleaser-gradle-plugin", version.ref = "plugin-jreleaser" }
micronaut = { id = "io.micronaut.gradle:micronaut-gradle-plugin", version.ref = "plugin-micronaut" }
google-protobuf = { id = "com.google.protobuf:protobuf-gradle-plugin", version.ref = "plugin-google-protobuf" }
jib = { id = "com.google.cloud.tools.jib", version.ref = "plugin-jib" }
77 changes: 77 additions & 0 deletions micronaut-api-gateway-image/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
plugins {
id("io.micronaut.minimal.application")
alias(libs.plugins.jib)
}

micronaut {
runtime("netty")
testRuntime("junit5")
processing {
incremental(true)
annotations("com.frogdevelopment.*")
}
}

java {
sourceCompatibility = JavaVersion.toVersion("21")
targetCompatibility = JavaVersion.toVersion("21")
}

dependencies {
annotationProcessor(mn.lombok)
annotationProcessor(mn.micronaut.http.validation)
annotationProcessor(mn.micronaut.serde.processor)

implementation(mn.micronaut.discovery.client)
implementation(mn.micronaut.http.client)
implementation(mn.micronaut.management)
implementation(mn.micronaut.serde.jackson)
implementation(projects.micronautApiGatewayHttp)

compileOnly(mn.lombok)

runtimeOnly(mn.logback.classic)
runtimeOnly(mn.snakeyaml)
runtimeOnly(mn.micronaut.discovery.client)

testImplementation(mn.assertj.core)
testImplementation(mn.mockito.junit.jupiter)
}

application {
mainClass.set("com.frogdevelopment.micronaut.gateway.Application")
}

tasks {
jib {

from {
image = "eclipse-temurin:21-jre-alpine"
platforms {
platform {
architecture = "amd64"
os = "linux"
}
platform {
architecture = "arm64"
os = "linux"
}
}
}

to {
image = "frogdevelopment/micronaut-api-gateway:${rootProject.version}"
if (System.getenv("CI") == "true") {
auth {
username = System.getenv("DOCKER_USR")
password = System.getenv("DOCKER_PSW")
}
}
}

container {
setMainClass(application.mainClass)
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.frogdevelopment.micronaut.gateway;

import io.micronaut.runtime.Micronaut;

public class Application {

public static void main(String[] args) {
Micronaut.run(Application.class, args);
}
}
15 changes: 15 additions & 0 deletions micronaut-api-gateway-image/src/main/resources/bootstrap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
micronaut:
application:
name: api-gateway
config-client:
enabled: true

consul:
client:
defaultZone: "${CONSUL_HOST:localhost}:${CONSUL_PORT:8500}"
config:
format: yaml
path: config/local
registration:
deregister: true
enabled: true
15 changes: 15 additions & 0 deletions micronaut-api-gateway-image/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<configuration debug="false">

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%cyan(%d{HH:mm:ss.SSS}) %gray([%thread]) %highlight(%-5level) %magenta(%logger{36}) - %msg%n
</pattern>
</encoder>
</appender>

<root level="info">
<appender-ref ref="STDOUT"/>
</root>
</configuration>
3 changes: 2 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ dependencyResolutionManagement {

include(
":micronaut-api-gateway-http",
":micronaut-api-gateway-grpc"
":micronaut-api-gateway-grpc",
":micronaut-api-gateway-image"
)

0 comments on commit 8b2986c

Please sign in to comment.