-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathDockerfile.tmpl
73 lines (60 loc) · 2.27 KB
/
Dockerfile.tmpl
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
ARG DEBIAN_VERSION
FROM debian:${DEBIAN_VERSION}
ARG DEBIAN_VERSION
# Replace sources.list in order to use archive.debian.org.
COPY sources-debian${DEBIAN_VERSION}.list /etc/apt/sources.list
RUN apt-get -o Acquire::Check-Valid-Until=false update -y --no-install-recommends --allow-unauthenticated \
&& apt-get upgrade -y --no-install-recommends --allow-unauthenticated \
&& apt-get dist-upgrade -y --no-install-recommends --allow-unauthenticated \
&& apt-get install -y --no-install-recommends --allow-unauthenticated \
build-essential \
ca-certificates \
curl \
git \
gnupg \
make \
file \
flex \
bison \
{{- if or (eq .DEBIAN_VERSION "10") (eq .DEBIAN_VERSION "11") (eq .DEBIAN_VERSION "12")}}
binutils-multiarch \
binutils-multiarch-dev \
python3-venv \
python3-pip \
python3 \
{{- end }}
&& rm -rf /var/lib/apt/lists/*
{{- if eq .DEBIAN_VERSION "10"}}
RUN ln -s /usr/bin/pip3 /usr/bin/pip
{{- end }}
ARG GOLANG_VERSION=1.23.5
ARG GOLANG_DOWNLOAD_URL=https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz
ARG GOLANG_DOWNLOAD_SHA256=cbcad4a6482107c7c7926df1608106c189417163428200ce357695cc7e01d091
RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz \
&& echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - \
&& rm -rf /usr/local/go \
&& tar -C /usr/local -xzf golang.tar.gz \
&& rm golang.tar.gz
ENV GOPATH /go
ENV PATH $PATH:/usr/local/go/bin
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
WORKDIR $GOPATH
COPY rootfs /
# show the GLIBC version
RUN ldd --version
WORKDIR /
RUN mkdir -p /root/.config/go/telemetry && echo "off 2024-08-23" > /root/.config/go/telemetry/mode
RUN go mod init github.com/elastic/golang-crossbuild-$GOLANG_VERSION \
&& go get . \
&& go env \
&& echo "toolcompile=$(go tool compile -V)" \
&& CGO_ENABLED=0 go build -o /crossbuild /entrypoint.go \
&& rm -rf /go/* /root/.cache/* /entrypoint.go
COPY sdks/libpcap-1.8.1.tar.gz .
RUN mkdir /libpcap \
&& tar -xzf libpcap-1.8.1.tar.gz -C /libpcap \
&& rm libpcap-1.8.1.tar.gz
ENV GOLANG_CROSSBUILD=1
VOLUME /app
WORKDIR /app
ENTRYPOINT ["/crossbuild"]