Skip to content

Commit c38e6e5

Browse files
authored
Merge pull request #883 from cqse/multi_platform_oci
TS-46051 Switch from docker to oci for publishing
2 parents b38de88 + a96fe1d commit c38e6e5

6 files changed

Lines changed: 79 additions & 66 deletions

File tree

.github/workflows/actions.yml

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Build
22

33
on:
44
push:
5-
branches: '**'
5+
branches: master
66
tags: 'v*'
77
pull_request:
88
branches: '**'
@@ -47,6 +47,14 @@ jobs:
4747
-Psigning.keyId=4FB80B8E \
4848
-PsonatypeUsername=${{ secrets.SONATYPE_USER }} \
4949
-PsonatypePassword=${{ secrets.SONATYPE_PASSWORD }}
50+
- name: Push Docker Image to DockerHub
51+
if: startsWith(github.ref, 'refs/tags/v')
52+
run: |
53+
./gradlew :agent:pushOciImage :agent:pushLegacyOciImage --registry=dockerHub
54+
./gradlew :agent:pushOciImage :agent:pushLegacyOciImage --registry=dockerHub -PociImageTag=latest
55+
env:
56+
ORG_GRADLE_PROJECT_dockerHubUsername: ${{ secrets.DOCKERHUB_USER }}
57+
ORG_GRADLE_PROJECT_dockerHubPassword: ${{ secrets.DOCKERHUB_TOKEN }}
5058
- name: Upload coverage to Teamscale
5159
if: always() && github.event_name == 'push'
5260
uses: cqse/teamscale-upload-action@v9.2.1
@@ -83,33 +91,3 @@ jobs:
8391
format: 'JACOCO'
8492
message: 'Coverage Windows'
8593
files: '**/jacocoTestReport.xml'
86-
87-
docker:
88-
runs-on: ubuntu-latest
89-
steps:
90-
- name: Set up QEMU
91-
uses: docker/setup-qemu-action@v4
92-
- name: Set up Docker Buildx
93-
uses: docker/setup-buildx-action@v4
94-
- name: Docker meta
95-
id: meta
96-
uses: docker/metadata-action@v6
97-
with:
98-
images: cqse/teamscale-jacoco-agent
99-
- name: Login to DockerHub
100-
if: github.event_name != 'pull_request'
101-
uses: docker/login-action@v4
102-
with:
103-
username: ${{ secrets.DOCKERHUB_USER }}
104-
password: ${{ secrets.DOCKERHUB_TOKEN }}
105-
- name: Build and push
106-
uses: docker/build-push-action@v7
107-
with:
108-
file: 'agent/src/docker/Dockerfile'
109-
platforms: linux/amd64,linux/arm64
110-
push: ${{ startsWith(github.ref, 'refs/tags/v') }}
111-
tags: ${{ steps.meta.outputs.tags }}
112-
labels: ${{ steps.meta.outputs.labels }}
113-
build-args: |
114-
GITHUB_REF=${{ github.ref }}
115-

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ We use [semantic versioning](http://semver.org/):
55
- PATCH version when you make backwards compatible bug fixes.
66

77
# Next version
8+
- [feature] _agent_: Renamed the docker image to `cqse/teamscale-java-profiler` and added support for the `linux/arm64` platform
89

910
# 36.4.1
1011
- [fix] _agent_: Fixed `IllegalStateException: Can't add different class with same name` when application servers like JBoss perform a reload without full restart or when duplicate class files exist across multiple archives

agent/build.gradle.kts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import io.github.sgtsilvio.gradle.oci.dsl.OciImageDefinition
2+
13
plugins {
24
com.teamscale.`java-convention`
35
application
@@ -9,6 +11,7 @@ plugins {
911
com.teamscale.coverage
1012
com.teamscale.publish
1113
com.teamscale.`logger-patch`
14+
alias(libs.plugins.oci)
1215
}
1316

1417
evaluationDependsOn(":installer")
@@ -101,3 +104,57 @@ distributions {
101104
tasks.shadowDistZip {
102105
archiveFileName = "teamscale-jacoco-agent.zip"
103106
}
107+
108+
// The OCI plugin adds a project-level repository ('dockerHubOciRegistry') for resolving
109+
// OCI image dependencies, which overrides the settings-level dependencyResolutionManagement
110+
// repositories. We need to re-declare mavenCentral() here so regular dependencies can still
111+
// be resolved. See: https://github.com/SgtSilvio/gradle-oci/issues/125
112+
repositories {
113+
mavenCentral()
114+
}
115+
116+
oci {
117+
registries {
118+
dockerHub {
119+
optionalCredentials()
120+
}
121+
}
122+
123+
val ociImageTag = providers.gradleProperty("ociImageTag").orElse(appVersion)
124+
val configureImage: Action<OciImageDefinition> = Action {
125+
imageTag = ociImageTag
126+
allPlatforms {
127+
dependencies {
128+
runtime("library:alpine:latest")
129+
}
130+
config {
131+
entryPoint = listOf("/entrypoint.sh")
132+
}
133+
layer("agent") {
134+
contents {
135+
into("agent") {
136+
from(tasks.shadowJar)
137+
}
138+
}
139+
}
140+
layer("entrypoint") {
141+
contents {
142+
from("src/docker/entrypoint.sh") {
143+
filePermissions = "755".toInt(8)
144+
}
145+
}
146+
}
147+
}
148+
specificPlatform(platform("linux", "amd64"))
149+
specificPlatform(platform("linux", "arm64"))
150+
}
151+
152+
imageDefinitions.register("main") {
153+
imageName = "cqse/teamscale-java-profiler"
154+
configureImage.execute(this)
155+
}
156+
imageDefinitions.register("legacy") {
157+
imageName = "cqse/teamscale-jacoco-agent"
158+
configureImage.execute(this)
159+
}
160+
}

agent/src/docker/Dockerfile

Lines changed: 0 additions & 35 deletions
This file was deleted.

agent/src/docker/entrypoint.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
# When /transfer exists (shared volume), copy the agent JAR there and exit.
3+
# This supports the Kubernetes init container pattern where this image provides
4+
# the agent JAR to the application container via a shared volume.
5+
if [ -e /transfer ]; then
6+
cp -r /agent/teamscale-jacoco-agent.jar /transfer
7+
exit 0
8+
fi
9+
# Otherwise, keep the container alive indefinitely as a sidecar.
10+
trap : TERM INT
11+
sleep infinity & wait

gradle/libs.versions.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,6 @@ pluginPublish = { id = "com.gradle.plugin-publish", version = "2.1.1" }
8888
gitProperties = { id = "com.gorylenko.gradle-git-properties", version = "2.5.7" }
8989
mavenPluginDevelopment = { id = "org.gradlex.maven-plugin-development", version = "1.0.3" }
9090
shadow = { id = "com.gradleup.shadow", version = "9.4.1" }
91+
oci = { id = "io.github.sgtsilvio.gradle.oci", version = "0.25.0" }
9192
kotlinJvm = { id = "org.jetbrains.kotlin.jvm", version = "2.3.20" }
9293
jlink = { id = "org.beryx.jlink", version = "4.0.0" }

0 commit comments

Comments
 (0)