CatgirlIntelligenceAgency/docker-service.gradle
Viktor Lofgren 98efb08e17 (gradle) Make docker image registry and tag configurable
This is to enable running an external repository for production and test.

Use the ./gradle -Pdocker-registry=registry.foo.bar -Pdocker-tag=my-tag while building to accomplish this.  By default, use 'marginalia' for repository and 'latest' as tag.
2023-11-16 21:12:55 +01:00

42 lines
986 B
Groovy

ext {
dockerImage='openjdk:21-slim'
}
tasks.register('dockerFile') {
buildDir.mkdir()
var df = new File(buildDir, "Dockerfile")
doLast {
df.text = """#
# I'm auto-generated, please don't make changes to me or commit me to git
#
# The template exists in docker-service.gradle
#
FROM ${dockerImage}
ADD ${application.applicationName}.tar /
RUN mkdir /wmsa
ENTRYPOINT WMSA_HOME=/wmsa /${application.applicationName}/bin/${application.applicationName} \${arg0} \${arg1}
"""
}
it.outputs.file(df)
}
dockerPrepare {
dependsOn tasks.dockerFile
}
dockerfileZip {
dependsOn tasks.dockerFile
}
docker {
dockerfile = tasks.dockerFile.outputs.files.singleFile
name = (project.hasProperty('docker-registry') ? project.property('docker-registry') : 'marginalia')+'/'+application.applicationName+':' + (project.hasProperty('docker-tag') ? project.property('docker-tag') : 'latest')
files tasks.distTar.outputs
dependsOn tasks.distTar
}