-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alex Martishin
authored and
Alex Martishin
committed
Jul 11, 2023
1 parent
69eca78
commit 729f207
Showing
24 changed files
with
289 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Stage 1: Build | ||
FROM gradle:7.6.0-jdk17 AS build | ||
COPY --chown=gradle:gradle . /home/gradle/src | ||
WORKDIR /home/gradle/src | ||
RUN gradle build -x test --no-daemon | ||
|
||
# Stage 2: Run | ||
FROM openjdk:17-jdk | ||
COPY --from=build /home/gradle/src/build/libs/server.jar /app/server.jar | ||
ENTRYPOINT ["java","-jar","/app/server.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.PHONY: build run | ||
|
||
build: | ||
docker build --tag spring-coroutines:mac . | ||
|
||
run: | ||
docker run -p 8080:8080 spring-coroutines:mac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,106 @@ | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
import org.jooq.meta.jaxb.Property | ||
|
||
plugins { | ||
id("org.springframework.boot") version "3.1.0" | ||
id("io.spring.dependency-management") version "1.1.0" | ||
kotlin("jvm") version "1.8.21" | ||
kotlin("plugin.spring") version "1.8.21" | ||
id("org.springframework.boot") version "3.1.0" | ||
id("io.spring.dependency-management") version "1.1.0" | ||
kotlin("jvm") version "1.8.21" | ||
kotlin("plugin.spring") version "1.8.21" | ||
id("nu.studer.jooq") version "8.2.1" | ||
} | ||
|
||
group = "com.ttymonkey" | ||
version = "0.0.1-SNAPSHOT" | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
} | ||
java.sourceCompatibility = JavaVersion.VERSION_17 | ||
|
||
repositories { | ||
mavenCentral() | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation("org.springframework.boot:spring-boot-starter-data-r2dbc") | ||
implementation("org.springframework.boot:spring-boot-starter-webflux") | ||
implementation("com.fasterxml.jackson.module:jackson-module-kotlin") | ||
implementation("io.projectreactor.kotlin:reactor-kotlin-extensions") | ||
implementation("org.jetbrains.kotlin:kotlin-reflect") | ||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor") | ||
implementation("org.flywaydb:flyway-core:8.5.11") | ||
runtimeOnly("org.postgresql:postgresql") | ||
runtimeOnly("org.postgresql:r2dbc-postgresql") | ||
testImplementation("org.springframework.boot:spring-boot-starter-test") | ||
testImplementation("io.projectreactor:reactor-test") | ||
// webflux | ||
implementation("org.springframework.boot:spring-boot-starter-webflux") | ||
|
||
// kotlin and coroutines support | ||
implementation("com.fasterxml.jackson.module:jackson-module-kotlin") | ||
implementation("io.projectreactor.kotlin:reactor-kotlin-extensions") | ||
implementation("org.jetbrains.kotlin:kotlin-reflect") | ||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor") | ||
|
||
// r2dbc and postgresql | ||
implementation("org.springframework.boot:spring-boot-starter-data-r2dbc") | ||
runtimeOnly("org.postgresql:postgresql") | ||
runtimeOnly("org.postgresql:r2dbc-postgresql") | ||
|
||
// flyway | ||
implementation("org.flywaydb:flyway-core:8.5.11") | ||
|
||
// jooq | ||
implementation("org.springframework.boot:spring-boot-starter-jooq") | ||
implementation("org.jooq:jooq-kotlin") | ||
jooqGenerator("org.jooq:jooq-meta-extensions") | ||
|
||
// test dependencies | ||
testImplementation("org.springframework.boot:spring-boot-starter-test") | ||
testImplementation("io.projectreactor:reactor-test") | ||
} | ||
|
||
tasks.withType<KotlinCompile> { | ||
kotlinOptions { | ||
freeCompilerArgs += "-Xjsr305=strict" | ||
jvmTarget = "17" | ||
} | ||
kotlinOptions { | ||
freeCompilerArgs += "-Xjsr305=strict" | ||
jvmTarget = "17" | ||
} | ||
} | ||
|
||
tasks.withType<Test> { | ||
useJUnitPlatform() | ||
useJUnitPlatform() | ||
} | ||
|
||
jooq { | ||
configurations { | ||
create("main") { | ||
jooqConfiguration.apply { | ||
logging = org.jooq.meta.jaxb.Logging.WARN | ||
jdbc = null | ||
|
||
generator.apply { | ||
database.apply { | ||
name = "org.jooq.codegen.KotlinGenerator" | ||
name = "org.jooq.meta.extensions.ddl.DDLDatabase" | ||
|
||
properties.addAll( | ||
listOf( | ||
Property().apply { | ||
key = "scripts" | ||
value = "src/main/resources/db/migration" | ||
}, | ||
|
||
Property().apply { | ||
key = "sort" | ||
value = "flyway" | ||
}, | ||
|
||
Property().apply { | ||
key = "defaultNameCase" | ||
value = "lower" | ||
}, | ||
), | ||
) | ||
} | ||
generate.apply { | ||
isPojosAsKotlinDataClasses = true // use data classes | ||
isKotlinNotNullPojoAttributes = true | ||
} | ||
target.apply { | ||
packageName = "com.ttymonkey.springcoroutines.jooq" | ||
} | ||
strategy.name = "org.jooq.codegen.DefaultGeneratorStrategy" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
tasks.withType<org.springframework.boot.gradle.tasks.bundling.BootJar> { | ||
archiveFileName.set("server.jar") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
version: '3.1' | ||
|
||
services: | ||
app: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
environment: | ||
DB_HOST: db | ||
DB_USERNAME: postgres | ||
DB_PASSWORD: password | ||
DB_DATABASE: monkey | ||
ports: | ||
- "8080:8080" | ||
depends_on: | ||
- db | ||
db: | ||
image: postgres:15.3-alpine | ||
environment: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: password | ||
POSTGRES_DB: monkey | ||
ports: | ||
- "5432:5432" | ||
volumes: | ||
- db_data:/var/lib/postgresql/data | ||
volumes: | ||
db_data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/main/kotlin/com/ttymonkey/springcoroutines/configs/JooqConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.ttymonkey.springcoroutines.configs | ||
|
||
import io.r2dbc.spi.ConnectionFactory | ||
import org.jooq.DSLContext | ||
import org.jooq.SQLDialect | ||
import org.jooq.impl.DSL | ||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
import org.springframework.r2dbc.connection.TransactionAwareConnectionFactoryProxy | ||
|
||
@Configuration | ||
class JooqConfig(private val connectionFactory: ConnectionFactory) { | ||
|
||
@Bean | ||
fun dslContext(): DSLContext { | ||
return DSL.using(TransactionAwareConnectionFactoryProxy(connectionFactory), SQLDialect.POSTGRES) | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/kotlin/com/ttymonkey/springcoroutines/configs/R2dbcConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.ttymonkey.springcoroutines.configs | ||
|
||
import org.springframework.context.annotation.Configuration | ||
import org.springframework.data.r2dbc.config.EnableR2dbcAuditing | ||
|
||
@Configuration | ||
@EnableR2dbcAuditing | ||
class R2dbcConfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/kotlin/com/ttymonkey/springcoroutines/dto/CompanyResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/kotlin/com/ttymonkey/springcoroutines/dto/IdNameTypeResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/kotlin/com/ttymonkey/springcoroutines/dto/UserResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.