Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Dockerfile #154

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
75 changes: 55 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,67 @@
# DockerFile for grpc4bmi. Installs the C++ bindings in the /usr/local prefix directory in the container. If you are
# planning to run a container with your BMI-enabled model and communicate with it using grpc4bmi, you can use this as a
# base image for your model
FROM ubuntu:bionic
MAINTAINER Gijs van den Oord <[email protected]>
RUN apt-get update
FROM ubuntu:24.04
LABEL author="Gijs van den Oord"
LABEL email="[email protected]"

ENV GRPC_VERSION="1.66.1"
ENV BMIC_VERSION="2.1.2"
ENV BMICXX_VERSION="2.0.2"

# Prerequisite packages
RUN apt-get install -y wget git build-essential g++ make cmake curl automake libtool pkg-config gfortran
RUN apt-get update && apt-get install -y \
automake \
build-essential \
cmake \
curl \
g++ \
gfortran \
git \
libtool \
libssl-dev \
make \
pkg-config \
wget \
&& rm -rf /var/lib/apt/lists/*

# Build grpc from source
RUN git clone -b $(curl -L https://grpc.io/release) --depth=1 https://github.com/grpc/grpc /opt/grpc
RUN git clone -b v${GRPC_VERSION} --depth 1 https://github.com/grpc/grpc /opt/grpc
WORKDIR /opt/grpc
RUN git submodule update --init --recursive
RUN make install
WORKDIR third_party/protobuf
RUN make install
WORKDIR /opt/grpc/cmake/_build
RUN cmake ../.. \
-DgRPC_INSTALL=ON \
-DgRPC_SSL_PROVIDER=package \
-DgRPC_BUILD_TESTS=OFF \
-DCMAKE_CXX_STANDARD=17 \
-DBUILD_SHARED_LIBS=ON && \
make install && \
make clean

# Build bmi-c from source
RUN git clone --depth=1 https://github.com/eWaterCycle/grpc4bmi.git /opt/grpc4bmi
WORKDIR /opt/grpc4bmi
RUN git submodule update --init --recursive
RUN mkdir -p /opt/grpc4bmi/cpp/bmi-c/build
WORKDIR /opt/grpc4bmi/cpp/bmi-c/build
RUN cmake ..
RUN make install
# Build bmi-c and bmi-cxx from source
RUN git clone --branch v${BMIC_VERSION} https://github.com/csdms/bmi-c /opt/bmi-c
WORKDIR /opt/bmi-c/_build
RUN cmake .. && \
make install && \
make clean
RUN git clone --branch v${BMICXX_VERSION} https://github.com/csdms/bmi-cxx /opt/bmi-cxx
WORKDIR /opt/bmi-cxx/_build
RUN cmake .. && \
make install && \
make clean

RUN ldconfig

# Build grpc4bmi from source
RUN mkdir -p /opt/grpc4bmi/cpp/build
WORKDIR /opt/grpc4bmi/cpp/build
RUN cmake ..
RUN make install
RUN git clone --branch update-dockerfile --depth 1 https://github.com/csdms/grpc4bmi /opt/grpc4bmi
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A note: if this PR is approved, the grpc4bmi remote needs to be switched from csdms back to eWaterCycle, and the build branch from update-dockerfile to main.

WORKDIR /opt/grpc4bmi
RUN git submodule update --init
WORKDIR /opt/grpc4bmi/cpp/_build
RUN cmake .. -DCMAKE_CXX_STANDARD=17 && \
make && \
ctest && \
make install && \
make clean

WORKDIR /opt
2 changes: 2 additions & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ find_library(GRPCREFLECTION grpc++_reflection)
find_library(GRPCLIB grpc CONFIG REQUIRED)
message(STATUS "Using gRPC ${GRPCLIB_VERSION}")
find_package(PkgConfig REQUIRED)
pkg_check_modules(ABSL_CHECK REQUIRED IMPORTED_TARGET absl_check)
pkg_check_modules(BMI REQUIRED IMPORTED_TARGET bmic bmicxx)
message(STATUS "Using BMI ${BMI_VERSION}")

Expand Down Expand Up @@ -52,6 +53,7 @@ target_link_libraries(
${GRPCREFLECTION}
${GRPC}
${PROTOBUF_LIBRARY}
${ABSL_CHECK_LINK_LIBRARIES}
)
set_target_properties(grpc4bmi PROPERTIES PUBLIC_HEADER "bmi_cpp_extension.h;bmi_c_wrapper.h;bmi_grpc_server.h;${GRPC_HDR_FILES}")
add_subdirectory (test)
Expand Down