forked from open-telemetry/opentelemetry-ebpf-profiler
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build on ubuntu+clang17, fix cross-build, QA (#10)
Migrate the build from DockerHub debian:testing to AWS ubuntu:22.04. Attention: Clang version on this image is 17, not 16. Isolate docker files in directory docker-image. Introduce an entrypoint for the docker image, to better deal with the GO environment. Dockerfile: install GolangCi deps in the docker image, copy the binaries in the container's workdir in /agent/go/bin. Makefile: fix the clean target. Makefiles: substitute LLVM commands versionsxi, example clang-16 with clang-17. This is to avoid introducing aliases in the building container. Makefile: remove the installation of GolangCi deps during linting. Makefile: add targets for GO deps management Makefile: pin GO deps versions Makefile: pin porto version to "v0.6.0" (instead of latest). The latest version of porto requires GO 1.23, while the current toolchain is based on Go 1.22. Makefile: improve target linter-version, print all GolangCi deps versions. GO: touch go/bin/.gitkeep, the directory bin contains the GO deps print_instruction_count: fix OBJDUMP_CMD from llvm-objdump-16 to llvm-objdump. Makefile: Fix cross-compilation Always use NATIVE_ARCH as GOARCH for go:generate. The previous approach may fail on systems that can not execute cross-compiled binaries on the build host (e.g. if an appropriate qemu binary is not installed).
- Loading branch information
1 parent
41533b2
commit ee8a86f
Showing
6 changed files
with
104 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,48 @@ | ||
FROM debian:testing | ||
ARG image=public.ecr.aws/ubuntu/ubuntu:22.04 | ||
|
||
WORKDIR /agent | ||
FROM ${image} | ||
|
||
WORKDIR /agent-go | ||
|
||
RUN apt-get update -y \ | ||
&& apt-get install -y --no-install-recommends --no-install-suggests \ | ||
ca-certificates \ | ||
gnupg2 \ | ||
software-properties-common \ | ||
wget \ | ||
git \ | ||
findutils \ | ||
unzip \ | ||
make | ||
|
||
RUN apt-get update -y && \ | ||
apt-get dist-upgrade -y && \ | ||
apt-get install -y clang-16 git lld-16 make pkgconf unzip wget && \ | ||
apt-get clean autoclean && \ | ||
apt-get autoremove --yes | ||
RUN wget https://apt.llvm.org/llvm.sh \ | ||
&& chmod +x llvm.sh \ | ||
&& ./llvm.sh 17 | ||
|
||
COPY go.mod /tmp/go.mod | ||
# Extract Go version from go.mod | ||
RUN GO_VERSION=$(grep -oPm1 '^go \K([[:digit:].]+)' /tmp/go.mod) && \ | ||
GOARCH=$(uname -m) && if [ "$GOARCH" = "x86_64" ]; then GOARCH=amd64; elif [ "$GOARCH" = "aarch64" ]; then GOARCH=arm64; fi && \ | ||
wget -qO- https://golang.org/dl/go${GO_VERSION}.linux-${GOARCH}.tar.gz | tar -C /usr/local -xz | ||
wget https://golang.org/dl/go${GO_VERSION}.linux-${GOARCH}.tar.gz && \ | ||
tar -C /usr/local -xvzf ./go${GO_VERSION}.linux-${GOARCH}.tar.gz && \ | ||
rm -rf ./go${GO_VERSION}.linux-${GOARCH}.tar.gz | ||
|
||
# Set Go environment variables | ||
ENV GOPATH="/agent/go" | ||
ENV GOCACHE="/agent/.cache" | ||
ENV GOPATH="/agent-go" | ||
ENV GOCACHE="$GOPATH/.cache" | ||
ENV GOBIN="$GOPATH/bin" | ||
# not addin GOBIN on purpose, see entrypoint | ||
ENV PATH="/usr/local/go/bin:$PATH" | ||
|
||
# gRPC dependencies | ||
RUN go install google.golang.org/protobuf/cmd/[email protected] | ||
RUN go install google.golang.org/grpc/cmd/[email protected] | ||
RUN go install github.com/jcchavezs/porto/cmd/[email protected] | ||
RUN go install github.com/golangci/golangci-lint/cmd/[email protected] | ||
|
||
RUN \ | ||
PB_URL="https://github.com/protocolbuffers/protobuf/releases/download/v24.4/"; \ | ||
PB_FILE="protoc-24.4-linux-x86_64.zip"; \ | ||
PB_FILE="protoc-24.4-linux-x86_64.zip"; \ | ||
INSTALL_DIR="/usr/local"; \ | ||
\ | ||
wget -q "$PB_URL/$PB_FILE" \ | ||
|
@@ -36,6 +53,10 @@ RUN | |
&& rm "$PB_FILE" | ||
|
||
# Append to /etc/profile for login shells | ||
RUN echo 'export PATH="/usr/local/go/bin:$PATH"' >> /etc/profile | ||
RUN echo 'export PATH="$PATH"' >> /etc/profile | ||
|
||
WORKDIR /agent | ||
|
||
ENTRYPOINT ["/bin/bash", "-l", "-c"] | ||
COPY docker-image/entrypoint.sh /entrypoint.sh | ||
RUN chmod +x /entrypoint.sh | ||
ENTRYPOINT ["/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
|
||
ORIG_GOPATH="/agent-go" | ||
|
||
NEW_GOPATH="/agent/go" | ||
GOPATH="$NEW_GOPATH" | ||
GOCACHE="$GOPATH/.cache" | ||
GOBIN="$GOPATH/bin" | ||
PATH="$PATH:$GOBIN" | ||
GOLANGCI_LINT_CACHE=$GOCACHE | ||
|
||
# Check if /agent/go exists, and create it if not | ||
if [ ! -d "${GOPATH}" ]; then | ||
mkdir -p ${GOPATH} | ||
mkdir -p ${GOBIN} | ||
fi | ||
|
||
cp --recursive $ORIG_GOPATH/bin/* $GOBIN | ||
|
||
export GOPATH | ||
export GOCACHE | ||
export GOBIN | ||
export PATH | ||
export GOLANGCI_LINT_CACHE | ||
|
||
git config --global --add safe.directory /agent | ||
|
||
# Run the actual command (e.g., bash or other processes) | ||
exec $@ |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters