Skip to content

Commit b653465

Browse files
committed
[autoinstrumentation] remove dependency on busybox, use native cp
1 parent f26a319 commit b653465

21 files changed

+313
-19
lines changed

.chloggen/native_cp.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
2+
change_type: enhancement
3+
4+
# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action)
5+
component: autoinstrumentation
6+
7+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
8+
note: Implement native cp, remove dependency on busybox for all autoinstrumentation images
9+
10+
# One or more tracking issues related to the change
11+
issues: [1600]
12+
13+
# (Optional) One or more lines of additional information to render under the primary note.
14+
# These lines will be padded with 2 spaces and then inserted directly into the document.
15+
# Use pipe (|) for multiline entries.
16+
subtext:

.github/workflows/publish-autoinstrumentation-apache-httpd.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,19 @@ on:
1212
- 'autoinstrumentation/apache-httpd/**'
1313
- '.github/workflows/publish-autoinstrumentation-apache-httpd.yaml'
1414
workflow_dispatch:
15+
workflow_run:
16+
workflows: [ "Publish cp Auto-Instrumentation" ]
17+
branches: [ main ]
18+
types:
19+
- completed
1520

1621
concurrency:
1722
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
1823
cancel-in-progress: true
1924

2025
jobs:
2126
publish:
27+
if: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' }}
2228
runs-on: ubuntu-22.04
2329

2430
steps:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: "Publish cp Auto-Instrumentation"
2+
3+
on:
4+
push:
5+
paths:
6+
- 'autoinstrumentation/cp/**'
7+
- '.github/workflows/publish-autoinstrumentation-cp.yaml'
8+
branches:
9+
- main
10+
pull_request:
11+
paths:
12+
- 'autoinstrumentation/cp/**'
13+
- '.github/workflows/publish-autoinstrumentation-cp.yaml'
14+
workflow_dispatch:
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
18+
cancel-in-progress: true
19+
20+
jobs:
21+
publish:
22+
runs-on: ubuntu-22.04
23+
24+
steps:
25+
- uses: actions/checkout@v4
26+
27+
- name: Read version
28+
run: echo "VERSION=$(cat autoinstrumentation/cp/version.txt)" >> $GITHUB_ENV
29+
30+
- name: Login to GitHub Package Registry
31+
uses: docker/login-action@v3
32+
with:
33+
registry: ghcr.io
34+
username: ${{ github.repository_owner }}
35+
password: ${{ secrets.GITHUB_TOKEN }}
36+
37+
- name: Create docker image
38+
run: |
39+
cd autoinstrumentation/cp
40+
VERSION=${{ env.VERSION }} make docker
41+

.github/workflows/publish-autoinstrumentation-dotnet.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,19 @@ on:
1212
- 'autoinstrumentation/dotnet/**'
1313
- '.github/workflows/publish-autoinstrumentation-dotnet.yaml'
1414
workflow_dispatch:
15+
workflow_run:
16+
workflows: [ "Publish cp Auto-Instrumentation" ]
17+
branches: [ main ]
18+
types:
19+
- completed
1520

1621
concurrency:
1722
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
1823
cancel-in-progress: true
1924

2025
jobs:
2126
publish:
27+
if: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' }}
2228
runs-on: ubuntu-22.04
2329

2430
steps:

.github/workflows/publish-autoinstrumentation-java.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ on:
1212
- 'autoinstrumentation/java/**'
1313
- '.github/workflows/publish-autoinstrumentation-java.yaml'
1414
workflow_dispatch:
15+
workflow_run:
16+
workflows: [ "Publish cp Auto-Instrumentation" ]
17+
branches: [ main ]
18+
types:
19+
- completed
1520

1621
concurrency:
1722
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
@@ -20,6 +25,7 @@ concurrency:
2025

2126
jobs:
2227
publish:
28+
if: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' }}
2329
runs-on: ubuntu-22.04
2430

2531
steps:

.github/workflows/publish-autoinstrumentation-nodejs.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ on:
1212
- 'autoinstrumentation/nodejs/**'
1313
- '.github/workflows/publish-autoinstrumentation-nodejs.yaml'
1414
workflow_dispatch:
15+
workflow_run:
16+
workflows: [ "Publish cp Auto-Instrumentation" ]
17+
branches: [ main ]
18+
types:
19+
- completed
1520

1621
concurrency:
1722
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
@@ -20,6 +25,7 @@ concurrency:
2025

2126
jobs:
2227
publish:
28+
if: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' }}
2329
runs-on: ubuntu-22.04
2430

2531
steps:

.github/workflows/publish-autoinstrumentation-python.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ on:
1212
- 'autoinstrumentation/python/**'
1313
- '.github/workflows/publish-autoinstrumentation-python.yaml'
1414
workflow_dispatch:
15+
workflow_run:
16+
workflows: [ "Publish cp Auto-Instrumentation" ]
17+
branches: [ main ]
18+
types:
19+
- completed
1520

1621
concurrency:
1722
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
@@ -20,6 +25,7 @@ concurrency:
2025

2126
jobs:
2227
publish:
28+
if: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' }}
2329
runs-on: ubuntu-22.04
2430

2531
steps:

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,4 @@ config/rbac/certmanager-permissions/
4444
build
4545
node_modules
4646
package-lock.json
47+
autoinstrumentation/cp/bin/
+7-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
2-
############################
3-
# STEP 1 download the webserver agent
4-
############################
51
FROM alpine:latest as agent
62

73
ARG version
@@ -13,14 +9,13 @@ RUN mkdir agent
139
RUN wget -c https://github.com/open-telemetry/opentelemetry-cpp-contrib/releases/download/webserver%2Fv$version/opentelemetry-webserver-sdk-x64-linux.tgz
1410
RUN unzip -p opentelemetry-webserver-sdk-x64-linux.tgz | tar -zx -C agent
1511

16-
############################
17-
# STEP 2 download the webserver agent
18-
############################
19-
FROM alpine:latest
20-
21-
COPY --from=agent /opt/opentelemetry/agent/opentelemetry-webserver-sdk /opt/opentelemetry
22-
2312
RUN chmod 775 -R /opt/opentelemetry/
2413
RUN chmod a+w /opt/opentelemetry/logs
2514

26-
CMD ["cat", "Just delivering the Opentelemetry Apache/Nginx agent"]
15+
FROM ghcr.io/open-telemetry/opentelemetry-operator/cp:1.0.0 AS cp
16+
17+
FROM scratch
18+
19+
COPY --from=cp /cp /usr/bin/cp
20+
21+
COPY --from=agent /opt/opentelemetry/agent/opentelemetry-webserver-sdk /opt/opentelemetry

autoinstrumentation/cp/Dockerfile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM scratch
2+
3+
ARG cp
4+
5+
ADD $cp /cp
6+
7+
ENTRYPOINT ["/cp"]
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM scratch
2+
3+
LABEL fips=true
4+
5+
ARG cp
6+
7+
ADD $cp /cp
8+
9+
ENTRYPOINT ["/cp"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM scratch
2+
3+
ARG cp
4+
5+
ADD $cp /cp.exe
6+
7+
ENTRYPOINT ["/cp.exe"]

autoinstrumentation/cp/Makefile

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
VERSION?=latest
2+
REPOSITORY?=ghcr.io/open-telemetry/opentelemetry-operator
3+
GO_BUILD_LDFLAGS ?= '-w -s -extldflags "-static"'
4+
5+
.PHONY := build
6+
build:
7+
mkdir -p bin
8+
CGO_ENABLED=0 go build -trimpath -o ./bin/cp_$(GOOS)_$(GOARCH)$(EXTRA)$(EXTENSION) -ldflags $(GO_BUILD_LDFLAGS)
9+
10+
bin/cp_linux_amd64: main.go go.mod
11+
GOOS=linux GOARCH=amd64 EXTENSION="" EXTRA="" make build
12+
13+
bin/cp_linux_arm64: main.go go.mod
14+
GOOS=linux GOARCH=arm64 EXTENSION="" EXTRA="" make build
15+
16+
bin/cp_linux_ppc64le: main.go go.mod
17+
GOOS=linux GOARCH=ppc64le EXTENSION="" EXTRA="" make build
18+
19+
bin/cp_linux_s390x: main.go go.mod
20+
GOOS=linux GOARCH=s390x EXTENSION="" EXTRA="" make build
21+
22+
bin/cp_windows_arm64.exe: main.go go.mod
23+
GOOS=windows GOARCH=arm64 EXTENSION=".exe" EXTRA="" make build
24+
25+
bin/cp_windows_amd64.exe: main.go go.mod
26+
GOOS=windows GOARCH=amd64 EXTENSION=".exe" EXTRA="" make build
27+
28+
bin/cp_linux_amd64_fips: main.go go.mod
29+
GOEXPERIMENT=boringcrypto GOOS=linux GOARCH=amd64 EXTENSION="" EXTRA="_fips" make build
30+
31+
bin/cp_linux_arm64_fips: main.go go.mod
32+
GOEXPERIMENT=boringcrypto GOOS=linux GOARCH=arm64 EXTENSION="" EXTRA="_fips" make build
33+
34+
bin/cp_windows_arm64_fips.exe: main.go go.mod
35+
GOEXPERIMENT=boringcrypto GOOS=windows GOARCH=arm64 EXTENSION=".exe" EXTRA="_fips" make build
36+
37+
bin/cp_windows_amd64_fips.exe: main.go go.mod
38+
GOEXPERIMENT=boringcrypto GOOS=windows GOARCH=amd64 EXTENSION=".exe" EXTRA="_fips" make build
39+
40+
## Docker build
41+
42+
.PHONY := docker_linux_amd64
43+
docker_linux_amd64: bin/cp_linux_amd64
44+
docker buildx build --platform="linux/amd64" --push -t $(REPOSITORY)/cp_linux_amd64:$(VERSION) --build-arg cp=bin/cp_linux_amd64 .
45+
46+
.PHONY := docker_linux_arm64
47+
docker_linux_arm64: bin/cp_linux_arm64
48+
docker buildx build --platform="linux/arm64" --push -t $(REPOSITORY)/cp_linux_arm64:$(VERSION) --build-arg cp=bin/cp_linux_arm64 .
49+
50+
.PHONY := docker_linux_ppc64le
51+
docker_linux_ppc64le: bin/cp_linux_ppc64le
52+
docker buildx build --platform="linux/ppc64le" --push -t $(REPOSITORY)/cp_linux_ppc64le:$(VERSION) --build-arg cp=bin/cp_linux_ppc64le .
53+
54+
.PHONY := docker_linux_s390x
55+
docker_linux_s390x: bin/cp_linux_s390x
56+
docker buildx build --platform="linux/s390x" --push -t $(REPOSITORY)/cp_linux_s390x:$(VERSION) --build-arg cp=bin/cp_linux_s390x .
57+
58+
.PHONY := docker_windows_arm64
59+
docker_windows_arm64: bin/cp_windows_arm64.exe
60+
docker buildx build --platform="windows/arm64" --push -f Dockerfile.windows -t $(REPOSITORY)/cp_windows_arm64:$(VERSION) --build-arg cp=bin/cp_windows_arm64.exe .
61+
62+
.PHONY := docker_windows_amd64
63+
docker_windows_amd64: bin/cp_windows_amd64.exe
64+
docker buildx build --platform="windows/amd64" --push -f Dockerfile.windows -t $(REPOSITORY)/cp_windows_amd64:$(VERSION) --build-arg cp=bin/cp_windows_amd64.exe .
65+
66+
.PHONY := docker_linux_amd64_fips
67+
docker_linux_amd64_fips: bin/cp_linux_amd64_fips
68+
docker buildx build --platform="linux/amd64" --push -t $(REPOSITORY)/cp_linux_amd64_fips:$(VERSION) --build-arg cp=bin/cp_linux_amd64_fips .
69+
70+
.PHONY := docker_linux_arm64_fips
71+
docker_linux_arm64_fips: bin/cp_linux_arm64_fips
72+
docker buildx build --platform="linux/arm64" --push -t $(REPOSITORY)/cp_linux_arm64_fips:$(VERSION) --build-arg cp=bin/cp_linux_arm64_fips .
73+
74+
.PHONY := docker_windows_amd64_fips
75+
docker_windows_amd64_fips: bin/cp_windows_amd64_fips.exe
76+
docker buildx build --platform="windows/amd64" --push -f Dockerfile.windows -t $(REPOSITORY)/cp_windows_amd64_fips:$(VERSION) --build-arg cp=bin/cp_windows_amd64_fips.exe .
77+
78+
.PHONY := docker_windows_arm64_fips
79+
docker_windows_arm64_fips: bin/cp_windows_arm64_fips.exe
80+
docker buildx build --platform="windows/arm64" --push -f Dockerfile.windows -t $(REPOSITORY)/cp_windows_arm64_fips:$(VERSION) --build-arg cp=bin/cp_windows_arm64_fips.exe .
81+
82+
.PHONY := docker
83+
docker: docker_linux_amd64 docker_linux_arm64 docker_linux_ppc64le docker_linux_s390x docker_windows_amd64 docker_windows_arm64 docker_linux_amd64_fips docker_linux_arm64_fips docker_windows_amd64_fips docker_windows_arm64_fips
84+
docker buildx imagetools create -t $(REPOSITORY)/cp:$(VERSION) \
85+
$(REPOSITORY)/cp_linux_amd64:$(VERSION) \
86+
$(REPOSITORY)/cp_linux_arm64:$(VERSION) \
87+
$(REPOSITORY)/cp_linux_ppc64le:$(VERSION) \
88+
$(REPOSITORY)/cp_linux_s390x:$(VERSION) \
89+
$(REPOSITORY)/cp_windows_amd64:$(VERSION) \
90+
$(REPOSITORY)/cp_windows_arm64:$(VERSION)
91+
92+
docker buildx imagetools create \
93+
-t $(REPOSITORY)/cp:$(VERSION)-fips \
94+
$(REPOSITORY)/cp_linux_amd64_fips:$(VERSION) \
95+
$(REPOSITORY)/cp_linux_arm64_fips:$(VERSION) \
96+
$(REPOSITORY)/cp_windows_amd64_fips:$(VERSION) \
97+
$(REPOSITORY)/cp_windows_arm64_fips:$(VERSION)

autoinstrumentation/cp/README.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# cp
2+
3+
This project allows you to take a file and copy to a new location on disk with the 0400 permission mask (read-only).
4+
5+
# Install
6+
7+
## As binary
8+
9+
```bash
10+
go install github.com/otel-warez/cp@latest
11+
```
12+
13+
## As a docker image
14+
15+
```
16+
docker pull ghcr.io/otel-warez/cp:latest
17+
```
18+
19+
This image is built from scratch and will not be useful on its own, but you can use it as a layer. Here is an example:
20+
21+
```
22+
FROM ghcr.io/otel-warez/cp:latest AS cp
23+
24+
FROM scratch AS final
25+
COPY --from=cp /cp /usr/bin/cp
26+
...
27+
```

autoinstrumentation/cp/go.mod

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/otel-warez/cp
2+
3+
go 1.23.0

autoinstrumentation/cp/main.go

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright The OpenTelemetry Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package main
16+
17+
import (
18+
"fmt"
19+
"log"
20+
"os"
21+
)
22+
23+
func main() {
24+
if len(os.Args) != 3 {
25+
log.Fatal("[USAGE] cp src dest")
26+
}
27+
28+
data, err := os.ReadFile(os.Args[1])
29+
if err != nil {
30+
log.Fatal(fmt.Sprintf("error copying file: %v", err))
31+
}
32+
33+
err = os.WriteFile(os.Args[2], data, 0400)
34+
35+
if err != nil {
36+
log.Fatal(fmt.Sprintf("error copying file: %v", err))
37+
}
38+
}

autoinstrumentation/cp/version.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.0.0

0 commit comments

Comments
 (0)