-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
82 lines (64 loc) · 3.33 KB
/
Dockerfile
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
# Install sfincs-bmi-server + its dependencies: sfincs, grpc4bmi, grpc, bmi-c, bmi-cxx
# Implementation follows https://github.com/eWaterCycle/grpc4bmi/blob/main/test/heat-images/cxx-bmi20/Dockerfile
# Also see https://github.com/Deltares/SFINCS/blob/main/source/Dockerfile
# Build with:
# docker build -t sfincs-bmiserver .
#FROM deltares/sfincs-cpu:sfincs-v2.0.2-Blockhaus-Release-Q2-2023 as sfincs_container
FROM ubuntu:jammy AS sfincs_container
# Compile sfincs from a Github branch instead of from image
# with copy of Dockerfile at https://github.com/Deltares/SFINCS/blob/feature/48-extend-bmi-functionality/source/Dockerfile
ENV DEBIAN_FRONTEND=noninteractive
RUN apt clean && apt autoclean && apt update --fix-missing && apt upgrade -y && apt install -y libnetcdf-dev build-essential autoconf automake libtool gfortran gdb tzdata m4 git
WORKDIR /usr/src/sfincs
ARG SFINCS_REPO=https://github.com/eWaterCycle/SFINCS.git
ARG SFINCS_BRANCH=patch-bmi
RUN git clone -b ${SFINCS_BRANCH} ${SFINCS_REPO} .
WORKDIR /usr/src/sfincs/source
RUN chmod -R 777 autogen.sh
# -fallow-argument-mismatch needed for https://github.com/Unidata/netcdf-fortran/issues/212
ENV FCFLAGS="-fopenmp -O3 -fallow-argument-mismatch -w"
ENV FFLAGS="-fopenmp -O3 -fallow-argument-mismatch -w"
RUN autoreconf -ivf && ./autogen.sh && ./configure --disable-openacc && make && make install
# End of copy of Dockerfile at https://github.com/Deltares/SFINCS/blob/feature/48-extend-bmi-functionality/source/Dockerfile
# Inherit from the same base as sfincs to get compatible library versions
# FROM ubuntu:jammy AS sfincs_bmi_container
# # Install sfincs
# COPY --from=sfincs_container /usr/local /usr/local
# Install build deps (including sfincs` dependency on netcdf)
RUN apt-get update && apt-get install -qy git build-essential cmake autoconf libtool pkg-config libssl-dev libnetcdf-dev gfortran
# Compile gRPC
WORKDIR /opt/grpc
ARG GRPC_VERSION=v1.51.1
RUN echo ${GRPC_VERSION}
RUN git clone -b ${GRPC_VERSION} --depth 1 https://github.com/grpc/grpc . && git submodule update --init
WORKDIR /opt/grpc/cmake/build
RUN cmake -DgRPC_INSTALL=ON -DgRPC_SSL_PROVIDER=package -DgRPC_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=ON ../.. \
&& make -j6 && make install && ldconfig
# Install bmi-cxx
ARG BMICXX_VERSION=v2.0
RUN git clone -b ${BMICXX_VERSION} https://github.com/csdms/bmi-cxx.git /opt/bmi-cxx
WORKDIR /opt/bmi-cxx/build
RUN cmake .. && make install
# Install bmi-c
ARG BMIC_VERSION=v2.1
RUN git clone -b ${BMIC_VERSION} https://github.com/csdms/bmi-c.git /opt/bmi-c
WORKDIR /opt/bmi-c/build
RUN cmake .. && make install
# Install grpc4bmi
RUN git clone https://github.com/eWaterCycle/grpc4bmi /opt/grpc4bmi
WORKDIR /opt/grpc4bmi/cpp/build
RUN cmake .. && make install
# Build sfincs-bmi-server (requires libsfincs)
COPY ./src /opt/sfincs-bmi
WORKDIR /opt/sfincs-bmi/build
RUN cmake .. && make install && ldconfig
# TODO can we make the container smaller?
# FROM debian:buster
# RUN apt-get update && apt-get install -qy libssl1.1 && rm -rf /var/lib/apt/lists/*
# COPY --from=sfincs_bmi_container /usr/local/bin/sfincs_bmi_server /usr/local/bin/sfincs_bmi_server
# COPY --from=sfincs_bmi_container /usr/local/lib/ /usr/local/lib/
# RUN ldconfig
# Expose entrypoint
ENV BMI_PORT=50051
ENTRYPOINT ["/usr/local/bin/sfincs_bmi_server"]
LABEL org.opencontainers.image.source https://github.com/eWaterCycle/sfincs-bmi-server