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

chore(Linux): factorise jdk in docker-bake.hcl #401

Merged
merged 4 commits into from
May 10, 2024

Conversation

lemeurherve
Copy link
Member

@lemeurherve lemeurherve commented May 8, 2024

This PR factorises the JDK in docker bake file, resulting in a more concise definition of images and ensuring tagging consistency, with one block defining Alpine images, another defining Debian images, and lastly the remaining one for the special Debian 21 preview image.

I titled this PR "chore/breaking" as it depends:

EDIT: No longer a breaking change with 427788c

Note that we can still target a single image even with this factorisation:

docker buildx bake --file docker-bake.hcl alpine_21 --print 
{
  "group": {
    "default": {
      "targets": [
        "alpine_21"
      ]
    }
  },
  "target": {
    "alpine_21": {
      "context": ".",
      "dockerfile": "alpine/Dockerfile",
      "args": {
        "ALPINE_TAG": "3.19.1",
        "JAVA_VERSION": "21.0.3_9"
      },
      "tags": [
        "docker.io/jenkins/ssh-agent:1.2.3-alpine-jdk21",
        "docker.io/jenkins/ssh-agent:1.2.3-alpine3.19-jdk21",
        "docker.io/jenkins/ssh-agent:alpine-jdk21",
        "docker.io/jenkins/ssh-agent:latest-alpine-jdk21",
        "docker.io/jenkins/ssh-agent:alpine3.19-jdk21",
        "docker.io/jenkins/ssh-agent:latest-alpine3.19-jdk21"
      ],
      "platforms": [
        "linux/amd64",
        "linux/arm64"
      ]
    }
  }
}

Testing done

Verified that the output of docker buildx bake --file docker-bake.hcl linux --print with VERSION=1.2.3 & ON_TAG=true is equivalent to the one of #400:

#400
{
  "group": {
    "default": {
      "targets": [
        "linux"
      ]
    },
    "linux": {
      "targets": [
        "alpine_jdk11",
        "alpine_jdk17",
        "alpine_jdk21",
        "debian_jdk11",
        "debian_jdk17",
        "debian_jdk21",
        "debian_jdk21-preview"
      ]
    }
  },
  "target": {
    "alpine_jdk11": {
      "context": ".",
      "dockerfile": "alpine/Dockerfile",
      "args": {
        "ALPINE_TAG": "3.19.1",
        "JAVA_VERSION": "11.0.23_9"
      },
      "tags": [
        "docker.io/jenkins/ssh-agent:1.2.3-alpine-jdk11",
        "docker.io/jenkins/ssh-agent:1.2.3-alpine3.19-jdk11",
        "docker.io/jenkins/ssh-agent:alpine-jdk11",
        "docker.io/jenkins/ssh-agent:latest-alpine-jdk11",
        "docker.io/jenkins/ssh-agent:alpine3.19-jdk11",
        "docker.io/jenkins/ssh-agent:latest-alpine3.19-jdk11"
      ],
      "platforms": [
        "linux/amd64"
      ]
    },
    "alpine_jdk17": {
      "context": ".",
      "dockerfile": "alpine/Dockerfile",
      "args": {
        "ALPINE_TAG": "3.19.1",
        "JAVA_VERSION": "17.0.11_9"
      },
      "tags": [
        "docker.io/jenkins/ssh-agent:1.2.3-alpine-jdk17",
        "docker.io/jenkins/ssh-agent:1.2.3-alpine3.19-jdk17",
        "docker.io/jenkins/ssh-agent:alpine",
        "docker.io/jenkins/ssh-agent:alpine-jdk17",
        "docker.io/jenkins/ssh-agent:latest-alpine-jdk17",
        "docker.io/jenkins/ssh-agent:alpine3.19",
        "docker.io/jenkins/ssh-agent:alpine3.19-jdk17",
        "docker.io/jenkins/ssh-agent:latest-alpine3.19",
        "docker.io/jenkins/ssh-agent:latest-alpine3.19-jdk17"
      ],
      "platforms": [
        "linux/amd64"
      ]
    },
    "alpine_jdk21": {
      "context": ".",
      "dockerfile": "alpine/Dockerfile",
      "args": {
        "ALPINE_TAG": "3.19.1",
        "JAVA_VERSION": "21.0.3_9"
      },
      "tags": [
        "docker.io/jenkins/ssh-agent:1.2.3-alpine-jdk21",
        "docker.io/jenkins/ssh-agent:1.2.3-alpine3.19-jdk21",
        "docker.io/jenkins/ssh-agent:alpine-jdk21",
        "docker.io/jenkins/ssh-agent:latest-alpine-jdk21",
        "docker.io/jenkins/ssh-agent:alpine3.19-jdk21",
        "docker.io/jenkins/ssh-agent:latest-alpine3.19-jdk21"
      ],
      "platforms": [
        "linux/amd64",
        "linux/arm64"
      ]
    },
    "debian_jdk11": {
      "context": ".",
      "dockerfile": "debian/Dockerfile",
      "args": {
        "DEBIAN_RELEASE": "bookworm-20240423",
        "JAVA_VERSION": "11.0.23_9"
      },
      "tags": [
        "docker.io/jenkins/ssh-agent:1.2.3-jdk11",
        "docker.io/jenkins/ssh-agent:bookworm-jdk11",
        "docker.io/jenkins/ssh-agent:debian-jdk11",
        "docker.io/jenkins/ssh-agent:jdk11",
        "docker.io/jenkins/ssh-agent:latest-bookworm-jdk11",
        "docker.io/jenkins/ssh-agent:latest-debian-jdk11",
        "docker.io/jenkins/ssh-agent:latest-jdk11"
      ],
      "platforms": [
        "linux/amd64",
        "linux/arm64",
        "linux/s390x",
        "linux/ppc64le"
      ]
    },
    "debian_jdk17": {
      "context": ".",
      "dockerfile": "debian/Dockerfile",
      "args": {
        "DEBIAN_RELEASE": "bookworm-20240423",
        "JAVA_VERSION": "17.0.11_9"
      },
      "tags": [
        "docker.io/jenkins/ssh-agent:1.2.3",
        "docker.io/jenkins/ssh-agent:1.2.3-jdk17",
        "docker.io/jenkins/ssh-agent:bookworm-jdk17",
        "docker.io/jenkins/ssh-agent:debian-jdk17",
        "docker.io/jenkins/ssh-agent:jdk17",
        "docker.io/jenkins/ssh-agent:latest",
        "docker.io/jenkins/ssh-agent:latest-bookworm-jdk17",
        "docker.io/jenkins/ssh-agent:latest-debian-jdk17",
        "docker.io/jenkins/ssh-agent:latest-jdk17"
      ],
      "platforms": [
        "linux/amd64",
        "linux/arm64",
        "linux/ppc64le"
      ]
    },
    "debian_jdk21": {
      "context": ".",
      "dockerfile": "debian/Dockerfile",
      "args": {
        "DEBIAN_RELEASE": "bookworm-20240423",
        "JAVA_VERSION": "21.0.3_9"
      },
      "tags": [
        "docker.io/jenkins/ssh-agent:1.2.3-jdk21",
        "docker.io/jenkins/ssh-agent:bookworm-jdk21",
        "docker.io/jenkins/ssh-agent:debian-jdk21",
        "docker.io/jenkins/ssh-agent:jdk21",
        "docker.io/jenkins/ssh-agent:latest-bookworm-jdk21",
        "docker.io/jenkins/ssh-agent:latest-debian-jdk21",
        "docker.io/jenkins/ssh-agent:latest-jdk21"
      ],
      "platforms": [
        "linux/amd64",
        "linux/arm64",
        "linux/ppc64le",
        "linux/s390x"
      ]
    },
    "debian_jdk21-preview": {
      "context": ".",
      "dockerfile": "debian/preview/Dockerfile",
      "args": {
        "DEBIAN_RELEASE": "bookworm-20240423",
        "JAVA_VERSION": "21.0.1+12"
      },
      "tags": [
        "docker.io/jenkins/ssh-agent:1.2.3-jdk21-preview",
        "docker.io/jenkins/ssh-agent:bookworm-jdk21-preview",
        "docker.io/jenkins/ssh-agent:debian-jdk21-preview",
        "docker.io/jenkins/ssh-agent:jdk21-preview",
        "docker.io/jenkins/ssh-agent:latest-bookworm-jdk21-preview",
        "docker.io/jenkins/ssh-agent:latest-debian-jdk21-preview",
        "docker.io/jenkins/ssh-agent:latest-jdk21-preview"
      ],
      "platforms": [
        "linux/arm/v7"
      ]
    }
  }
}
After
{
  "group": {
    "alpine": {
      "targets": [
        "alpine_11",
        "alpine_17",
        "alpine_21"
      ]
    },
    "debian": {
      "targets": [
        "debian_11",
        "debian_17",
        "debian_21"
      ]
    },
    "default": {
      "targets": [
        "linux"
      ]
    },
    "linux": {
      "targets": [
        "alpine",
        "debian",
        "debian_jdk21-preview"
      ]
    }
  },
  "target": {
    "alpine_11": {
      "context": ".",
      "dockerfile": "alpine/Dockerfile",
      "args": {
        "ALPINE_TAG": "3.19.1",
        "JAVA_VERSION": "11.0.23_9"
      },
      "tags": [
        "docker.io/jenkins/ssh-agent:1.2.3-alpine-jdk11",
        "docker.io/jenkins/ssh-agent:1.2.3-alpine3.19-jdk11",
        "docker.io/jenkins/ssh-agent:alpine-jdk11",
        "docker.io/jenkins/ssh-agent:latest-alpine-jdk11",
        "docker.io/jenkins/ssh-agent:alpine3.19-jdk11",
        "docker.io/jenkins/ssh-agent:latest-alpine3.19-jdk11"
      ],
      "platforms": [
        "linux/amd64"
      ]
    },
    "alpine_17": {
      "context": ".",
      "dockerfile": "alpine/Dockerfile",
      "args": {
        "ALPINE_TAG": "3.19.1",
        "JAVA_VERSION": "17.0.11_9"
      },
      "tags": [
        "docker.io/jenkins/ssh-agent:1.2.3-alpine-jdk17",
        "docker.io/jenkins/ssh-agent:1.2.3-alpine3.19-jdk17",
        "docker.io/jenkins/ssh-agent:alpine",
        "docker.io/jenkins/ssh-agent:alpine3.19",
        "docker.io/jenkins/ssh-agent:latest-alpine3.19",
        "docker.io/jenkins/ssh-agent:alpine-jdk17",
        "docker.io/jenkins/ssh-agent:latest-alpine-jdk17",
        "docker.io/jenkins/ssh-agent:alpine3.19-jdk17",
        "docker.io/jenkins/ssh-agent:latest-alpine3.19-jdk17"
      ],
      "platforms": [
        "linux/amd64"
      ]
    },
    "alpine_21": {
      "context": ".",
      "dockerfile": "alpine/Dockerfile",
      "args": {
        "ALPINE_TAG": "3.19.1",
        "JAVA_VERSION": "21.0.3_9"
      },
      "tags": [
        "docker.io/jenkins/ssh-agent:1.2.3-alpine-jdk21",
        "docker.io/jenkins/ssh-agent:1.2.3-alpine3.19-jdk21",
        "docker.io/jenkins/ssh-agent:alpine-jdk21",
        "docker.io/jenkins/ssh-agent:latest-alpine-jdk21",
        "docker.io/jenkins/ssh-agent:alpine3.19-jdk21",
        "docker.io/jenkins/ssh-agent:latest-alpine3.19-jdk21"
      ],
      "platforms": [
        "linux/amd64",
        "linux/arm64"
      ]
    },
    "debian_11": {
      "context": ".",
      "dockerfile": "debian/Dockerfile",
      "args": {
        "DEBIAN_RELEASE": "bookworm-20240423",
        "JAVA_VERSION": "11.0.23_9"
      },
      "tags": [
        "docker.io/jenkins/ssh-agent:1.2.3-jdk11",
        "docker.io/jenkins/ssh-agent:bookworm-jdk11",
        "docker.io/jenkins/ssh-agent:debian-jdk11",
        "docker.io/jenkins/ssh-agent:jdk11",
        "docker.io/jenkins/ssh-agent:latest-bookworm-jdk11",
        "docker.io/jenkins/ssh-agent:latest-debian-jdk11",
        "docker.io/jenkins/ssh-agent:latest-jdk11"
      ],
      "platforms": [
        "linux/amd64",
        "linux/arm64",
        "linux/ppc64le",
        "linux/s390x"
      ]
    },
    "debian_17": {
      "context": ".",
      "dockerfile": "debian/Dockerfile",
      "args": {
        "DEBIAN_RELEASE": "bookworm-20240423",
        "JAVA_VERSION": "17.0.11_9"
      },
      "tags": [
        "docker.io/jenkins/ssh-agent:1.2.3-jdk17",
        "docker.io/jenkins/ssh-agent:1.2.3",
        "docker.io/jenkins/ssh-agent:latest",
        "docker.io/jenkins/ssh-agent:bookworm-jdk17",
        "docker.io/jenkins/ssh-agent:debian-jdk17",
        "docker.io/jenkins/ssh-agent:jdk17",
        "docker.io/jenkins/ssh-agent:latest-bookworm-jdk17",
        "docker.io/jenkins/ssh-agent:latest-debian-jdk17",
        "docker.io/jenkins/ssh-agent:latest-jdk17"
      ],
      "platforms": [
        "linux/amd64",
        "linux/arm64",
        "linux/ppc64le"
      ]
    },
    "debian_21": {
      "context": ".",
      "dockerfile": "debian/Dockerfile",
      "args": {
        "DEBIAN_RELEASE": "bookworm-20240423",
        "JAVA_VERSION": "21.0.3_9"
      },
      "tags": [
        "docker.io/jenkins/ssh-agent:1.2.3-jdk21",
        "docker.io/jenkins/ssh-agent:bookworm-jdk21",
        "docker.io/jenkins/ssh-agent:debian-jdk21",
        "docker.io/jenkins/ssh-agent:jdk21",
        "docker.io/jenkins/ssh-agent:latest-bookworm-jdk21",
        "docker.io/jenkins/ssh-agent:latest-debian-jdk21",
        "docker.io/jenkins/ssh-agent:latest-jdk21"
      ],
      "platforms": [
        "linux/amd64",
        "linux/arm64",
        "linux/ppc64le",
        "linux/s390x"
      ]
    },
    "debian_jdk21-preview": {
      "context": ".",
      "dockerfile": "debian/preview/Dockerfile",
      "args": {
        "DEBIAN_RELEASE": "bookworm-20240423",
        "JAVA_VERSION": "21.0.1+12"
      },
      "tags": [
        "docker.io/jenkins/ssh-agent:1.2.3-jdk21-preview",
        "docker.io/jenkins/ssh-agent:bookworm-jdk21-preview",
        "docker.io/jenkins/ssh-agent:debian-jdk21-preview",
        "docker.io/jenkins/ssh-agent:jdk21-preview",
        "docker.io/jenkins/ssh-agent:latest-bookworm-jdk21-preview",
        "docker.io/jenkins/ssh-agent:latest-debian-jdk21-preview",
        "docker.io/jenkins/ssh-agent:latest-jdk21-preview"
      ],
      "platforms": [
        "linux/arm/v7"
      ]
    }
  }
}

Submitter checklist

timja
timja previously approved these changes May 8, 2024
timja
timja previously approved these changes May 9, 2024
timja
timja previously approved these changes May 9, 2024
docker-bake.hcl Outdated
]
platforms = ["linux/amd64"]
variable "default_jdk" {
default = 17
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
default = 17
default = 11

Setting the default JDK to 11 so we can introduce this pull request without any (breaking) change.

Solving #399 will then be as simple as setting this default_jdk value to 17.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compared to the changes needed in https://github.com/jenkinsci/docker-ssh-agent/pull/400/files, this illustrates the benefit of this PR.

@lemeurherve lemeurherve changed the title chore/breaking(Linux): factorise jdk in docker-bake.hcl chore(Linux): factorise jdk in docker-bake.hcl May 10, 2024
@MarkEWaite MarkEWaite merged commit 0f652a6 into jenkinsci:master May 10, 2024
9 checks passed
@lemeurherve lemeurherve deleted the factorise-jdk-in-docker-bake branch May 14, 2024 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants