-
Notifications
You must be signed in to change notification settings - Fork 414
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
[proposal] Use rust based cp
tool rather than busybox
in autoinstrumentation images.
#1698
base: main
Are you sure you want to change the base?
Changes from all commits
1bdb526
f9033f1
515324a
6c4b6e7
95c38fd
83106e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: 'enhancement' | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. operator, target allocator, github action) | ||
component: autoinstrumentation | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: Replace busybox base image with cp binary in java autoinstrumentation dockerfile | ||
|
||
# One or more tracking issues related to the change | ||
issues: [1600] | ||
|
||
# (Optional) One or more lines of additional information to render under the primary note. | ||
# These lines will be padded with 2 spaces and then inserted directly into the document. | ||
# Use pipe (|) for multiline entries. | ||
subtext: |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,43 @@ | |
# - 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 | ||
|
||
# Stage 1: Build the cp-utility binary | ||
FROM rust:1.69 as builder | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can the rust cp impl. be built for all target platforms supported by go? What I have in mind are ibm z + power (that's what we have to support). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, s390x and ppc64le are supported by the rust base image and musl. Are you using the autoinstrumentation images that are published from this repo in those platforms? I'm asking because today they only support arm and x86 (please take a look here) |
||
|
||
WORKDIR /usr/src/cp-utility | ||
COPY ./cp-utility . | ||
|
||
## TARGETARCH is defined by buildx | ||
# https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope | ||
ARG TARGETARCH | ||
|
||
# Run validations and audit only on amd64 bacause it is faster and those two steps | ||
# are only used to validate the source code and don't require anything that is | ||
# architecture specific. | ||
|
||
# Validations | ||
## Validate formatting | ||
RUN if [ $TARGETARCH = "amd64" ]; then rustup component add rustfmt && cargo fmt --check ; fi | ||
|
||
## Audit dependencies | ||
RUN if [ $TARGETARCH = "amd64" ]; then cargo install cargo-audit && cargo audit ; fi | ||
|
||
|
||
# Cross-compile based on the target platform. | ||
RUN if [ $TARGETARCH = "amd64" ]; then export ARCH="x86_64" ; \ | ||
elif [ $TARGETARCH = "arm64" ]; then export ARCH="aarch64" ; \ | ||
else false; \ | ||
fi \ | ||
&& rustup target add ${ARCH}-unknown-linux-musl \ | ||
&& cargo test --target ${ARCH}-unknown-linux-musl \ | ||
&& cargo install --target ${ARCH}-unknown-linux-musl --path . --root . | ||
|
||
# Stage 2: Create distribution | ||
FROM scratch | ||
|
||
ARG version | ||
|
||
ADD https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v$version/opentelemetry-javaagent.jar /javaagent.jar | ||
COPY --from=builder /usr/src/cp-utility/bin/cp-utility /bin/cp | ||
|
||
RUN chmod -R go+r /javaagent.jar | ||
ADD --chmod=go+r https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v$version/opentelemetry-javaagent.jar /javaagent.jar |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Use git CLI to fetch the source code instead of relying on the rust git implementation | ||
[net] | ||
git-fetch-with-cli = true |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[package] | ||
name = "cp-utility" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
# No dependencies here | ||
|
||
[dev-dependencies] | ||
# dependencies only used during tests | ||
tempfile = "3.5.0" | ||
uuid = { version = "1.3.1", features = ["v4", "fast-rng"] } | ||
|
||
[profile.release] | ||
# Levers to optimize the binary for size | ||
strip = true # Strip symbols | ||
opt-level = "z" # Size optimization | ||
lto = true # linking time optimizations | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we'll have to make another group in order to use CODEOWNERS here