Skip to content

Commit

Permalink
Run build container as user (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
rockdaboot committed Apr 18, 2024
1 parent b9b8d74 commit 95160be
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
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/bluebox@v0.0.1
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

0 comments on commit 95160be

Please sign in to comment.