Skip to content

Commit d57a51d

Browse files
authored
Drop legacy images support (#617)
1 parent 1a919de commit d57a51d

File tree

273 files changed

+431
-7542
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

273 files changed

+431
-7542
lines changed

.ci/Jenkinsfile

+4-121
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,6 @@ String getImageMasterName(Map image) {
4141
return image["name"].replace("-PR${pr_number}", "").replace(conanVersion , "master")
4242
}
4343

44-
def buildLegacyImage(Map image, String buildArgs, String registry, String registryCredentialsID, String cacheFrom) {
45-
withCredentials([usernamePassword(credentialsId: registryCredentialsID, usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
46-
sh 'docker login --username $USERNAME --password $PASSWORD ' + "${registry}"
47-
image["pull"].each {
48-
sh "docker pull ${it} || true"
49-
}
50-
}
51-
52-
sh "docker build -t ${image["name"]} ${cacheFrom} ${buildArgs} ."
53-
}
54-
5544
def uploadImage(Map image, String fromRegistryName, String toRegistryName, String crendentialsID) {
5645
withCredentials([usernamePassword(credentialsId: crendentialsID, usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
5746
sh 'docker login --username $USERNAME --password $PASSWORD ' + "${toRegistryName}"
@@ -68,68 +57,6 @@ def uploadImage(Map image, String fromRegistryName, String toRegistryName, Strin
6857
sh "docker push ${uploadImageName}"
6958
}
7059

71-
def getLegacyImageName(Map imageData, String registry) {
72-
// <registry>/<docker_username>/<compiler><compilerVersion>(-<suffix>):<conan_version>-PR<pr_number>
73-
String name = "${imageData["dockerUsername"]}/${imageData["compiler"]}${imageData["compilerVersion"]}"
74-
name = imageData["suffix"] != null ? "${name}-${imageData["suffix"]}" : name
75-
String conanVersion = imageData["buildArgs"]["CONAN_VERSION"]
76-
// <registry>/<docker_username>/<compiler><compilerVersion>(-<suffix>):<conan_version>-jdk<JDKVersion>-<JenkinsAgentVersion>-PR<pr_number>
77-
String tag = imageData["suffix"] == "jenkins" ? "${conanVersion}-jdk${imageData["buildArgs"]["JAVA_JDK_VERSION"]}-${imageData["buildArgs"]["JENKINS_AGENT_VERSION"]}" : conanVersion
78-
tag = "${tag}-PR${imageData["pr_number"]}"
79-
return "${registry}/${name}:${tag}"
80-
}
81-
82-
def getLegacyImages(String pr_number, String registry) {
83-
Map<String, String> envValues = [:]
84-
stage('Legacy - Parse environment file') {
85-
envValues = readEnvValues("legacy/.env")
86-
}
87-
88-
List<Map> images = []
89-
stage('Legacy - Generate build matrix') {
90-
final Map baseDockerImage = ["5": "docker.io/library/ubuntu:xenial", "7": "docker.io/library/ubuntu:bionic", "9": "docker.io/library/ubuntu:eoan"]
91-
List<String> conanVersions = envValues["CONAN_VERSIONS"].split(",")
92-
93-
conanVersions.each({ String conanVersion ->
94-
List<String> gccVersions = envValues["GCC_LEGACY_VERSIONS"].split(",")
95-
96-
gccVersions.each({ String gccVersion ->
97-
String dockerUsername = envValues["DOCKER_USERNAME"]
98-
String image = "${dockerUsername}/gcc${gccVersion}"
99-
Map imageData = ["suffix": null, "buildArgs": [:], "target": null, "prefix": null, "cache": [], "pull": []]
100-
imageData["dockerUsername"] = dockerUsername
101-
imageData["compiler"] = "gcc"
102-
imageData["compilerVersion"] = gccVersion
103-
imageData["pr_number"] = pr_number
104-
imageData["path"] = "legacy/gcc_${gccVersion}"
105-
imageData["buildArgs"]["CONAN_VERSION"] = conanVersion
106-
imageData["buildArgs"]["BUILDKIT_INLINE_CACHE"] = "1" // Enable BuildKit cache
107-
imageData["name"] = getLegacyImageName(imageData, registry)
108-
// pull images from registry to be used as cache
109-
String masterImageName = getImageMasterName(imageData)
110-
imageData["cache"] = [imageData["name"], masterImageName]
111-
imageData["pull"] = [imageData["name"], masterImageName, baseDockerImage[gccVersion]]
112-
images.add(imageData)
113-
114-
Map jenkinsImageData = imageData.clone()
115-
jenkinsImageData["suffix"] = "jenkins"
116-
jenkinsImageData["buildArgs"]["SOURCE_CONANIO_IMAGE"] = imageData["name"]
117-
jenkinsImageData["buildArgs"]["JENKINS_AGENT_VERSION"] = envValues["JENKINS_AGENT_VERSION"]
118-
jenkinsImageData["buildArgs"]["JAVA_JDK_VERSION"] = envValues["JAVA_JDK_VERSION"]
119-
jenkinsImageData["path"] = "legacy/jenkins"
120-
jenkinsImageData["name"] = getLegacyImageName(jenkinsImageData, registry)
121-
// pull images from registry to be used as cache
122-
String jenkinsImageMasterName = getImageMasterName(jenkinsImageData)
123-
jenkinsImageData["cache"] = [jenkinsImageData["name"], jenkinsImageMasterName]
124-
jenkinsImageData["pull"] = [jenkinsImageData["name"], imageData["name"], jenkinsImageMasterName]
125-
images.add(jenkinsImageData)
126-
})
127-
})
128-
129-
}
130-
return images
131-
}
132-
13360
def getModernImageName(Map imageData, String registry) {
13461
if (imageData["prefix"] == "base") {
13562
// base: <registry>/<docker_username>/<prefix>-<distro>:<conan_version>-PR<pr_number>
@@ -152,7 +79,7 @@ def getModernImageName(Map imageData, String registry) {
15279
def defineModernBaseImageData(Map envValues, String pr_number, String registry, String conanVersion) {
15380
Map imageData = ["buildArgs": [:], "target": null, "suffix": null, "prefix": null , "pull": [], "cache": []]
15481
imageData["prefix"] = "base"
155-
imageData["path"] = "modern/base"
82+
imageData["path"] = "images/base"
15683
imageData['distro'] = envValues["DISTRO"]
15784
imageData["dockerUsername"] = envValues["DOCKER_USERNAME"]
15885
imageData["pr_number"] = pr_number
@@ -191,7 +118,7 @@ def defineModernImagesData(String compiler, String compilerVersion, Map envValue
191118
builderImage["buildArgs"]["CONAN_VERSION"] = conanVersion
192119
builderImage["buildArgs"]['DOCKER_TAG'] = "${conanVersion}-PR${pr_number}"
193120
builderImage["buildArgs"]["${compiler.toUpperCase()}_VERSION"] = envValues["${compiler.toUpperCase()}${compilerVersion}_VERSION"]
194-
builderImage["path"] = "modern/${compiler}"
121+
builderImage["path"] = "images/${compiler}"
195122
builderImage["suffix"] = "builder"
196123
builderImage["target"] = "builder"
197124
builderImage["name"] = getModernImageName(builderImage, registry)
@@ -218,7 +145,7 @@ def defineModernImagesData(String compiler, String compilerVersion, Map envValue
218145
jenkinsImage["buildArgs"]["SOURCE_CONANIO_IMAGE"] = deployImage["name"]
219146
jenkinsImage["buildArgs"]["JENKINS_AGENT_VERSION"] = envValues["JENKINS_AGENT_VERSION"]
220147
jenkinsImage["buildArgs"]["JAVA_JDK_VERSION"] = envValues["JAVA_JDK_VERSION"]
221-
jenkinsImage["path"] = "modern/jenkins"
148+
jenkinsImage["path"] = "images/jenkins"
222149
jenkinsImage["name"] = getModernImageName(jenkinsImage, registry)
223150
// pull images from registry to be used as cache
224151
String jenkinsImageMasterName = getImageMasterName(jenkinsImage)
@@ -233,7 +160,7 @@ def defineModernImagesData(String compiler, String compilerVersion, Map envValue
233160
def getModernImages(String pr_number, String registry) {
234161
Map<String, String> envValues = [:]
235162
stage('Modern - Parse environment file') {
236-
envValues = readEnvValues("modern/.env")
163+
envValues = readEnvValues("images/.env")
237164
}
238165

239166
List<Map> images = []
@@ -257,43 +184,6 @@ def getModernImages(String pr_number, String registry) {
257184
return images
258185
}
259186

260-
def buildLegacyImages(List<Map> images, String registry, String registryCredentialsID) {
261-
// Define helper function to build the image
262-
Closure imageBuild = { Map image ->
263-
return {
264-
node('Linux') {
265-
String buildArgsStr = image["buildArgs"].collect({ k, v -> "--build-arg ${k }=${v }" }).join(' ') as String
266-
String cacheFrom = image["cache"].collect({"--cache-from=${it}"}).join(' ') as String
267-
268-
environment {
269-
DOCKER_BUILDKIT = 1
270-
COMPOSE_DOCKER_CLI_BUILD = 0
271-
}
272-
273-
stage('Legacy - Checkout sources') {
274-
checkout scm
275-
}
276-
277-
stage("Legacy - Build image ${image["name"]}") {
278-
dir(image["path"]) {
279-
buildLegacyImage(image, buildArgsStr, registry, registryCredentialsID, cacheFrom)
280-
}
281-
}
282-
283-
stage("Legacy - Upload image ${image["name"]} to Artifactory") {
284-
uploadImage(image, registry, registry, registryCredentialsID)
285-
}
286-
}
287-
}
288-
}
289-
290-
// Build images in parallel
291-
List<Map> normalImages = images.findAll({ Map image -> !image["name"].contains("jenkins") })
292-
List<Map> jenkinsImages = images.findAll({ Map image -> image["name"].contains("jenkins") })
293-
buildParallel("Legacy image", normalImages, imageBuild)
294-
buildParallel("Legacy image jenkins", jenkinsImages, imageBuild)
295-
}
296-
297187
def buildParallel(String stageName, List images, Closure closure) {
298188
Map builds = [:]
299189
images.each { Map image ->
@@ -419,29 +309,22 @@ node('Linux') {
419309
return // Outside stage
420310
}
421311

422-
List<Map> legacyImages = getLegacyImages(pr_number, "center-c3i-docker.jfrog.io")
423-
echo "Legacy images: ${legacyImages}"
424312
List<Map> modernImages = getModernImages(pr_number, "center-c3i-docker.jfrog.io")
425313
echo "Modern images: ${modernImages}"
426314

427315
if (!isMasterbranch) {
428-
// Build Legacy Images
429-
buildLegacyImages(legacyImages, "center-c3i-docker.jfrog.io", "center-c3i-docker")
430-
431316
// Build Modern Images
432317
buildModernImages(modernImages, "center-c3i-docker.jfrog.io", "center-c3i-docker")
433318
}
434319

435320
if (isMasterbranch) {
436321
// Tag images as definitive (without pr_number)
437-
legacyImages = tagImagesWithoutPRNumber(legacyImages, pr_number, "center-c3i-docker.jfrog.io", "center-c3i-docker")
438322
modernImages = tagImagesWithoutPRNumber(modernImages, pr_number, "center-c3i-docker.jfrog.io", "center-c3i-docker")
439323

440324
// Filter images to promote in hub.docker only. Do not promote base and builder images
441325
List<Map> modernDeployImages = modernImages.findAll({ Map image -> image["name"].contains("jenkins") || image["target"] == "deploy" })
442326

443327
// Promote to dockerhub
444-
promoteImages(legacyImages, "center-c3i-docker.jfrog.io", "center-c3i-docker", "docker.io", "docker-credentials")
445328
promoteImages(modernDeployImages, "center-c3i-docker.jfrog.io", "center-c3i-docker", "docker.io", "docker-credentials")
446329

447330
// TODO: Clean images from PR that are in Artifactory

.ci/on_conan_release.jenkinsfile

+3-12
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,17 @@ node('Linux') {
99
echo """
1010
- conan_version: ${params.conan_version}
1111
- build_new_images: ${params.build_new_images}
12-
- build_old_images: ${params.build_old_images}
1312
"""
1413
}
1514

1615
stage('New docker images') {
1716
// Trigger the build
18-
if (params.build_new_images || params.build_old_images) {
17+
if (params.build_new_images) {
1918
// We need to wait for a while, to be sure that new release will be returned from the API
2019
sleep time: 120, unit: 'SECONDS'
2120
if (params.build_new_images) {
2221
build(job: 'ConanCenterIndex', wait: false)
2322
}
24-
if (params.build_old_images) {
25-
build(job: 'ConanCenterIndexLegacy', wait: false)
26-
}
2723
}
2824
}
2925

@@ -38,15 +34,10 @@ node('Linux') {
3834
relativeTargetDir: 'conan-docker-tools']],
3935
])
4036

41-
String content1 = readFile(file: 'conan-docker-tools/modern/.env')
37+
String content1 = readFile(file: 'conan-docker-tools/images/.env')
4238
content1 = content1.replaceAll(/CONAN_VERSION=\d+\.\d+.\d+/, "CONAN_VERSION=${params.conan_version}")
4339
content1 = content1.replaceAll(/DOCKER_TAG=\d+\.\d+.\d+/, "DOCKER_TAG=${params.conan_version}")
44-
writeFile(file: 'conan-docker-tools/modern/.env', text: content1)
45-
46-
String content2 = readFile(file: 'conan-docker-tools/legacy/.env')
47-
content2 = content2.replaceAll(/CONAN_VERSION=\d+\.\d+.\d+/, "CONAN_VERSION=${params.conan_version}")
48-
content2 = content2.replaceAll(/DOCKER_BUILD_TAG=\d+\.\d+.\d+/, "DOCKER_BUILD_TAG=${params.conan_version}")
49-
writeFile(file: 'conan-docker-tools/legacy/.env', text: content2)
40+
writeFile(file: 'conan-docker-tools/images/.env', text: content1)
5041

5142
String branchName = "bot/release-${params.conan_version}".replaceAll(/\./, '_')
5243
dir('conan-docker-tools') {

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
__pycache__/
55
_venv/
66
.idea/
7-
modern/tests/tmp/
7+
images/tests/tmp/

README.md

+5-14
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
Dockerfiles for different GCC and Clang compiler versions.
1111
You can use these images directly in your project or with the [conan-package-tools project](https://github.com/conan-io/conan-package-tools).
1212

13+
### Note about Conan Docker Tools
14+
1315
> :warning: **Warning:**
1416
The images listed below are intended for **generating open-source library packages** and we cannot guarantee any kind of stability. We strongly recommend using your own generated images for production environments taking the dockerfiles in this repository as a reference.
1517

@@ -26,26 +28,15 @@ $ docker run -it conanio/gcc11-ubuntu16.04:2.2.2
2628

2729
### Storage and availability
2830

29-
First, check what images are still maintained in the [legacy](legacy/README.md#official-docker-images) and [modern](modern/README.md#official-docker-images) folder.
31+
First, [images](images/README.md#official-docker-images) folder.
3032

3133
All public images are stored in the Docker Hub under the `conanio` organization. You can find them [here](https://hub.docker.com/r/conanio/).
3234

3335
Also, there is a copy for each image used internally by ConanCenterIndexCI. These images are private and consumed by the Jenkins server. It keeps the images up-to-date, avoiding the Docker Hub rate limit and network delays.
3436

35-
### Legacy and Modern images
36-
37-
There are two main folders which store our Dockerfiles [legacy](legacy/) and [modern](modern/).
38-
39-
#### Legacy
40-
41-
As the name suggests, they are our legacy, a few images are still used by Conan Center, and all of them are superseded by the Moderns images.
42-
Please, read the table below to understand which images are still maintained. All images produced by legacy only contain the compiler name, version, and arch, e.g. `conanio/gcc10`, `conan/gcc7-armv7hf`
43-
Also, all non-x64 images are no longer supported. Because we do not use them on Conan Center, we do not have maintainers/experts enough to keep them, and we have only a few users looking for them.
44-
For personal projects, avoid the legacy folder.
45-
46-
#### Modern
37+
#### Images
4738

48-
The Modern folder stores our new design, re-using the same Dockerfile for any compiler version. Consider this folder for new projects, as we will maintain it for a long period. All images generated by modern design are named using the compiler name, version, distro and its version, e.g. `conanio/gcc11-ubuntu16.04`. Only x64 is supported. Please, read the issue [#205](https://github.com/conan-io/conan-docker-tools/issues/205) to obtain more information about our decision related to design, distro version, glibc support, system package and compilers.
39+
The images folder stores our new design, re-using the same Dockerfile for any compiler version. Consider this folder for new projects, as we will maintain it for a long period. All images generated by modern design are named using the compiler name, version, distro and its version, e.g. `conanio/gcc11-ubuntu16.04`. Only x64 is supported. Please, read the issue [#205](https://github.com/conan-io/conan-docker-tools/issues/205) to obtain more information about our decision related to design, distro version, glibc support, system package and compilers.
4940

5041
### LICENSE
5142

bump_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ def update_versions(file_path, new_version):
1919

2020
args = parser.parse_args()
2121

22-
for file_path in ['legacy/.env', 'modern/.env']:
22+
for file_path in ['images/.env']:
2323
update_versions(file_path, args.conan_version)
2424
print(f"Updated CONAN_VERSION and DOCKER_TAG to {args.conan_version} in {file_path}")

modern/.env images/.env

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CONAN_VERSIONS=2.9.1,1.65.0
1+
CONAN_VERSIONS=2.9.1
22
CONAN_VERSION=2.9.1
33

44
DOCKER_TAG=2.9.1

0 commit comments

Comments
 (0)