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

Run build container as user #10

Merged
merged 3 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.cache
go
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
*.o
*.pb.go
.idea
.cache
/.idea
/go
otel-profiling-agent
tracer.ebpf
tracer.ebpf.arm64
Expand Down
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ RUN
&& find "$INSTALL_DIR/include" -type f -exec chmod +r {} \; \
&& rm "$PB_FILE"

# The docker image is built as root - make binaries available to user.
RUN mv /root/go/bin/* /usr/local/bin/

ENV GOPATH=/agent/go
ENV GOCACHE=/agent/.cache

RUN echo "export PATH=\"\$PATH:\$(go env GOPATH)/bin\"" >> ~/.bashrc

ENTRYPOINT ["/bin/bash", "-l", "-c"]
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ all: generate ebpf binary

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

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

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

legal:
@go install go.elastic.co/go-licence-detector@latest
Expand Down
Loading