Skip to content

Commit

Permalink
Allow targetting Alpine Linux independently of regular Linux when dow…
Browse files Browse the repository at this point in the history
…nloading Adoptium/Eclipse Temurin builds

Adoptium now publish validated Alpine Linux builds of Eclipse Temurin JVM, compiled directly against musl libc (rather than glibc). Using these would avoid the need to use the Alpine GLIBC package which is not recommended by the Alpine team, and which is no longer supported by Adopt in their own containers. See the long discussion at adoptium/containers#1

At time of writing we cannot move away from glibc because the Tanuki wrapper does not seem to work against musl, OR with either gcompat or libc6-compat compatibility layers (both seem to be missing some symbols). However this allows us to do so in future by changing the targetted `OperatingSystem` in the alpine and docker-dind `Distro`s
  • Loading branch information
chadlwilson committed Jan 3, 2022
1 parent 57e1939 commit d07ec0a
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,13 @@

package com.thoughtworks.go.build

enum OperatingSystem {
windows("zip"), linux("tar.gz"), mac("tar.gz")

final String extension

OperatingSystem(String extension) {
this.extension = extension
}
}

class AdoptiumUrlHelper {
static String downloadURL(OperatingSystem operatingSystem, Integer featureVersion, Integer interimVersion, Integer updateVersion, Integer buildVersion) {
String versionComponent = [featureVersion, interimVersion, updateVersion].findAll({ it != null }).join('.')
String featureSuffix = updateVersion == null ? '' : 'U'

"https://github.com/adoptium/temurin${featureVersion}-binaries/releases/download/jdk-${versionComponent}%2B${buildVersion}/OpenJDK${featureVersion}${featureSuffix}-jre_x64_${operatingSystem.name()}_hotspot_${versionComponent}_${buildVersion}.${operatingSystem.extension}"
"https://github.com/adoptium/temurin${featureVersion}-binaries/releases/download/jdk-${versionComponent}%2B${buildVersion}/OpenJDK${featureVersion}${featureSuffix}-jre_x64_${operatingSystem.adoptiumAlias()}_hotspot_${versionComponent}_${buildVersion}.${operatingSystem.extension}"
}

static String sha256sumURL(OperatingSystem operatingSystem, Integer featureVersion, Integer interimVersion, Integer updateVersion, Integer buildVersion) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2021 ThoughtWorks, Inc.
*
* 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.
*/

package com.thoughtworks.go.build

enum OperatingSystem {
windows("zip"), linux("tar.gz"), alpine_linux("tar.gz"), mac("tar.gz")

final String extension

OperatingSystem(String extension) {
this.extension = extension
}

String adoptiumAlias() {
name().replace('_', '-')
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@

package com.thoughtworks.go.build.docker

import com.thoughtworks.go.build.OperatingSystem
import org.gradle.api.Project

enum Distro implements DistroBehavior {

alpine{
@Override
OperatingSystem getOperatingSystem() {
OperatingSystem.linux
}

@Override
List<DistroVersion> getSupportedVersions() {
def installSasl_Post_3_9 = ['apk add --no-cache libsasl']
Expand Down Expand Up @@ -193,6 +199,11 @@ enum Distro implements DistroBehavior {
},

docker{
@Override
OperatingSystem getOperatingSystem() {
return alpine.getOperatingSystem()
}

@Override
boolean isPrivilegedModeSupport() {
return true
Expand Down Expand Up @@ -222,7 +233,6 @@ enum Distro implements DistroBehavior {
return alpine.getInstallPrerequisitesCommands(distroVersion)
}


@Override
List<String> getInstallJavaCommands(Project project) {
return alpine.getInstallJavaCommands(project)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.thoughtworks.go.build.docker

import com.thoughtworks.go.build.AdoptiumUrlHelper
import com.thoughtworks.go.build.OperatingSystem
import org.gradle.api.Project

trait DistroBehavior {
Expand Down Expand Up @@ -54,7 +55,7 @@ trait DistroBehavior {

List<String> getInstallJavaCommands(Project project) {
def downloadUrl = AdoptiumUrlHelper.downloadURL(
com.thoughtworks.go.build.OperatingSystem.linux,
getOperatingSystem(),
project.packaging.adoptOpenjdk.featureVersion,
project.packaging.adoptOpenjdk.interimVersion,
project.packaging.adoptOpenjdk.updateVersion,
Expand All @@ -68,6 +69,10 @@ trait DistroBehavior {
]
}

OperatingSystem getOperatingSystem() {
OperatingSystem.linux
}

Map<String, String> getEnvironmentVariables(DistroVersion distroVersion) {
return [GO_JAVA_HOME: '/gocd-jre']
}
Expand Down

0 comments on commit d07ec0a

Please sign in to comment.