Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish a docker image containing Java autoinstrumentation files. #475

Merged
merged 8 commits into from
Nov 3, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/publish-autoinstrumentation-java.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: "Publish Java Auto-Instrumentation"

on:
push:
paths:
- 'autoinstrumentation/java/**'
- '.github/workflows/publish-autoinstrumentation-java.yaml'
branches:
- main
workflow_dispatch:

jobs:
publish:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2.3.5

- name: Read version
run: echo "VERSION=$(cat autoinstrumentation/java/version.txt)" >> $GITHUB_ENV

- name: Docker meta
id: meta
uses: docker/metadata-action@v3.6.0
with:
images: ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-java
jpkrohling marked this conversation as resolved.
Show resolved Hide resolved
tags: |
type=match,pattern=v(.*),group=1,value=v${{ env.VERSION }}

- name: Login to GitHub Package Registry
uses: docker/login-action@v1.10.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v2.7.0
with:
context: autoinstrumentation/java
push: true
build-args: version=${{ env.VERSION }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
5 changes: 5 additions & 0 deletions autoinstrumentation/java/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM busybox
jpkrohling marked this conversation as resolved.
Show resolved Hide resolved

ARG version

ADD https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v$version/opentelemetry-javaagent.jar /javaagent.jar
1 change: 1 addition & 0 deletions autoinstrumentation/java/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.7.0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For other languages, this will be a version number in something like a package.json. I tried to provide a similar "edit a file to update the version" experience for Java using this txt file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative approach would be to put the version in https://github.com/open-telemetry/opentelemetry-operator/blob/main/versions.txt and publish the image on operator release.

However, I like your approach more as it allows us to release the java docker image without operator release. I still need the version being defined in the root version.txt to use it as a default version of the javaagent when the image is not specified in the CR (I will do this on a follow up PR once the initial implementation is merged).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - yeah since instrumentation will be published at various cycles it's probably good to decouple those release cycles.

Added the version to top level to allow operator to reference the most recent one (which will generally have already been published before the operator is released)