diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 28511ec75..2b5dcf4f1 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -2,7 +2,7 @@ name: Build on: push: - branches: '**' + branches: master tags: 'v*' pull_request: branches: '**' @@ -47,6 +47,14 @@ jobs: -Psigning.keyId=4FB80B8E \ -PsonatypeUsername=${{ secrets.SONATYPE_USER }} \ -PsonatypePassword=${{ secrets.SONATYPE_PASSWORD }} + - name: Push Docker Image to DockerHub + if: startsWith(github.ref, 'refs/tags/v') + run: | + ./gradlew :agent:pushOciImage :agent:pushLegacyOciImage --registry=dockerHub + ./gradlew :agent:pushOciImage :agent:pushLegacyOciImage --registry=dockerHub -PociImageTag=latest + env: + ORG_GRADLE_PROJECT_dockerHubUsername: ${{ secrets.DOCKERHUB_USER }} + ORG_GRADLE_PROJECT_dockerHubPassword: ${{ secrets.DOCKERHUB_TOKEN }} - name: Upload coverage to Teamscale if: always() && github.event_name == 'push' uses: cqse/teamscale-upload-action@v9.2.1 @@ -83,33 +91,3 @@ jobs: format: 'JACOCO' message: 'Coverage Windows' files: '**/jacocoTestReport.xml' - - docker: - runs-on: ubuntu-latest - steps: - - name: Set up QEMU - uses: docker/setup-qemu-action@v4 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v4 - - name: Docker meta - id: meta - uses: docker/metadata-action@v6 - with: - images: cqse/teamscale-jacoco-agent - - name: Login to DockerHub - if: github.event_name != 'pull_request' - uses: docker/login-action@v4 - with: - username: ${{ secrets.DOCKERHUB_USER }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push - uses: docker/build-push-action@v7 - with: - file: 'agent/src/docker/Dockerfile' - platforms: linux/amd64,linux/arm64 - push: ${{ startsWith(github.ref, 'refs/tags/v') }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - build-args: | - GITHUB_REF=${{ github.ref }} - diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d78574ee..ca737238b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ We use [semantic versioning](http://semver.org/): - PATCH version when you make backwards compatible bug fixes. # Next version +- [feature] _agent_: Renamed the docker image to `cqse/teamscale-java-profiler` and added support for the `linux/arm64` platform # 36.4.1 - [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 diff --git a/agent/build.gradle.kts b/agent/build.gradle.kts index 300483c52..b217489ec 100644 --- a/agent/build.gradle.kts +++ b/agent/build.gradle.kts @@ -1,3 +1,5 @@ +import io.github.sgtsilvio.gradle.oci.dsl.OciImageDefinition + plugins { com.teamscale.`java-convention` application @@ -9,6 +11,7 @@ plugins { com.teamscale.coverage com.teamscale.publish com.teamscale.`logger-patch` + alias(libs.plugins.oci) } evaluationDependsOn(":installer") @@ -101,3 +104,57 @@ distributions { tasks.shadowDistZip { archiveFileName = "teamscale-jacoco-agent.zip" } + +// The OCI plugin adds a project-level repository ('dockerHubOciRegistry') for resolving +// OCI image dependencies, which overrides the settings-level dependencyResolutionManagement +// repositories. We need to re-declare mavenCentral() here so regular dependencies can still +// be resolved. See: https://github.com/SgtSilvio/gradle-oci/issues/125 +repositories { + mavenCentral() +} + +oci { + registries { + dockerHub { + optionalCredentials() + } + } + + val ociImageTag = providers.gradleProperty("ociImageTag").orElse(appVersion) + val configureImage: Action = Action { + imageTag = ociImageTag + allPlatforms { + dependencies { + runtime("library:alpine:latest") + } + config { + entryPoint = listOf("/entrypoint.sh") + } + layer("agent") { + contents { + into("agent") { + from(tasks.shadowJar) + } + } + } + layer("entrypoint") { + contents { + from("src/docker/entrypoint.sh") { + filePermissions = "755".toInt(8) + } + } + } + } + specificPlatform(platform("linux", "amd64")) + specificPlatform(platform("linux", "arm64")) + } + + imageDefinitions.register("main") { + imageName = "cqse/teamscale-java-profiler" + configureImage.execute(this) + } + imageDefinitions.register("legacy") { + imageName = "cqse/teamscale-jacoco-agent" + configureImage.execute(this) + } +} diff --git a/agent/src/docker/Dockerfile b/agent/src/docker/Dockerfile deleted file mode 100644 index 1711758f8..000000000 --- a/agent/src/docker/Dockerfile +++ /dev/null @@ -1,35 +0,0 @@ -# --- build image --- - -FROM eclipse-temurin:21 AS build - -# We need to manually pass this enviroment variable through to make Gradle determine the correct version number (TS-42362) -ARG GITHUB_REF -ENV GITHUB_REF=${GITHUB_REF} - -ADD . /src -WORKDIR /src -RUN ./gradlew :agent:shadowJar - -# --- production image --- -FROM alpine:latest - -RUN mkdir -p /agent -COPY --from=build /src/agent/build/libs/teamscale-jacoco-agent.jar /agent - -VOLUME /agent - -# make the image do nothing when started -# except if /transfer is mounted, then copy the agent there and exit immediately -# this lets us use the image as an init container in Kubernetes -COPY <