Skip to content

Commit 06cc511

Browse files
Merge pull request #154 from csdms/update-dockerfile
Update Dockerfile
2 parents d881954 + fea867b commit 06cc511

File tree

2 files changed

+58
-23
lines changed

2 files changed

+58
-23
lines changed

Dockerfile

Lines changed: 56 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,65 @@
11
# DockerFile for grpc4bmi. Installs the C++ bindings in the /usr/local prefix directory in the container. If you are
22
# planning to run a container with your BMI-enabled model and communicate with it using grpc4bmi, you can use this as a
33
# base image for your model
4-
FROM ubuntu:bionic
5-
MAINTAINER Gijs van den Oord <[email protected]>
6-
RUN apt-get update
4+
FROM ubuntu:24.04
5+
LABEL maintainer="eWaterCycle <[email protected]>"
6+
LABEL org.opencontainers.image.source="https://github.com/eWaterCycle/grpc4bmi"
7+
8+
ENV GRPC_VERSION="1.66.1"
9+
ENV BMIC_VERSION="2.1.2"
10+
ENV BMICXX_VERSION="2.0.2"
711

812
# Prerequisite packages
9-
RUN apt-get install -y wget git build-essential g++ make cmake curl automake libtool pkg-config gfortran
13+
RUN apt-get update && apt-get install -y \
14+
automake \
15+
build-essential \
16+
cmake \
17+
curl \
18+
g++ \
19+
gfortran \
20+
git \
21+
libtool \
22+
libssl-dev \
23+
make \
24+
pkg-config \
25+
vim-tiny \
26+
wget \
27+
&& apt-get clean && rm -rf /var/lib/apt/lists/*
28+
29+
# Build grpc from source (removing git history saves 1.7 GB)
30+
RUN git clone --branch v${GRPC_VERSION} --depth 1 --recurse-submodules https://github.com/grpc/grpc /opt/grpc && \
31+
rm -rf /opt/grpc/.git
32+
WORKDIR /opt/grpc/cmake/_build
33+
RUN cmake ../.. \
34+
-DgRPC_INSTALL=ON \
35+
-DgRPC_SSL_PROVIDER=package \
36+
-DgRPC_BUILD_TESTS=OFF \
37+
-DCMAKE_CXX_STANDARD=17 \
38+
-DBUILD_SHARED_LIBS=ON && \
39+
make install && \
40+
make clean
1041

11-
# Build grpc from source
12-
RUN git clone -b $(curl -L https://grpc.io/release) --depth=1 https://github.com/grpc/grpc /opt/grpc
13-
WORKDIR /opt/grpc
14-
RUN git submodule update --init --recursive
15-
RUN make install
16-
WORKDIR third_party/protobuf
17-
RUN make install
42+
# Build bmi-c and bmi-cxx from source
43+
RUN git clone --branch v${BMIC_VERSION} https://github.com/csdms/bmi-c /opt/bmi-c
44+
WORKDIR /opt/bmi-c/_build
45+
RUN cmake .. && \
46+
make install && \
47+
make clean
48+
RUN git clone --branch v${BMICXX_VERSION} https://github.com/csdms/bmi-cxx /opt/bmi-cxx
49+
WORKDIR /opt/bmi-cxx/_build
50+
RUN cmake .. && \
51+
make install && \
52+
make clean
1853

19-
# Build bmi-c from source
20-
RUN git clone --depth=1 https://github.com/eWaterCycle/grpc4bmi.git /opt/grpc4bmi
21-
WORKDIR /opt/grpc4bmi
22-
RUN git submodule update --init --recursive
23-
RUN mkdir -p /opt/grpc4bmi/cpp/bmi-c/build
24-
WORKDIR /opt/grpc4bmi/cpp/bmi-c/build
25-
RUN cmake ..
26-
RUN make install
54+
RUN ldconfig
2755

2856
# Build grpc4bmi from source
29-
RUN mkdir -p /opt/grpc4bmi/cpp/build
30-
WORKDIR /opt/grpc4bmi/cpp/build
31-
RUN cmake ..
32-
RUN make install
57+
COPY . /opt/grpc4bmi
58+
WORKDIR /opt/grpc4bmi/cpp/_build
59+
RUN cmake .. -DCMAKE_CXX_STANDARD=17 && \
60+
make && \
61+
ctest && \
62+
make install && \
63+
make clean
64+
65+
WORKDIR /opt

cpp/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ find_library(GRPCREFLECTION grpc++_reflection)
1818
find_library(GRPCLIB grpc CONFIG REQUIRED)
1919
message(STATUS "Using gRPC ${GRPCLIB_VERSION}")
2020
find_package(PkgConfig REQUIRED)
21+
pkg_check_modules(ABSL_CHECK REQUIRED IMPORTED_TARGET absl_check)
2122
pkg_check_modules(BMI REQUIRED IMPORTED_TARGET bmic bmicxx)
2223
message(STATUS "Using BMI ${BMI_VERSION}")
2324

@@ -52,6 +53,7 @@ target_link_libraries(
5253
${GRPCREFLECTION}
5354
${GRPC}
5455
${PROTOBUF_LIBRARY}
56+
${ABSL_CHECK_LINK_LIBRARIES}
5557
)
5658
set_target_properties(grpc4bmi PROPERTIES PUBLIC_HEADER "bmi_cpp_extension.h;bmi_c_wrapper.h;bmi_grpc_server.h;${GRPC_HDR_FILES}")
5759
add_subdirectory (test)

0 commit comments

Comments
 (0)