Skip to content

Commit c387188

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

21 files changed

+316
-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,45 @@
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+
42+
- name: Push
43+
run: |
44+
docker push ghcr.io/open-telemetry/opentelemetry-operator/cp:${{ env.VERSION }}
45+
docker push ghcr.io/open-telemetry/opentelemetry-operator/cp:${{ env.VERSION }}-fips

.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

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

0 commit comments

Comments
 (0)