This repository was archived by the owner on Feb 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathDockerfile
More file actions
71 lines (61 loc) · 2.24 KB
/
Dockerfile
File metadata and controls
71 lines (61 loc) · 2.24 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
# Copyright 2018 gRPC authors.
# Copyright 2018 Claudiu Nedelcu.
#
# 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.#
#
# Based on https://hub.docker.com/r/grpc/cxx.
FROM debian:stretch as build
RUN apt-get update && apt-get install -y \
autoconf \
automake \
build-essential \
cmake \
curl \
g++ \
git \
libtool \
make \
pkg-config \
unzip \
&& apt-get clean
ENV GRPC_RELEASE_TAG v1.16.0
ENV CALCULATOR_BUILD_PATH /usr/local/calculator
RUN git clone -b ${GRPC_RELEASE_TAG} https://github.com/grpc/grpc /var/local/git/grpc && \
cd /var/local/git/grpc && \
git submodule update --init --recursive
RUN echo "-- installing protobuf" && \
cd /var/local/git/grpc/third_party/protobuf && \
./autogen.sh && ./configure --enable-shared && \
make -j$(nproc) && make -j$(nproc) check && make install && make clean && ldconfig
RUN echo "-- installing grpc" && \
cd /var/local/git/grpc && \
make -j$(nproc) && make install && make clean && ldconfig
COPY . $CALCULATOR_BUILD_PATH/src/calculator/
RUN echo "-- building calculator" && \
mkdir -p $CALCULATOR_BUILD_PATH/out/calculator && \
cd $CALCULATOR_BUILD_PATH/out/calculator && \
cmake -DCMAKE_BUILD_TYPE=Release $CALCULATOR_BUILD_PATH/src/calculator && \
make && \
mkdir -p bin && \
ldd calculator | grep "=> /" | awk '{print $3}' | xargs -I '{}' cp -v '{}' bin/ && \
mv calculator bin/calculator && \
echo "LD_LIBRARY_PATH=/opt/calculator/:\$LD_LIBRARY_PATH ./calculator" > bin/start.sh && \
chmod +x bin/start.sh
WORKDIR $CALCULATOR_BUILD_PATH
ENTRYPOINT ["/bin/bash"]
CMD ["-s"]
FROM debian:stretch as runtime
COPY --from=build /usr/local/calculator/out/calculator/bin/ /opt/calculator/
EXPOSE 8080
WORKDIR /opt/calculator/
ENTRYPOINT ["/bin/bash", "start.sh"]