From 338cf403c3506e0266f8728528ca921496ae2b96 Mon Sep 17 00:00:00 2001 From: Jeromy Cannon Date: Thu, 19 Oct 2023 13:17:45 -0500 Subject: [PATCH] feat: add Gradle build docker image tasks (#408) Signed-off-by: Jeromy Cannon --- docker/kubectl-bats/build.gradle.kts | 36 +++++++++++++++++++++++ docker/ubi8-init-dind/build.gradle.kts | 36 +++++++++++++++++++++++ docker/ubi8-init-java17/build.gradle.kts | 37 ++++++++++++++++++++++++ fullstack-gradle-plugin/build.gradle.kts | 2 +- settings.gradle.kts | 25 +++++++++------- 5 files changed, 124 insertions(+), 12 deletions(-) create mode 100644 docker/kubectl-bats/build.gradle.kts create mode 100644 docker/ubi8-init-dind/build.gradle.kts create mode 100644 docker/ubi8-init-java17/build.gradle.kts diff --git a/docker/kubectl-bats/build.gradle.kts b/docker/kubectl-bats/build.gradle.kts new file mode 100644 index 000000000..40cc1cf95 --- /dev/null +++ b/docker/kubectl-bats/build.gradle.kts @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id("com.palantir.docker") version "0.35.0" +} + +var repo = "ghcr.io" +var registry = "hashgraph/full-stack-testing" +var containerName = "kubectl-bats" +var appVersion = project.version.toString() + +docker { + name = "${repo}/${registry}/${containerName}:${appVersion}" + version = appVersion + buildx(true) + if (!System.getenv("CI").isNullOrEmpty()) { + platform("linux/arm64", "linux/amd64") + push(true) + } else { + load(true) // loads the image into the local docker daemon, doesn't support multi-platform + } +} diff --git a/docker/ubi8-init-dind/build.gradle.kts b/docker/ubi8-init-dind/build.gradle.kts new file mode 100644 index 000000000..53d1192b5 --- /dev/null +++ b/docker/ubi8-init-dind/build.gradle.kts @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id("com.palantir.docker") version "0.35.0" +} + +var repo = "ghcr.io" +var registry = "hashgraph/full-stack-testing" +var containerName = "ubi8-init-dind" +var appVersion = project.version.toString() + +docker { + name = "${repo}/${registry}/${containerName}:${appVersion}" + version = appVersion + buildx(true) + if (!System.getenv("CI").isNullOrEmpty()) { + platform("linux/arm64", "linux/amd64") + push(true) + } else { + load(true) // loads the image into the local docker daemon, doesn't support multi-platform + } +} diff --git a/docker/ubi8-init-java17/build.gradle.kts b/docker/ubi8-init-java17/build.gradle.kts new file mode 100644 index 000000000..5737a756f --- /dev/null +++ b/docker/ubi8-init-java17/build.gradle.kts @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id("com.palantir.docker") version "0.35.0" +} + +var repo = "ghcr.io" +var registry = "hashgraph/full-stack-testing" +var containerName = "ubi8-init-java17" +var appVersion = project.version.toString() + +docker { + name = "${repo}/${registry}/${containerName}:${appVersion}" + version = appVersion + files("entrypoint.sh", "network-node.service") + buildx(true) + if (!System.getenv("CI").isNullOrEmpty()) { + platform("linux/arm64", "linux/amd64") + push(true) + } else { + load(true) // loads the image into the local docker daemon, doesn't support multi-platform + } +} diff --git a/fullstack-gradle-plugin/build.gradle.kts b/fullstack-gradle-plugin/build.gradle.kts index 296d12db0..408ab5c29 100644 --- a/fullstack-gradle-plugin/build.gradle.kts +++ b/fullstack-gradle-plugin/build.gradle.kts @@ -16,7 +16,7 @@ plugins { id("java-gradle-plugin") - id("com.gradle.plugin-publish").version("1.2.1") + id("com.gradle.plugin-publish") version "1.2.1" id("com.hedera.fullstack.root") id("com.hedera.fullstack.conventions") id("com.hedera.fullstack.maven-publish") diff --git a/settings.gradle.kts b/settings.gradle.kts index 2f2ec2531..9a54d6d97 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -14,28 +14,26 @@ * limitations under the License. */ -pluginManagement { - includeBuild("build-logic") - // includeBuild("fullstack-gradle-plugin") -} +pluginManagement { includeBuild("build-logic") } plugins { - id("com.gradle.enterprise").version("3.14.1") + id("com.gradle.enterprise") version "3.14.1" id("com.hedera.fullstack.settings") - // id("com.hedera.fullstack.fullstack-gradle-plugin") -} - -dependencyResolutionManagement { - // includeBuild("fullstack-gradle-plugin") } rootProject.name = "full-stack-testing" includeBuild(".") // https://github.com/gradlex-org/java-module-dependencies/issues/26 +// Include the subprojects +include(":docker-kubectl-bats", "docker/kubectl-bats") + +include(":docker-ubi8-init-dind", "docker/ubi8-init-dind") + +include(":docker-ubi8-init-java17", "docker/ubi8-init-java17") + include(":fullstack-bom") -// Include the subprojects include(":fullstack-alerting-api") include(":fullstack-alerting-core") @@ -95,3 +93,8 @@ gradleEnterprise { } } } + +fun include(name: String, path: String) { + include(name) + project(name).projectDir = File(rootDir, path) +}