-
Notifications
You must be signed in to change notification settings - Fork 272
/
Dockerfile
46 lines (38 loc) · 2.16 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
FROM debian:testing
WORKDIR /agent
# cross_debian_arch: amd64 or arm64
# cross_pkg_arch: x86-64 or aarch64
RUN cross_debian_arch=$(uname -m | sed -e 's/aarch64/amd64/' -e 's/x86_64/arm64/'); \
cross_pkg_arch=$(uname -m | sed -e 's/aarch64/x86-64/' -e 's/x86_64/aarch64/'); \
apt-get update -y && \
apt-get dist-upgrade -y && \
apt-get install -y wget make git clang-16 unzip libc6-dev g++ gcc pkgconf \
gcc-${cross_pkg_arch}-linux-gnu libc6-${cross_debian_arch}-cross && \
apt-get clean autoclean && \
apt-get autoremove --yes
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
# Set Go environment variables
ENV GOPATH="/agent/go"
ENV GOCACHE="/agent/.cache"
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 \
PB_URL="https://github.com/protocolbuffers/protobuf/releases/download/v24.4/"; \
PB_FILE="protoc-24.4-linux-x86_64.zip"; \
INSTALL_DIR="/usr/local"; \
\
wget -q "$PB_URL/$PB_FILE" \
&& unzip "$PB_FILE" -d "$INSTALL_DIR" 'bin/*' 'include/*' \
&& chmod +xr "$INSTALL_DIR/bin/protoc" \
&& find "$INSTALL_DIR/include" -type d -exec chmod +x {} \; \
&& find "$INSTALL_DIR/include" -type f -exec chmod +r {} \; \
&& rm "$PB_FILE"
# Append to /etc/profile for login shells
RUN echo 'export PATH="/usr/local/go/bin:$PATH"' >> /etc/profile
ENTRYPOINT ["/bin/bash", "-l", "-c"]