From 5d8a717edba3da9fb9d658b6aca757a4745a5233 Mon Sep 17 00:00:00 2001 From: cleverchuk Date: Wed, 18 Sep 2024 16:22:40 -0400 Subject: [PATCH] NH-90479: add building auto-instrumentation docker image --- .github/workflows/push.yml | 38 ++++++++++++++++++++++++++++++++- .github/workflows/release.yml | 40 ++++++++++++++++++++++++++++++++++- agent/Dockerfile | 11 ++++++++++ 3 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 agent/Dockerfile diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 4c6f1afb..81c7e183 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -508,4 +508,40 @@ jobs: echo "AGENT_VERSION=${{ steps.set_version.outputs.version }}.$GIT_HASH" >> $GITHUB_ENV - name: Publish - run: ./gradlew publish \ No newline at end of file + run: ./gradlew publish + + docker_hub: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + - name: Set agent version + id: set_version + uses: ./.github/actions/version + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_HUB_CI_USER }} + password: ${{ secrets.DOCKER_HUB_CI_PASSWORD }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + push: true + context: agent + platforms: linux/amd64,linux/arm64,linux/s390x,linux/ppc64le + tags: solarwinds/autoinstrumentation-java:${{ steps.set_version.outputs.version }},solarwinds/autoinstrumentation-java:latest \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a5f54d84..0cf151b6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -385,4 +385,42 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - VERSION: ${{ steps.set_version.outputs.version }} \ No newline at end of file + VERSION: ${{ steps.set_version.outputs.version }} + + docker_hub: + runs-on: ubuntu-latest + needs: github_release + name: Deploy to docker hub + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set agent version + id: set_version + uses: ./.github/actions/version + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_HUB_CI_USER }} + password: ${{ secrets.DOCKER_HUB_CI_PASSWORD }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + push: true + context: agent + platforms: + - linux/amd64 + - linux/arm64 + - linux/ppc64le + - linux/s390x + tags: + - solarwinds/autoinstrumentation-java:${{ steps.set_version.outputs.version }} + - solarwinds/autoinstrumentation-java:latest \ No newline at end of file diff --git a/agent/Dockerfile b/agent/Dockerfile new file mode 100644 index 00000000..46458ba1 --- /dev/null +++ b/agent/Dockerfile @@ -0,0 +1,11 @@ +# To build one auto-instrumentation image for Java, please: +# - Download your customized `javaagent.jar` to `/javaagent.jar`. This is required as when instrumenting the pod, +# one init container will be created to copy the jar to your app's container. +# - Grant the necessary access to the jar. `chmod -R go+r /javaagent.jar` +# - For auto-instrumentation by container injection, the Linux command cp is +# used and must be availabe in the image. +FROM busybox + +ADD build/libs/solarwinds-apm-agent.jar /javaagent.jar + +RUN chmod -R go+r /javaagent.jar \ No newline at end of file