Skip to content

Commit 95160be

Browse files
authored
Run build container as user (open-telemetry#10)
1 parent b9b8d74 commit 95160be

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.cache
2+
go

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
*.o
22
*.pb.go
3-
.idea
3+
.cache
4+
/.idea
5+
/go
46
otel-profiling-agent
57
tracer.ebpf
68
tracer.ebpf.arm64

Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ RUN
3333
&& find "$INSTALL_DIR/include" -type f -exec chmod +r {} \; \
3434
&& rm "$PB_FILE"
3535

36+
# The docker image is built as root - make binaries available to user.
37+
RUN mv /root/go/bin/* /usr/local/bin/
38+
39+
ENV GOPATH=/agent/go
40+
ENV GOCACHE=/agent/.cache
41+
3642
RUN echo "export PATH=\"\$PATH:\$(go env GOPATH)/bin\"" >> ~/.bashrc
3743

3844
ENTRYPOINT ["/bin/bash", "-l", "-c"]

Makefile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ all: generate ebpf binary
66

77
# Removes the go build cache and binaries in the current project
88
clean:
9-
go clean -cache -i
10-
$(MAKE) -C support/ebpf clean
11-
rm -f build-targets/*.{deb,rpm}
12-
rm -f support/*.test
9+
@go clean -cache -i
10+
@$(MAKE) -s -C support/ebpf clean
11+
@rm -f support/*.test
12+
@chmod -Rf u+w go/ || true
13+
@rm -rf go .cache
1314

1415
generate: protobuf
1516
go install github.com/florianl/[email protected]
@@ -57,7 +58,7 @@ docker-image:
5758
docker build -t profiling-agent --build-arg arch=$(NATIVE_ARCH) -f Dockerfile .
5859

5960
agent:
60-
docker run -v "$$PWD":/agent -it profiling-agent make
61+
docker run -v "$$PWD":/agent -it --rm --user $(shell id -u):$(shell id -g) profiling-agent make
6162

6263
legal:
6364
@go install go.elastic.co/go-licence-detector@latest

0 commit comments

Comments
 (0)