setup docker build
parent
332c73f5fd
commit
dfa8dcb6e9
@ -0,0 +1,50 @@
|
||||
.gradle
|
||||
build/
|
||||
!gradle/wrapper/gradle-wrapper.jar
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### Git ###
|
||||
.git
|
||||
.gitignore
|
||||
|
||||
### Docker ###
|
||||
.dockerignore
|
||||
Dockerfile
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
out/
|
||||
!**/src/main/**/out/
|
||||
!**/src/test/**/out/
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
bin/
|
||||
!**/src/main/**/bin/
|
||||
!**/src/test/**/bin/
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
@ -0,0 +1,33 @@
|
||||
FROM eclipse-temurin:21-jdk-alpine AS build
|
||||
|
||||
WORKDIR /root/app
|
||||
|
||||
# Download Gradle
|
||||
COPY ./gradle ./gradle
|
||||
COPY ./gradlew ./
|
||||
RUN ./gradlew --no-daemon --info --stacktrace
|
||||
|
||||
# Download Dependencies
|
||||
COPY ./buildSrc ./buildSrc
|
||||
COPY ./settings.gradle.kts ./
|
||||
COPY ./bot-api/build.gradle.kts ./bot-api/
|
||||
COPY ./bot-database/build.gradle.kts ./bot-database/
|
||||
COPY ./management/build.gradle.kts ./management/
|
||||
COPY ./server/build.gradle.kts ./server/
|
||||
COPY ./bots/ping-bot/build.gradle.kts ./bots/ping-bot/
|
||||
COPY ./bots/pizza-bot/build.gradle.kts ./bots/pizza-bot/
|
||||
RUN ./gradlew deps --no-daemon --info --stacktrace
|
||||
|
||||
# Build Application
|
||||
COPY . .
|
||||
RUN ./gradlew build :server:jlink --no-daemon --info --stacktrace
|
||||
|
||||
FROM alpine:3.19.1
|
||||
|
||||
WORKDIR /opt/chat/
|
||||
COPY --from=build /root/app/server/build/dist/jre /opt/chat/
|
||||
|
||||
ENV JAVA_HOME="/opt/chat"
|
||||
ENV JAVA_OPTS="--enable-preview"
|
||||
ENV CHAT_BOT_CONFIG="file:/etc/chat/config.json"
|
||||
ENTRYPOINT $JAVA_HOME/bin/java $JAVA_OPTS --module eu.jonahbauer.chat.server
|
@ -0,0 +1,68 @@
|
||||
package eu.jonahbauer.chat.build.jlink
|
||||
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.file.ConfigurableFileCollection
|
||||
import org.gradle.api.file.DirectoryProperty
|
||||
import org.gradle.api.file.RegularFileProperty
|
||||
import org.gradle.api.plugins.JavaPluginExtension
|
||||
import org.gradle.api.plugins.internal.JavaPluginHelper
|
||||
import org.gradle.api.provider.ListProperty
|
||||
import org.gradle.api.tasks.*
|
||||
import org.gradle.api.tasks.internal.JavaExecExecutableUtils
|
||||
import org.gradle.jvm.toolchain.JavaToolchainService
|
||||
import org.gradle.jvm.toolchain.internal.JavaExecutableUtils
|
||||
import org.gradle.kotlin.dsl.getByType
|
||||
|
||||
abstract class JLinkTask : DefaultTask() {
|
||||
@get:OutputDirectory
|
||||
abstract val output : DirectoryProperty
|
||||
|
||||
@get:InputFile
|
||||
abstract val executable : RegularFileProperty
|
||||
|
||||
@get:InputFiles
|
||||
abstract val modulePath : ConfigurableFileCollection
|
||||
|
||||
@get:Input
|
||||
abstract val modules : ListProperty<String>
|
||||
|
||||
@get:Input
|
||||
abstract val options : ListProperty<String>
|
||||
|
||||
init {
|
||||
group = "distribution"
|
||||
description = "assembles a modular runtime image using jlink"
|
||||
|
||||
output.convention(project.layout.buildDirectory.dir("dist/jre"))
|
||||
modules.convention(listOf("ALL-MODULE-PATH"))
|
||||
|
||||
if (project.pluginManager.hasPlugin("java")) {
|
||||
val feature = JavaPluginHelper.getJavaComponent(project).mainFeature
|
||||
modulePath.from(feature.runtimeClasspathConfiguration)
|
||||
modulePath.from(feature.jarTask)
|
||||
|
||||
val toolchains = project.extensions.getByType(JavaToolchainService::class)
|
||||
val java = project.extensions.getByType(JavaPluginExtension::class)
|
||||
|
||||
executable.convention(toolchains.launcherFor(java.toolchain)
|
||||
.map { it.metadata.installationPath }
|
||||
.map { it.dir("bin").file("jlink") })
|
||||
}
|
||||
}
|
||||
|
||||
@TaskAction
|
||||
fun execute() {
|
||||
val args = options.get() + listOf(
|
||||
"--module-path", modulePath.asPath,
|
||||
"--output", output.get().asFile.path,
|
||||
"--add-modules", modules.get().joinToString(",")
|
||||
)
|
||||
val executable = executable.get().asFile.path
|
||||
|
||||
project.delete(output)
|
||||
project.exec {
|
||||
this.executable = executable
|
||||
this.args = args
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue