-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
122 lines (96 loc) · 4.41 KB
/
Dockerfile
File metadata and controls
122 lines (96 loc) · 4.41 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
# ====================== Builder Stage ======================
FROM alpine:latest AS builder
ARG TARGET_EXECUTABLE=worker
ARG CMAKE_VERSION=3.27.9
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
RUN apk add --no-cache \
build-base \
cmake \
git \
curl-dev \
openssl-dev \
zstd-dev \
boost-dev \
nlohmann-json \
hiredis-dev \
libcurl \
ninja \
asio-dev
RUN cd /root && git clone https://github.com/gflags/gflags.git && cd gflags && \
mkdir build && cd build && \
cmake .. -DCMAKE_POSITION_INDEPENDENT_CODE=ON && \
make -j$(nproc) && make install
RUN cd /root && git clone https://github.com/google/glog.git && cd glog \
&& git checkout v0.6.0 \
&& mkdir build && cd build && \
cmake .. && \
make -j$(nproc) && make install
RUN cd /root && git clone https://github.com/google/googletest.git && cd googletest && mkdir build && cd build && \
cmake .. && make -j$(nproc) && make install
RUN cd /root && git clone https://github.com/redis/hiredis.git && cd hiredis && make -j$(nproc) USE_SSL=1 && make USE_SSL=1 install
RUN cd /root && git clone https://github.com/sewenew/redis-plus-plus.git && cd redis-plus-plus && mkdir build && cd build && \
cmake -DREDIS_PLUS_PLUS_USE_TLS=ON .. && make -j$(nproc) && make install
RUN cd /root && git clone --recurse-submodules https://github.com/aws/aws-sdk-cpp.git && cd aws-sdk-cpp && \
mkdir -p build && cd build && cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_ONLY="core;s3" \
-DENABLE_UNITY_BUILD=ON \
-DBUILD_SHARED_LIBS=ON \
-DENABLE_TESTING=OFF \
-DCMAKE_INSTALL_PREFIX=/root/aws-sdk-cpp-install && make -j$(nproc) && \
make install
RUN cd /root && git clone https://github.com/libcpr/cpr.git && \
cd cpr && mkdir build && cd build && \
cmake .. -DCPR_USE_SYSTEM_CURL=ON -DBUILD_SHARED_LIBS=OFF && \
cmake --build . --parallel &&\
cmake --install .
RUN cd /root && git clone https://github.com/awslabs/aws-lambda-cpp.git && cd aws-lambda-cpp && mkdir build && cd build && \
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/root/lambda-install && \
make -j$(nproc) && make install
WORKDIR /app
COPY . /app
RUN cd /app && mkdir -p build && cd build && rm -rf ./* && \
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH=/root/aws-sdk-cpp-install \
-Daws-lambda-runtime_DIR=/root/lambda-install/lib/aws-lambda-runtime/cmake && \
cmake --build . -j$(nproc) --target ${TARGET_EXECUTABLE} && \
if [ "${TARGET_EXECUTABLE}" = "worker" ]; then \
cmake --build . -j$(nproc) --target worker_plugins; \
fi && \
strip ${TARGET_EXECUTABLE} && \
cp ${TARGET_EXECUTABLE} /root/bootstrap && \
mkdir -p /root/plugins && \
if [ "${TARGET_EXECUTABLE}" = "worker" ]; then \
for so in lib*.so; do \
[ -e "$so" ] || continue; \
strip --strip-unneeded "$so" && cp "$so" /root/plugins/; \
done; \
fi
RUN mkdir -p /root/deps && \
for lib in $(ldd /root/bootstrap | awk '{print $3}' | grep "^/" | grep -vE 'libc\\.so|libpthread|ld-linux|libm\\.so|librt\\.so|libdl\\.so|libresolv\\.so'); do \
cp -v "$lib" /root/deps/; \
if [ -L "$lib" ]; then \
real_path=$(readlink -f "$lib") && \
cp -v "$real_path" /root/deps/ && \
cp -v "$lib" /root/deps/; \
fi \
done
RUN cp /etc/ssl/certs/ca-certificates.crt /root/ca-certificates.crt
# ====================== Runtime Stage ======================
FROM public.ecr.aws/lambda/provided:al2.2025.04.03.11
ARG TARGETARCH
ARG TARGET_EXECUTABLE=worker
COPY --from=builder /root/deps /var/deps
COPY --from=builder /root/deps/ld-musl-aarch64.so.1 /lib/
COPY --from=builder /root/bootstrap /var/bootstrap
COPY --from=builder /root/plugins /var/plugins
COPY bootstrap ${LAMBDA_RUNTIME_DIR}
ENV LD_LIBRARY_PATH=/var/deps
RUN chmod +x /var/runtime/bootstrap
RUN chmod +x /var/bootstrap
RUN if [ "${TARGET_EXECUTABLE}" = "worker" ] && ls /var/plugins/lib*.so >/dev/null 2>&1; then \
cp /var/plugins/lib*.so /var/runtime/; \
fi
COPY --from=builder /root/ca-certificates.crt /etc/ssl/cert.pem
ENTRYPOINT ["/var/runtime/bootstrap"]