Skip to content

Commit

Permalink
Improve build image (#11)
Browse files Browse the repository at this point in the history
* Avoid setting GOPATH in docker image

Setting GOPATH to point inside agent directory has some undesirable
side effects, such as make `go test ./...` fail ( because it tries
to execute tests in ./go directory).

* Add a 'build' user

Add a `build` user  and run container with this user by default.
This allows mounting local agent directory in the docker container
while still the right uid permissions.
Allow this user to sudo in order to run the otel agent.
  • Loading branch information
nsavoire authored Jun 10, 2024
1 parent efc5588 commit 714a34c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ARG arch=amd64

RUN apt-get update -y && apt-get dist-upgrade -y && apt-get install -y \
curl wget cmake dwz lsb-release software-properties-common gnupg git clang llvm \
golang unzip
golang unzip sudo

RUN git clone --depth 1 --branch v3.1.0 --recursive https://github.com/zyantific/zydis.git && \
cd zydis && mkdir build && cd build && \
Expand Down Expand Up @@ -36,9 +36,10 @@ RUN
# 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
RUN useradd -ms /bin/bash build
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
RUN adduser build sudo

ENTRYPOINT ["/bin/bash", "-l", "-c"]
USER build

0 comments on commit 714a34c

Please sign in to comment.