Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix docker image building #9

Merged
merged 2 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,14 @@ springBoot {
buildInfo()
}

val dockerRegistry = System.getenv().getOrDefault("DOCKER_REGISTRY", project.properties["docker.registry"]) as? String
val octopusGithubDockerRegistry = System.getenv().getOrDefault("OCTOPUS_GITHUB_DOCKER_REGISTRY", project.properties["octopus.github.docker.registry"]) as? String

docker {
springBootApplication {
baseImage.set("${rootProject.properties["docker.registry"]}/openjdk:11")
ports.set(listOf(8765, 8765))
images.set(setOf("${rootProject.properties["publishing.docker.registry"]}/${project.name}:${project.version}"))
baseImage.set("$dockerRegistry/openjdk:11")
ports.set(listOf(8888, 8888))
images.set(setOf("$octopusGithubDockerRegistry/octopusden/${project.name}:${project.version}"))
}
}

Expand All @@ -93,3 +96,16 @@ dependencies {
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("io.micrometer:micrometer-registry-prometheus:1.10.4")
}

fun validateDockerRegistryParams() {
if (dockerRegistry.isNullOrBlank() || octopusGithubDockerRegistry.isNullOrBlank()) {
throw IllegalArgumentException(
"Start gradle build with" +
(if (dockerRegistry.isNullOrBlank()) " -Pdocker.registry=..." else "") +
(if (octopusGithubDockerRegistry.isNullOrBlank()) " -Poctopus.github.docker.registry=..." else "") +
" or set env variable(s):" +
(if (dockerRegistry.isNullOrBlank()) " DOCKER_REGISTRY" else "") +
(if (octopusGithubDockerRegistry.isNullOrBlank()) " OCTOPUS_GITHUB_DOCKER_REGISTRY" else "")
)
}
}
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ kotlin.version=1.6.21
spring-cloud.version=2021.0.0
spring-boot.version=2.6.1
docker.registry=
octopus.github.docker.registry=