diff options
-rw-r--r-- | Dockerfile | 4 | ||||
-rw-r--r-- | build.gradle.kts | 109 | ||||
-rw-r--r-- | docker-compose.yaml | 36 |
3 files changed, 96 insertions, 53 deletions
diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..03628b8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,4 @@ +FROM openjdk:11-jdk-alpine +ARG JAR_FILE=./build/libs/src.jar +COPY ${JAR_FILE} src.jar +ENTRYPOINT ["java", "-jar", "/src.jar"] diff --git a/build.gradle.kts b/build.gradle.kts index 82758e1..4fb985e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,53 +1,56 @@ - /*https://docs.gradle.org/current/userguide/building_java_projects.html*/ - plugins { - `java-library` - // application - id("org.springframework.boot") version "2.6.4" - id("io.spring.dependency-management") version "1.0.11.RELEASE" - id("java") - } - - - repositories { - mavenCentral() - } - - sourceSets { - main { - java { - setSrcDirs(listOf("src")) - } - } - - test { - java { - setSrcDirs(listOf("test")) - } - } - } - - java { - // sourceCompatibility = JavaVersion.VERSION_11 - // targetCompatibility = JavaVersion.VERSION_11 - toolchain { - languageVersion.set(JavaLanguageVersion.of(11)) - } - } - - // application { - // mainClass.set("com.terminaldweller.Main") - // } - - tasks.compileJava { - options.isIncremental = true - options.isFork = true - options.isFailOnError = false - options.release.set(11) - } - - dependencies { - implementation("org.springframework.boot:spring-boot-starter-data-jdbc") - implementation("org.springframework.boot:spring-boot-starter-web") - runtimeOnly("org.postgresql:postgresql") - testImplementation("org.springframework.boot:spring-boot-starter-test") - } +// https://docs.gradle.org/current/userguide/building_java_projects.html +plugins { + `java-library` + // application + id("org.springframework.boot") version "2.6.4" + id("io.spring.dependency-management") version "1.0.11.RELEASE" + id("java") +} + +repositories { + mavenCentral() +} + +dependencies { + implementation("org.springframework.boot:spring-boot-starter-data-jdbc") + implementation("org.springframework.boot:spring-boot-starter-web") + runtimeOnly("org.postgresql:postgresql") + testImplementation("org.springframework.boot:spring-boot-starter-test") +} + +tasks.create("FatJar", Jar::class) { + description = "makes a fatjar" + group = "build" + manifest.attributes["Main-Class"] = "com.terminaldweller.MainApplication" + duplicatesStrategy = DuplicatesStrategy.EXCLUDE + val dependencies = configurations.runtimeClasspath.get().map(::zipTree) + from(dependencies) + with(tasks.jar.get()) +} + +sourceSets { + main { + java { + setSrcDirs(listOf("src")) + } + } + + test { + java { + setSrcDirs(listOf("test")) + } + } +} + +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(11)) + } +} + +tasks.compileJava { + options.isIncremental = true + options.isFork = true + options.isFailOnError = false + options.release.set(11) +} diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..f3c7718 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,36 @@ +version: "3" +services: + server: + postgres: + image: postgres:14-alpine + networks: + - dbnet + volumes: + - db-data:/var/lib/postgresql/14/ + ports: + - "5432:5432" + environment: + - POSTGRES_PASSWORD_FILE=/run/secrets/pg_pass_secret + - POSTGRES_USER_FILE=/run/secrets/pg_user_secret + - POSTGRES_INITDB_ARGS_FILE=/run/secrets/pg_initdb_args_secret + - POSTGRES_DB_FILE=/run/secrets/pg_db_secret + secrets: + - pg_pass_secret + - pg_user_secret + - pg_initdb_args_secret + - pg_db_secret + cap_drop: + - ALL +networks: + dbnet: +volumes: + db-data: +secrets: + pg_pass_secret: + file: ./postgres/pg_pass_secret + pg_user_secret: + file: ./postgres/pg_user_secret + pg_initdb_args_secret: + file: ./postgres/pg_initdb_args_secret + pg_db_secret: + file: ./postgres/pg_db_secret |