Repository navigation
Expand file tree
/
Copy pathDockerfile.alpine
More file actions
140 lines (130 loc) · 6.32 KB
/
Copy pathDockerfile.alpine
File metadata and controls
140 lines (130 loc) · 6.32 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Base image
#
FROM alpine:3.11
#
# Dependencies
#
# Everything we can get through apt-get
RUN apk --no-cache add \
autoconf \
automake \
cmake \
curl \
g++ \
git \
libexecinfo-dev \
libexecinfo-static \
libtool \
linux-headers \
make \
nghttp2-static \
unzip \
zlib-dev
# Install JDK 11 as sampling heap profiler depends on the new JVMTI APIs.
RUN apk --no-cache add openjdk11-jdk
# openssl
# This openssl (compiled with -fPIC) is used to statically link into the agent
# shared library.
ENV JAVA_PATH=/usr/lib/jvm/java-11-openjdk/
RUN mkdir /tmp/openssl && cd /tmp/openssl && \
curl -sL https://github.com/openssl/openssl/archive/OpenSSL_1_1_1t.tar.gz | \
tar xzv --strip=1 && \
./config no-shared -fPIC --openssldir=/usr/local/ssl --prefix=/usr/local/ssl && \
make && make install_sw && \
cd ~ && rm -rf /tmp/openssl
# curl
RUN git clone --depth=1 -b curl-8_10_1 https://github.com/curl/curl.git /tmp/curl && \
cd /tmp/curl && \
./buildconf && \
./configure --disable-ldap --disable-shared --without-libssh2 \
--without-librtmp --without-libidn --enable-static \
--without-libidn2 --without-libpsl \
--with-pic --with-ssl=/usr/local/ssl/ && \
make -j && make install && \
cd ~ && rm -rf /tmp/curl
# gflags
RUN git clone --depth=1 -b v2.1.2 https://github.com/gflags/gflags.git /tmp/gflags && \
cd /tmp/gflags && \
mkdir build && cd build && \
cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_CXX_FLAGS=-fpic -DGFLAGS_NAMESPACE=google .. && \
make -j && make install && \
cd ~ && rm -rf /tmp/gflags
# google-glog
RUN mkdir /tmp/glog && cd /tmp/glog && \
curl -sL https://github.com/google/glog/archive/v0.4.0.tar.gz | \
tar xzv --strip=1 && ./autogen.sh && \
LDFLAGS="-lexecinfo" ./configure --with-pic --enable-static && \
make -j && make install && \
cd ~ && rm -rf /tmp/glog
# gRPC & protobuf - build using CMake
# Use the protobuf version from gRPC for everything to avoid conflicting
# versions to be linked in. Disable OpenSSL embedding: when it's on, the build
# process of gRPC puts the OpenSSL static object files into the gRPC archive
# which causes link errors later when the agent is linked with the static
# OpenSSL library itself.
# Limit the number of threads used by make, as unlimited threads causes
# memory exhausted error on the Kokoro VM.
#
# See https://github.com/grpc/grpc/blob/v1.66.0/test/distrib/cpp/run_distrib_test_cmake_pkgconfig.sh
RUN git clone --depth=1 --recursive -b v1.66.0 https://github.com/grpc/grpc.git /tmp/grpc && \
cd /tmp/grpc/ && \
# Modern Protobuf (v22+) depends on Abseil. To prevent symbol conflicts and undefined references
# when gRPC links against Protobuf, Abseil must be built and installed as a shared system package
# first from gRPC's submodule. Then both Protobuf and gRPC consume it via package (-D..._ABSL_PROVIDER=package).
# Protobuf CMakeLists.txt moved to repo root in newer releases, so we build in third_party/protobuf/build.
# Step 1: Install Abseil as a shared package first
mkdir -p third_party/abseil-cpp/build && \
(cd third_party/abseil-cpp/build && \
cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DABSL_BUILD_TESTING=OFF -DABSL_ENABLE_INSTALL=ON -DCMAKE_CXX_STANDARD=17 -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_LIBDIR=lib .. && \
make -j8 install) && \
# Step 2: Install Protobuf (using shared Abseil package)
mkdir -p third_party/protobuf/build && \
(cd third_party/protobuf/build && \
cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_ABSL_PROVIDER=package -DCMAKE_CXX_STANDARD=17 -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_LIBDIR=lib .. && \
make -j8 install) && \
# Step 3: Install RE2 and generate re2.pc using RE2's official Makefile target (bundled version in gRPC v1.66.0 lacks CMake .pc generation)
mkdir -p third_party/re2/build && \
(cd third_party/re2/build && \
cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DRE2_BUILD_TESTING=OFF -DCMAKE_CXX_STANDARD=17 -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_LIBDIR=lib .. && \
make -j8 install && \
make -C .. common-install prefix=/usr/local) && \
# Step 4: Install gRPC (using shared Abseil, Protobuf, and RE2 packages)
mkdir -p cmake/build && \
(cd cmake/build && \
cmake \
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
-DOPENSSL_ROOT_DIR=/usr/local/ssl \
-DOPENSSL_INCLUDE_DIR=/usr/local/ssl/include \
-DOPENSSL_CRYPTO_LIB=/usr/local/ssl/lib \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_STANDARD=17 \
-DCMAKE_INSTALL_PREFIX=/usr/local/grpc \
-DCMAKE_INSTALL_LIBDIR=lib \
-DgRPC_INSTALL=ON \
-DgRPC_BUILD_TESTS=OFF \
-DgRPC_ABSL_PROVIDER=package \
-DgRPC_CARES_PROVIDER=module \
-DgRPC_RE2_PROVIDER=package \
-DgRPC_ZLIB_PROVIDER=module \
-DgRPC_PROTOBUF_PROVIDER=package \
-DgRPC_SSL_PROVIDER=package \
../.. && \
make -j8 install) && \
cd ~ && rm -rf /tmp/grpc
# Add /usr/local/grpc/lib64/pkgconfig and /usr/local/lib/pkgconfig as 64-bit builds on Alpine may install .pc files there.
ENV PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:/usr/local/ssl/lib/pkgconfig:/usr/local/grpc/lib/pkgconfig:/usr/local/grpc/lib64/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig:/usr/local/lib/x86_64-linux-gnu/pkgconfig:/usr/local/share/pkgconfig"
ENV PATH="${PATH}:/usr/local/grpc/bin"