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

Specify a custom container registry #970

Merged
merged 27 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7aba7e9
Use defined images
Luigi96 Jul 5, 2024
7f39d84
Add container registry property
Luigi96 Jul 6, 2024
30f7e77
Fix mispell of buildArgs
Luigi96 Jul 6, 2024
d9ee331
Try simpifing buildArgs
Luigi96 Jul 6, 2024
154f67c
Fix build arg
Luigi96 Jul 6, 2024
f35393f
Print container registry and build args
Luigi96 Jul 6, 2024
53aa384
Use container registry arg in gosu
Luigi96 Jul 8, 2024
6498a0e
Set container registry without build-args
Luigi96 Jul 8, 2024
0ada1d6
Fix adding build arguments
Luigi96 Jul 8, 2024
58a9e83
Add container registry argument to dockerfiles and docker build cmds
Luigi96 Jul 9, 2024
c1b65d3
Add container registry property to RedHat tests
Luigi96 Jul 11, 2024
214cb4d
Print container registry
Luigi96 Jul 11, 2024
0f608fc
Use environment variable to set registry
Luigi96 Jul 11, 2024
033aaea
Debug container registry
Luigi96 Jul 11, 2024
ede4f8a
Print container registry on gradle for debug
Luigi96 Jul 11, 2024
2e01b35
Add container registry option to all distros
Luigi96 Jul 11, 2024
6922459
Fix container registry for debian Dockerfile
Luigi96 Jul 13, 2024
b3b5004
Fix bug when container registry wasn't set
Luigi96 Jul 13, 2024
a3ba961
Fix missing semicolons
Luigi96 Jul 16, 2024
6a85e4e
Fix issue to send container registry when testing
Luigi96 Jul 17, 2024
4049cec
Print docker.io as default container registry
Luigi96 Aug 6, 2024
23571e9
Add just CONTAINER_REGISTRY as build argument
Luigi96 Aug 10, 2024
5063d19
Merge branch 'master' into user-defined-image
Luigi96 Aug 12, 2024
ef617ed
Fix identation issues
Luigi96 Aug 14, 2024
ef7c006
Check if container registry is not null or empty string
Luigi96 Aug 15, 2024
2d37877
Fix image order
Luigi96 Aug 15, 2024
9b399d5
Merge branch 'master' into user-defined-image
Luigi96 Aug 24, 2024
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
4 changes: 4 additions & 0 deletions linux/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,8 @@ def getInputDir() {

def getLocalBuildStatus() {
return hasProperty("INPUT_DIR") ? "true" : "false"
}

def getContainerRegistry() {
karianna marked this conversation as resolved.
Show resolved Hide resolved
return hasProperty("CONTAINER_REGISTRY") ? CONTAINER_REGISTRY.toString() : ""
}
11 changes: 11 additions & 0 deletions linux/ca-certificates/debian/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ task packageCaCertificatesDebian {
def outputDir = new File(project.buildDir.absolutePath, "ospackage")
outputs.dir(outputDir)

// Get container registry property. If not set, return empty string that is equivalent to dockerhub
def containerRegistry = getContainerRegistry()

doLast {
project.copy {
from("src/main/packaging/")
Expand All @@ -84,6 +87,7 @@ task packageCaCertificatesDebian {
workingDir "src/main/packaging"
commandLine "docker", "build", "--no-cache",
"-t", "adoptium-packages-linux-cacerts-debian",
"--build-arg=CONTAINER_REGISTRY=${containerRegistry}",
"-f", "Dockerfile",
getProjectDir().absolutePath + "/src/main/packaging"
}
Expand All @@ -108,8 +112,15 @@ task checkCaCertificatesDebian(type: Test) {
testClassesDirs = sourceSets.packageTest.output.classesDirs
classpath = sourceSets.packageTest.runtimeClasspath

def containerRegistry = getContainerRegistry()
karianna marked this conversation as resolved.
Show resolved Hide resolved

environment "PACKAGE", "adoptium-ca-certificates"

if (containerRegistry != null && containerRegistry != "") {
environment "containerRegistry", "$containerRegistry"
println "Container registry set to $containerRegistry"
}

useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
Expand Down
4 changes: 3 additions & 1 deletion linux/ca-certificates/debian/src/main/packaging/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM debian:bullseye
ARG CONTAINER_REGISTRY=""

FROM ${CONTAINER_REGISTRY}debian:bullseye
karianna marked this conversation as resolved.
Show resolved Hide resolved

# Combine apt-get update with apt-get install to prevent stale package indexes.
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,25 @@ public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
* Ubuntu policy: Current LTS versions, and development version.
* (https://wiki.ubuntu.com/Releases)
*/

String containerRegistry = "";

if (System.getenv("containerRegistry") == null) {
System.out.println("Using docker.io as the default container registry");
} else {
containerRegistry = System.getenv("containerRegistry");
System.out.println("Using container registry: " + containerRegistry);
}

return Stream.of(
Arguments.of("debian", "trixie"), // Debian/13 (testing)
Arguments.of("debian", "bookworm"), // Debian/12 (testing)
Arguments.of("debian", "bullseye"), // Debian/11 (stable)
Arguments.of("debian", "buster"), // Debian/10 (oldstable)
Arguments.of("ubuntu", "noble"), // Ubuntu/24.04 (LTS)
Arguments.of("ubuntu", "jammy"), // Ubuntu/22.04 (LTS)
Arguments.of("ubuntu", "focal"), // Ubuntu/20.04 (LTS)
Arguments.of("ubuntu", "bionic") // Ubuntu/18.04 (LTS)
Arguments.of(containerRegistry + "debian", "trixie"), // Debian/13 (testing)
Arguments.of(containerRegistry + "debian", "bookworm"), // Debian/12 (testing)
Arguments.of(containerRegistry + "debian", "bullseye"), // Debian/11 (stable)
Arguments.of(containerRegistry + "debian", "buster"), // Debian/10 (oldstable)
Arguments.of(containerRegistry + "ubuntu", "noble"), // Ubuntu/24.04 (LTS)
Arguments.of(containerRegistry + "ubuntu", "jammy"), // Ubuntu/22.04 (LTS)
Arguments.of(containerRegistry + "ubuntu", "focal"), // Ubuntu/20.04 (LTS)
Arguments.of(containerRegistry + "ubuntu", "bionic") // Ubuntu/18.04 (LTS)
);
}
}
11 changes: 11 additions & 0 deletions linux/jdk/alpine/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ task packageJdkAlpine {
def gpgKey = getGPGKey()
def arch = getArch()

// Get container registry property. If not set, return empty string that is equivalent to dockerhub. If not set, return empty string that is equivalent to dockerhub
def containerRegistry = getContainerRegistry()

doLast {
if (!file("src/main/packaging/$product/$productVersion").exists()) {
throw new IllegalArgumentException("Unknown product $product/$productVersion")
Expand All @@ -84,6 +87,7 @@ task packageJdkAlpine {
commandLine "docker", "build", "--no-cache",
"-t", "adoptium-packages-linux-jdk-alpine",
"--secret", "id=gpg,src=${gpgKey}",
"--build-arg=CONTAINER_REGISTRY=${containerRegistry}",
"-f", "Dockerfile",
getProjectDir().absolutePath + "/src/main/packaging"
}
Expand All @@ -92,6 +96,7 @@ task packageJdkAlpine {
workingDir "src/main/packaging"
commandLine "docker", "build", "--no-cache",
"-t", "adoptium-packages-linux-jdk-alpine",
"--build-arg=CONTAINER_REGISTRY=${containerRegistry}",
"-f", "Dockerfile",
getProjectDir().absolutePath + "/src/main/packaging"
}
Expand Down Expand Up @@ -120,13 +125,19 @@ task checkJdkAlpine(type: Test) {
def product = getProduct()
def productVersion = getProductVersion()
def gpgKey = getGPGKey()
def containerRegistry = getContainerRegistry()

environment "PACKAGE", "${product}-${productVersion}-jdk"
if (gpgKey != null) {
environment "JDKGPG", "$gpgKey"
println "We set the gpgkey!"
}

if (containerRegistry != null && containerRegistry != "") {
environment "containerRegistry", "$containerRegistry"
println "Container registry set to $containerRegistry"
}

useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
Expand Down
4 changes: 3 additions & 1 deletion linux/jdk/alpine/src/main/packaging/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM alpine
ARG CONTAINER_REGISTRY=""

FROM ${CONTAINER_REGISTRY}alpine
ENV GOSU_VERSION 1.14

RUN set -eux; \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,25 @@ public class AlpineFlavours implements ArgumentsProvider {
@Override
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
/*
* Alpine policy: current (alive) releases and development version.
* (https://alpinelinux.org/releases/)
* Alpine policy: current (alive) releases and development version.
* (https://alpinelinux.org/releases/)
*/

String containerRegistry = "";

if (System.getenv("containerRegistry") == null) {
System.out.println("Using docker.io as the default container registry");
} else {
containerRegistry = System.getenv("containerRegistry");
System.out.println("Using container registry: " + containerRegistry);
}

return Stream.of(
Arguments.of("alpine", "edge"),
Arguments.of("alpine", "latest"),
Arguments.of("alpine", "3.19"),
Arguments.of("alpine", "3.18"),
Arguments.of("alpine", "3.17")
Arguments.of(containerRegistry + "alpine", "edge"),
Arguments.of(containerRegistry + "alpine", "latest"),
Arguments.of(containerRegistry + "alpine", "3.19"),
Arguments.of(containerRegistry + "alpine", "3.18"),
Arguments.of(containerRegistry + "alpine", "3.17")
);
}
}
13 changes: 13 additions & 0 deletions linux/jdk/debian/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ task packageJdkDebian {
def input_dir = getInputDir()
def buildLocalFlag = getLocalBuildStatus()

// Get container registry property. If not set, return empty string that is equivalent to dockerhub
def containerRegistry = getContainerRegistry()

doLast {
if (!file("src/main/packaging/$product/$productVersion").exists()) {
throw new IllegalArgumentException("Unknown product $product/$productVersion")
Expand Down Expand Up @@ -107,6 +110,7 @@ if ("$arch" == "armhf") {
commandLine "docker", "build", "--no-cache",
"--build-arg", "IMAGE=arm32v7/debian:bullseye",
"-t", "adoptium-packages-linux-jdk-debian",
"--build-arg=CONTAINER_REGISTRY=${containerRegistry}",
"-f", "Dockerfile",
getProjectDir().absolutePath + "/src/main/packaging"
}
Expand All @@ -118,6 +122,7 @@ if ("$arch" == "riscv64") {
commandLine "docker", "build", "--no-cache",
"--build-arg", "IMAGE=riscv64/ubuntu:jammy",
"-t", "adoptium-packages-linux-jdk-debian",
"--build-arg=CONTAINER_REGISTRY=${containerRegistry}",
"-f", "Dockerfile",
getProjectDir().absolutePath + "/src/main/packaging"
}
Expand All @@ -128,6 +133,7 @@ if ("$arch" != "armhf" && "$arch" != "riscv64"){
workingDir "src/main/packaging"
commandLine "docker", "build", "--no-cache",
"-t", "adoptium-packages-linux-jdk-debian",
"--build-arg=CONTAINER_REGISTRY=${containerRegistry}",
"-f", "Dockerfile",
getProjectDir().absolutePath + "/src/main/packaging"
}
Expand Down Expand Up @@ -159,6 +165,8 @@ task checkJdkDebian(type: Test) {

def product = getProduct()
def productVersion = getProductVersion()

def containerRegistry = getContainerRegistry()

// If product is microsoft set it as msopenjdk
if (product == "microsoft") {
Expand All @@ -167,6 +175,11 @@ task checkJdkDebian(type: Test) {
environment "PACKAGE", "$product-$productVersion-jdk"
}

if (containerRegistry != null && containerRegistry != "") {
environment "containerRegistry", "$containerRegistry"
println "Container registry set to $containerRegistry"
}

useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
Expand Down
3 changes: 2 additions & 1 deletion linux/jdk/debian/src/main/packaging/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ARG CONTAINER_REGISTRY=""
ARG IMAGE=debian:bullseye
FROM $IMAGE
FROM ${CONTAINER_REGISTRY}${IMAGE}

# Combine apt-get update with apt-get install to prevent stale package indexes.
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential \
Expand Down
48 changes: 29 additions & 19 deletions linux/jdk/debian/src/packageTest/java/packaging/DebianFlavours.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,33 @@
* @author luozhenyu
*/
public class DebianFlavours implements ArgumentsProvider {
@Override
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
/*
* Debian policy: oldstable, stable and testing version.
* (https://www.debian.org/releases/)
* Ubuntu policy: Current LTS versions, and development version.
* (https://wiki.ubuntu.com/Releases)
*/
return Stream.of(
Arguments.of("debian", "trixie"), // Debian/13 (testing)
Arguments.of("debian", "bookworm"), // Debian/12 (testing)
Arguments.of("debian", "bullseye"), // Debian/11 (stable)
Arguments.of("debian", "buster"), // Debian/10 (oldstable)
Arguments.of("ubuntu", "noble"), // Ubuntu/24.04 (LTS)
Arguments.of("ubuntu", "jammy"), // Ubuntu/22.04 (LTS)
Arguments.of("ubuntu", "focal"), // Ubuntu/20.04 (LTS)
Arguments.of("ubuntu", "bionic") // Ubuntu/18.04 (LTS)
);
}
@Override
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
/*
* Debian policy: oldstable, stable and testing version.
* (https://www.debian.org/releases/)
* Ubuntu policy: Current LTS versions, and development version.
* (https://wiki.ubuntu.com/Releases)
*/

String containerRegistry = "";

if (System.getenv("containerRegistry") == null) {
System.out.println("Using docker.io as the default container registry");
} else {
containerRegistry = System.getenv("containerRegistry");
System.out.println("Using container registry: " + containerRegistry);
}

return Stream.of(
Arguments.of(containerRegistry + "debian", "trixie"), // Debian/13 (testing)
Arguments.of(containerRegistry + "debian", "bookworm"), // Debian/12 (testing)
Arguments.of(containerRegistry + "debian", "bullseye"), // Debian/11 (stable)
Arguments.of(containerRegistry + "debian", "buster"), // Debian/10 (oldstable)
Arguments.of(containerRegistry + "ubuntu", "noble"), // Ubuntu/24.04 (LTS)
Arguments.of(containerRegistry + "ubuntu", "jammy"), // Ubuntu/22.04 (LTS)
Arguments.of(containerRegistry + "ubuntu", "focal"), // Ubuntu/20.04 (LTS)
Arguments.of(containerRegistry + "ubuntu", "bionic") // Ubuntu/18.04 (LTS)
);
}
}
14 changes: 14 additions & 0 deletions linux/jdk/redhat/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ task packageJdkRedHat {
def outputDir = new File(project.buildDir.absolutePath, "ospackage")
outputs.dir(outputDir)

// Get container registry property. If not set, return empty string that is equivalent to dockerhub
def containerRegistry = getContainerRegistry()

doLast {
if (!file("src/main/packaging/$product/$productVersion").exists()) {
throw new IllegalArgumentException("Unknown product $product/$productVersion")
Expand Down Expand Up @@ -97,6 +100,7 @@ task packageJdkRedHat {
commandLine "docker", "build", "--no-cache",
"-t", "adoptium-packages-linux-jdk-redhat",
"--secret", "id=gpg,src=${gpgKey}",
"--build-arg=CONTAINER_REGISTRY=${containerRegistry}",
"-f", "Dockerfile",
getProjectDir().absolutePath + "/src/main/packaging"
}
Expand All @@ -105,6 +109,7 @@ task packageJdkRedHat {
workingDir "src/main/packaging"
commandLine "docker", "build", "--no-cache",
"-t", "adoptium-packages-linux-jdk-redhat",
"--build-arg=CONTAINER_REGISTRY=${containerRegistry}",
"-f", "Dockerfile",
getProjectDir().absolutePath + "/src/main/packaging"
}
Expand Down Expand Up @@ -138,6 +143,9 @@ task checkJdkRedHat(type: Test) {
def gpgKey = getGPGKey()
def arch = getArch()

def containerRegistry = getContainerRegistry()
// def containerRegistry = "junipercontainerregistry.azurecr.io/mirror/"

// If product is microsoft set it as msopenjdk
if (product == "microsoft") {
environment "PACKAGE", "msopenjdk-$productVersion"
Expand All @@ -150,6 +158,12 @@ task checkJdkRedHat(type: Test) {
println "We set the gpgkey!"
}
environment "testArch", "$arch"

if (containerRegistry != null && containerRegistry != "") {
environment "containerRegistry", "$containerRegistry"
println "Container registry set to $containerRegistry"
}

useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
Expand Down
7 changes: 5 additions & 2 deletions linux/jdk/redhat/src/main/packaging/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
FROM fedora:38
ARG CONTAINER_REGISTRY=""

FROM ${CONTAINER_REGISTRY}tianon/gosu as gosu
karianna marked this conversation as resolved.
Show resolved Hide resolved
FROM ${CONTAINER_REGISTRY}fedora:38

RUN dnf update -y && dnf install -y rpmdevtools \
rpm-sign \
Expand All @@ -9,7 +12,7 @@ RUN dnf update -y && dnf install -y rpmdevtools \
tini \
wget

COPY --from=tianon/gosu /gosu /usr/local/bin/
COPY --from=gosu /gosu /usr/local/bin/

# Create unprivileged user for building, see
# https://github.com/hexops/dockerfile#use-a-static-uid-and-gid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,26 @@ public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
* ubi7 does not have DNF pre-installed, ubi-minimal has microdnf
* ubi8 has DNF installed
*/

String containerRegistry = "";

if (System.getenv("containerRegistry") == null) {
System.out.println("Using docker.io as the default container registry");
} else {
containerRegistry = System.getenv("containerRegistry");
System.out.println("Using container registry: " + containerRegistry);
}

return Stream.of(
Arguments.of("rockylinux", "8"),
Arguments.of("fedora", "35"),
Arguments.of("fedora", "36"),
Arguments.of("fedora", "37"),
Arguments.of("fedora", "38"),
Arguments.of("fedora", "39"),
Arguments.of("redhat/ubi8", "latest"),
Arguments.of("redhat/ubi9", "latest"),
Arguments.of("oraclelinux", "8")
Arguments.of(containerRegistry + "rockylinux", "8"),
Arguments.of(containerRegistry + "fedora", "35"),
Arguments.of(containerRegistry + "fedora", "36"),
Arguments.of(containerRegistry + "fedora", "37"),
Luigi96 marked this conversation as resolved.
Show resolved Hide resolved
Arguments.of(containerRegistry + "fedora", "38"),
Arguments.of(containerRegistry + "fedora", "39"),
Arguments.of(containerRegistry + "redhat/ubi8", "latest"),
Arguments.of(containerRegistry + "redhat/ubi9", "latest"),
Arguments.of(containerRegistry + "oraclelinux", "8")
);
}
}
Loading