From f6017447a8ba12e43ea0ac899fefba95c47b8b28 Mon Sep 17 00:00:00 2001 From: TShapinsky Date: Sat, 20 Jul 2024 13:25:29 -0600 Subject: [PATCH 01/19] first pass at multiplatform builds and specifying python versions --- .github/workflows/build.yml | 6 +- Dockerfile | 199 ++++++++++++++++++++---------------- 2 files changed, 117 insertions(+), 88 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cc98686..4832571 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -40,9 +40,11 @@ jobs: type=semver,pattern={{major}},enable=${{ github.event_name == 'release' }} - name: Build and push - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v6 with: context: . push: true + target: alfalfa-dependencies + platform: linux/amd64,linux/arm64,linux/arm/v7 tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.output.labels }} \ No newline at end of file + labels: ${{ steps.meta.output.labels }} diff --git a/Dockerfile b/Dockerfile index 259c648..dd0fe38 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,95 +1,122 @@ -FROM ubuntu:20.04 AS base - -USER root +ARG PYTHON_VERSION=3.10.14 +ARG DEBIAN_VERSION=bookworm +FROM python:${PYTHON_VERSION}-slim-${DEBIAN_VERSION} as modelica-dependencies +ARG SUNDIALS_VERSION=v2.7.0 +RUN apt update \ + && apt install -y \ + cmake \ + liblapack-dev \ + libsuitesparse-dev \ + libhypre-dev \ + curl \ + git \ + build-essential + +RUN python3 -m pip install \ + Cython \ + numpy \ + scipy \ + matplotlib \ + nose-py3 \ + setuptools==69.1.0 + +RUN ln -s /usr/lib/$(uname -m)-linux-gnu/libblas.so /usr/lib/$(uname -m)-linux-gnu/libblas_OPENMP.so + +WORKDIR /build + +RUN curl -fSsL https://portal.nersc.gov/project/sparse/superlu/superlu_mt_3.1.tar.gz | tar xz \ + && cd SuperLU_MT_3.1 \ + && make CFLAGS="-O2 -fPIC -fopenmp" BLASLIB="-lblas" PLAT="_OPENMP" MPLIB="-fopenmp" lib -j1 \ + && cp -v ./lib/libsuperlu_mt_OPENMP.a /usr/lib \ + && cp -v ./SRC/*.h /usr/include + +RUN git clone --depth 1 -b ${SUNDIALS_VERSION} https://github.com/LLNL/sundials.git \ + && cd sundials \ + && echo "target_link_libraries(sundials_idas_shared lapack blas superlu_mt_OPENMP)" >> src/idas/CMakeLists.txt \ + && echo "target_link_libraries(sundials_kinsol_shared lapack blas superlu_mt_OPENMP)" >> src/kinsol/CMakeLists.txt \ + && mkdir build && cd build \ + && cmake \ + -LAH \ + -DSUPERLUMT_BLAS_LIBRARIES=blas \ + -DSUPERLUMT_LIBRARIES=blas \ + -DSUPERLUMT_INCLUDE_DIR=/usr/include \ + -DSUPERLUMT_LIBRARY=/usr/lib/libsuperlu_mt_OPENMP.a \ + -DSUPERLUMT_THREAD_TYPE=OpenMP \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DSUPERLUMT_ENABLE=ON \ + -DLAPACK_ENABLE=ON \ + -DEXAMPLES_ENABLE=OFF \ + -DEXAMPLES_ENABLE_C=OFF \ + -DBUILD_STATIC_LIBS=OFF \ + .. \ + && make -j4 \ + && make install + +RUN git clone --depth 1 -b Assimulo-3.5.2 https://github.com/modelon-community/Assimulo.git \ + && cd Assimulo \ + && python3 setup.py install --user --sundials-home=/usr --blas-home=/usr/lib/$(uname -m)-linux-gnu --lapack-home=/usr/lib/$(uname -m)-linux-gnu --superlu-home=/usr \ + && python3 setup.py bdist_wheel + +RUN git clone --depth 1 -b 2.4.1 https://github.com/modelon-community/fmi-library.git \ + && cd fmi-library \ + && sed -i "/CMAKE_INSTALL_PREFIX/d" CMakeLists.txt \ + && mkdir fmi_build && cd fmi_build \ + && mkdir fmi_library \ + && cmake -DCMAKE_INSTALL_PREFIX=/build/fmi-libary/fmi_library .. \ + && make -j4 \ + && make install + +RUN git clone --depth 1 -b PyFMI-2.13.1 https://github.com/modelon-community/PyFMI.git \ + && cd PyFMI \ + && python3 setup.py bdist_wheel --fmil-home=/build/fmi-libary/fmi_library + +WORKDIR /artifacts + +RUN cp /build/Assimulo/build/dist/* . \ + && cp /build/PyFMI/dist/* . + +FROM python:${PYTHON_VERSION}-slim-${DEBIAN_VERSION} as energyplus-dependencies +ARG OPENSTUDIO_VERSION=3.8.0 +ARG OPENSTUDIO_VERSION_SHA=f953b6fcaf +ARG ENERGYPLUS_VERSION=24.1.0 +ARG ENERGYPLUS_VERSION_SHA=9d7789a3ac + +RUN apt update \ + && apt install -y \ + curl + +WORKDIR /artifacts +RUN curl -SfL https://github.com/NREL/EnergyPlus/releases/download/v${ENERGYPLUS_VERSION}/EnergyPlus-${ENERGYPLUS_VERSION}-${ENERGYPLUS_VERSION_SHA}-Linux-Ubuntu22.04-$(uname -m).tar.gz -o energyplus.tar.gz +RUN curl -SfL https://github.com/NREL/OpenStudio/releases/download/v${OPENSTUDIO_VERSION}/OpenStudio-${OPENSTUDIO_VERSION}+${OPENSTUDIO_VERSION_SHA}-Ubuntu-22.04-$(uname -m).deb -o openstudio.deb + +FROM python:${PYTHON_VERSION}-slim-${DEBIAN_VERSION} as alfalfa-dependencies +ENV ENERGYPLUS_DIR /usr/local/EnergyPlus ENV HOME /alfalfa -# Need to set the lang to use Python 3.8 with Poetry -ENV LANG C.UTF-8 -ENV DEBIAN_FRONTEND noninteractive -ENV ROOT_DIR /usr/local -ENV BUILD_DIR $HOME/build - +WORKDIR /artifacts -RUN apt-get update \ - && apt-get install -y \ - ca-certificates \ - curl \ - gdebi-core \ - openjdk-8-jdk \ - libgfortran4 \ - python3-venv \ - python3-pip \ - && rm -rf /var/lib/apt/lists/* +COPY --from=modelica-dependencies /artifacts/* . +COPY --from=energyplus-dependencies /artifacts/* . +RUN apt update \ + && apt install -y \ + gdebi-core \ + openjdk-17-jdk -WORKDIR $HOME -# Use set in update-alternatives instead of config to -# provide non-interactive input. -RUN update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java \ - && update-alternatives --set javac /usr/lib/jvm/java-8-openjdk-amd64/bin/javac \ - && curl -SLO http://openstudio-resources.s3.amazonaws.com/bcvtb-linux.tar.gz \ - && tar -xzf bcvtb-linux.tar.gz \ - && rm bcvtb-linux.tar.gz +# RUN update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java \ +# && update-alternatives --set javac /usr/lib/jvm/java-8-openjdk-amd64/bin/javac -WORKDIR $BUILD_DIR +RUN pip3 install *.whl +RUN mkdir ${ENERGYPLUS_DIR} \ + && tar -C $ENERGYPLUS_DIR/ --strip-components=1 -xzf energyplus.tar.gz \ + && ln -s $ENERGYPLUS_DIR/energyplus /usr/local/bin/ \ + && ln -s $ENERGYPLUS_DIR/ExpandObjects /usr/local/bin/ \ + && ln -s $ENERGYPLUS_DIR/runenergyplus /usr/local/bin/ -ENV OPENSTUDIO_DOWNLOAD_URL https://github.com/NREL/OpenStudio/releases/download/v3.8.0/OpenStudio-3.8.0+f953b6fcaf-Ubuntu-20.04-x86_64.deb +RUN gdebi -n openstudio.deb \ + && cd /usr/local/openstudio* \ + && rm -rf EnergyPlus \ + && ln -s ${ENERGYPLUS_DIR} EnergyPlus -# mlep / external interface needs parts of EnergyPlus that are not included with OpenStudio -# expandobjects, runenergyplus might be two examples, but the need to install EnergyPlus separately from OpenStudio -# might be revaluated -ENV ENERGYPLUS_DIR /usr/local/EnergyPlus -ENV ENERGYPLUS_DOWNLOAD_URL https://github.com/NREL/EnergyPlus/releases/download/v24.1.0/EnergyPlus-24.1.0-9d7789a3ac-Linux-Ubuntu20.04-x86_64.tar.gz - -# We would rather use the self extracting tarball distribution of EnergyPlus, but there appears to -# be a bug in the installation script so using the tar.gz manually here and making our own links -RUN curl -SL $ENERGYPLUS_DOWNLOAD_URL -o energyplus.tar.gz\ - && mkdir $ENERGYPLUS_DIR \ - && tar -C $ENERGYPLUS_DIR/ --strip-components=1 -xzf energyplus.tar.gz \ - && ln -s $ENERGYPLUS_DIR/energyplus /usr/local/bin/ \ - && ln -s $ENERGYPLUS_DIR/ExpandObjects /usr/local/bin/ \ - && ln -s $ENERGYPLUS_DIR/runenergyplus /usr/local/bin/ \ - && rm energyplus.tar.gz - -RUN curl -SL $OPENSTUDIO_DOWNLOAD_URL -o openstudio.deb\ - && gdebi -n openstudio.deb \ - && rm -f openstudio.deb \ - && cd /usr/local/openstudio* \ - && rm -rf EnergyPlus \ - && ln -s $ENERGYPLUS_DIR EnergyPlus - -# Install commands for Spawn -ENV SPAWN_VERSION=0.3.0-69040695f9 -RUN curl -SL https://spawn.s3.amazonaws.com/custom/Spawn-$SPAWN_VERSION-Linux.tar.gz -o spawn.tar.gz \ - && tar -C /usr/local/ -xzf spawn.tar.gz \ - && ln -s /usr/local/Spawn-$SPAWN_VERSION-Linux/bin/spawn-$SPAWN_VERSION /usr/local/bin/ \ - && rm spawn.tar.gz - -## MODELICA -# Modelica requires libgfortran3 which is not in apt for 20.04 -RUN curl -SLO http://archive.ubuntu.com/ubuntu/pool/universe/g/gcc-6/gcc-6-base_6.4.0-17ubuntu1_amd64.deb \ - && curl -SLO http://archive.ubuntu.com/ubuntu/pool/universe/g/gcc-6/libgfortran3_6.4.0-17ubuntu1_amd64.deb \ - && dpkg -i gcc-6-base_6.4.0-17ubuntu1_amd64.deb \ - && dpkg -i libgfortran3_6.4.0-17ubuntu1_amd64.deb \ - && ln -s /usr/lib/x86_64-linux-gnu/libffi.so.7 /usr/lib/x86_64-linux-gnu/libffi.so.6 \ - && rm *.deb - -COPY requirements.txt $BUILD_DIR -RUN pip install -r requirements.txt && \ - rm requirements.txt - -# Install Assimulo for PyFMI -RUN curl -SLO https://github.com/modelon-community/Assimulo/releases/download/Assimulo-3.4.3/Assimulo-3.4.3-cp38-cp38-linux_x86_64.whl \ - && pip install Assimulo-3.4.3-cp38-cp38-linux_x86_64.whl \ - && rm Assimulo-3.4.3-cp38-cp38-linux_x86_64.whl - -# Install PyFMI -RUN curl -SLO https://github.com/modelon-community/PyFMI/releases/download/PyFMI-2.11.0/PyFMI-2.11.0-cp38-cp38-linux_x86_64.whl \ - && pip install PyFMI-2.11.0-cp38-cp38-linux_x86_64.whl \ - && rm PyFMI-2.11.0-cp38-cp38-linux_x86_64.whl - -ENV PYTHONPATH=${PYTHONPATH}:${ENERGYPLUS_DIR} - -ENV SEPARATE_PROCESS_JVM /usr/lib/jvm/java-8-openjdk-amd64/ -ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/ +WORKDIR $HOME From e771417a9b7d2296dde3581ccb0bd7f58a98e56f Mon Sep 17 00:00:00 2001 From: TShapinsky Date: Sat, 20 Jul 2024 13:27:02 -0600 Subject: [PATCH 02/19] platform to platforms --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4832571..f6c89a1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -45,6 +45,6 @@ jobs: context: . push: true target: alfalfa-dependencies - platform: linux/amd64,linux/arm64,linux/arm/v7 + platforms: linux/amd64,linux/arm64,linux/arm/v7 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.output.labels }} From 006d8e6133986c19a7efbc27cb695c37d57b0cff Mon Sep 17 00:00:00 2001 From: TShapinsky Date: Sat, 20 Jul 2024 13:28:29 -0600 Subject: [PATCH 03/19] enable multiplatform --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f6c89a1..1782f64 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -45,6 +45,7 @@ jobs: context: . push: true target: alfalfa-dependencies + multiPlatform: true platforms: linux/amd64,linux/arm64,linux/arm/v7 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.output.labels }} From 7ca813e00af2b1d3625232d85512ef38086bafeb Mon Sep 17 00:00:00 2001 From: TShapinsky Date: Sat, 20 Jul 2024 13:31:13 -0600 Subject: [PATCH 04/19] setup qemu and buildx --- .github/workflows/build.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1782f64..01f2fc5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,6 +20,12 @@ jobs: - name: Checkout Code uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Log into container registry uses: docker/login-action@v2 with: @@ -45,7 +51,6 @@ jobs: context: . push: true target: alfalfa-dependencies - multiPlatform: true platforms: linux/amd64,linux/arm64,linux/arm/v7 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.output.labels }} From db8a54fe1ccf2fcbf89d3338f74a302c5c287b45 Mon Sep 17 00:00:00 2001 From: TShapinsky Date: Sat, 20 Jul 2024 13:33:28 -0600 Subject: [PATCH 05/19] only support x86_64 and aarch_64 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 01f2fc5..d62a79d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -51,6 +51,6 @@ jobs: context: . push: true target: alfalfa-dependencies - platforms: linux/amd64,linux/arm64,linux/arm/v7 + platforms: linux/amd64,linux/arm64 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.output.labels }} From c3c61767f90e9b727487847d01293ae601ad39c8 Mon Sep 17 00:00:00 2001 From: TShapinsky Date: Sat, 20 Jul 2024 14:19:10 -0600 Subject: [PATCH 06/19] add logic for changing architecture for what OS and E+ expect --- Dockerfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index dd0fe38..996930b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -86,8 +86,10 @@ RUN apt update \ curl WORKDIR /artifacts -RUN curl -SfL https://github.com/NREL/EnergyPlus/releases/download/v${ENERGYPLUS_VERSION}/EnergyPlus-${ENERGYPLUS_VERSION}-${ENERGYPLUS_VERSION_SHA}-Linux-Ubuntu22.04-$(uname -m).tar.gz -o energyplus.tar.gz -RUN curl -SfL https://github.com/NREL/OpenStudio/releases/download/v${OPENSTUDIO_VERSION}/OpenStudio-${OPENSTUDIO_VERSION}+${OPENSTUDIO_VERSION_SHA}-Ubuntu-22.04-$(uname -m).deb -o openstudio.deb +RUN export ARCHITECTURE=x86_64 \ + && if [ $(uname -m) == "aarch64" ]; then export ARCHITECTURE=arm64; fi \ + && curl -SfL https://github.com/NREL/EnergyPlus/releases/download/v${ENERGYPLUS_VERSION}/EnergyPlus-${ENERGYPLUS_VERSION}-${ENERGYPLUS_VERSION_SHA}-Linux-Ubuntu22.04-${ARCHITECTURE}.tar.gz -o energyplus.tar.gz \ + && curl -SfL https://github.com/NREL/OpenStudio/releases/download/v${OPENSTUDIO_VERSION}/OpenStudio-${OPENSTUDIO_VERSION}+${OPENSTUDIO_VERSION_SHA}-Ubuntu-22.04-${ARCHITECTURE}.deb -o openstudio.deb FROM python:${PYTHON_VERSION}-slim-${DEBIAN_VERSION} as alfalfa-dependencies From 589a2db78d3844f1e5eb666dadf77ca910c8f2f7 Mon Sep 17 00:00:00 2001 From: TShapinsky Date: Sat, 20 Jul 2024 15:03:53 -0600 Subject: [PATCH 07/19] purge cache and increase timeout --- .github/workflows/build.yml | 2 +- Dockerfile | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d62a79d..0a51f53 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,7 +15,7 @@ jobs: build-image: name: Build image runs-on: ubuntu-latest - timeout-minutes: 20 + timeout-minutes: 40 steps: - name: Checkout Code uses: actions/checkout@v3 diff --git a/Dockerfile b/Dockerfile index 996930b..cc1d7a7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -98,27 +98,28 @@ ENV HOME /alfalfa WORKDIR /artifacts -COPY --from=modelica-dependencies /artifacts/* . -COPY --from=energyplus-dependencies /artifacts/* . - RUN apt update \ && apt install -y \ gdebi-core \ - openjdk-17-jdk + openjdk-17-jdk \ + && rm -rf /var/lib/apt/lists/* # RUN update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java \ # && update-alternatives --set javac /usr/lib/jvm/java-8-openjdk-amd64/bin/javac -RUN pip3 install *.whl -RUN mkdir ${ENERGYPLUS_DIR} \ +RUN --mount=type=bind,from=modelica-dependencies,source=/artifacts,target=/artifacts pip3 install *.whl + +RUN --mount=type=bind,from=energyplus-dependencies,source=/artifacts,target=/artifacts mkdir ${ENERGYPLUS_DIR} \ && tar -C $ENERGYPLUS_DIR/ --strip-components=1 -xzf energyplus.tar.gz \ && ln -s $ENERGYPLUS_DIR/energyplus /usr/local/bin/ \ && ln -s $ENERGYPLUS_DIR/ExpandObjects /usr/local/bin/ \ && ln -s $ENERGYPLUS_DIR/runenergyplus /usr/local/bin/ -RUN gdebi -n openstudio.deb \ +RUN --mount=type=bind,from=energyplus-dependencies,source=/artifacts,target=/artifacts apt update \ + && gdebi -n openstudio.deb \ && cd /usr/local/openstudio* \ && rm -rf EnergyPlus \ - && ln -s ${ENERGYPLUS_DIR} EnergyPlus + && ln -s ${ENERGYPLUS_DIR} EnergyPlus \ + && rm -rf /var/lib/apt/lists/* WORKDIR $HOME From 2065ac106dc13b6f539212dcf74418be096a5871 Mon Sep 17 00:00:00 2001 From: TShapinsky Date: Sat, 20 Jul 2024 15:45:06 -0600 Subject: [PATCH 08/19] python 3.8 and remove timeout temporarily --- .github/workflows/build.yml | 2 +- Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0a51f53..11f58b9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,7 +15,7 @@ jobs: build-image: name: Build image runs-on: ubuntu-latest - timeout-minutes: 40 + # timeout-minutes: 40 steps: - name: Checkout Code uses: actions/checkout@v3 diff --git a/Dockerfile b/Dockerfile index cc1d7a7..bc2e431 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG PYTHON_VERSION=3.10.14 +ARG PYTHON_VERSION=3.8.19 ARG DEBIAN_VERSION=bookworm FROM python:${PYTHON_VERSION}-slim-${DEBIAN_VERSION} as modelica-dependencies ARG SUNDIALS_VERSION=v2.7.0 From 9369b5671d88a77f40e971e993c818bd5177ae65 Mon Sep 17 00:00:00 2001 From: TShapinsky Date: Sun, 21 Jul 2024 10:23:00 -0600 Subject: [PATCH 09/19] dual python installation --- Dockerfile | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 110 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index bc2e431..82d2d99 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,8 @@ -ARG PYTHON_VERSION=3.8.19 +ARG PYTHON_VERSION=3.10.14 ARG DEBIAN_VERSION=bookworm FROM python:${PYTHON_VERSION}-slim-${DEBIAN_VERSION} as modelica-dependencies ARG SUNDIALS_VERSION=v2.7.0 +ARG ASSIMULO_VERSION=3.5.2 RUN apt update \ && apt install -y \ cmake \ @@ -52,7 +53,7 @@ RUN git clone --depth 1 -b ${SUNDIALS_VERSION} https://github.com/LLNL/sundials. && make -j4 \ && make install -RUN git clone --depth 1 -b Assimulo-3.5.2 https://github.com/modelon-community/Assimulo.git \ +RUN git clone --depth 1 -b Assimulo-${ASSIMULO_VERSION} https://github.com/modelon-community/Assimulo.git \ && cd Assimulo \ && python3 setup.py install --user --sundials-home=/usr --blas-home=/usr/lib/$(uname -m)-linux-gnu --lapack-home=/usr/lib/$(uname -m)-linux-gnu --superlu-home=/usr \ && python3 setup.py bdist_wheel @@ -91,7 +92,113 @@ RUN export ARCHITECTURE=x86_64 \ && curl -SfL https://github.com/NREL/EnergyPlus/releases/download/v${ENERGYPLUS_VERSION}/EnergyPlus-${ENERGYPLUS_VERSION}-${ENERGYPLUS_VERSION_SHA}-Linux-Ubuntu22.04-${ARCHITECTURE}.tar.gz -o energyplus.tar.gz \ && curl -SfL https://github.com/NREL/OpenStudio/releases/download/v${OPENSTUDIO_VERSION}/OpenStudio-${OPENSTUDIO_VERSION}+${OPENSTUDIO_VERSION_SHA}-Ubuntu-22.04-${ARCHITECTURE}.deb -o openstudio.deb -FROM python:${PYTHON_VERSION}-slim-${DEBIAN_VERSION} as alfalfa-dependencies +FROM python:${PYTHON_VERSION}-slim-${DEBIAN_VERSION} as dual-python + + ENV PYTHON_VERSION 3.8.19 + ENV GPG_KEY E3FF2839C048B25C084DEBE9B26995E310250568 + + RUN set -eux; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + dpkg-dev \ + gcc \ + gnupg \ + libbluetooth-dev \ + libbz2-dev \ + libc6-dev \ + libdb-dev \ + libexpat1-dev \ + libffi-dev \ + libgdbm-dev \ + liblzma-dev \ + libncursesw5-dev \ + libreadline-dev \ + libsqlite3-dev \ + libssl-dev \ + make \ + tk-dev \ + uuid-dev \ + wget \ + xz-utils \ + zlib1g-dev \ + ; \ + \ + wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ + wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc"; \ + GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \ + gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY"; \ + gpg --batch --verify python.tar.xz.asc python.tar.xz; \ + gpgconf --kill all; \ + rm -rf "$GNUPGHOME" python.tar.xz.asc; \ + mkdir -p /usr/src/python; \ + tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ + rm python.tar.xz; \ + \ + cd /usr/src/python; \ + gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ + ./configure \ + --build="$gnuArch" \ + --enable-loadable-sqlite-extensions \ + --enable-optimizations \ + --enable-option-checking=fatal \ + --enable-shared \ + --with-system-expat \ + --without-ensurepip \ + ; \ + nproc="$(nproc)"; \ + EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \ + LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \ + LDFLAGS="${LDFLAGS:--Wl},--strip-all"; \ + make -j "$nproc" \ + "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ + "LDFLAGS=${LDFLAGS:-}" \ + "PROFILE_TASK=${PROFILE_TASK:-}" \ + ; \ + # https://github.com/docker-library/python/issues/784 + # prevent accidental usage of a system installed libpython of the same version + rm python; \ + make -j "$nproc" \ + "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ + "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ + "PROFILE_TASK=${PROFILE_TASK:-}" \ + python \ + ; \ + make altinstall; \ + \ + cd /; \ + rm -rf /usr/src/python; \ + \ + find /usr/local -depth \ + \( \ + \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ + -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ + -o \( -type f -a -name 'wininst-*.exe' \) \ + \) -exec rm -rf '{}' + \ + ; \ + \ + ldconfig; \ + \ + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark; \ + find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec ldd '{}' ';' \ + | awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); printf "*%s\n", so }' \ + | sort -u \ + | xargs -r dpkg-query --search \ + | cut -d: -f1 \ + | sort -u \ + | xargs -r apt-mark manual \ + ; \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/*; \ + \ + python3.8 --version + + RUN python3.8 -m ensurepip --altinstall + + +FROM dual-python as alfalfa-dependencies ENV ENERGYPLUS_DIR /usr/local/EnergyPlus ENV HOME /alfalfa From 8eec1d6efb2474db344890998cc20eacc3f68f9a Mon Sep 17 00:00:00 2001 From: TShapinsky Date: Sun, 21 Jul 2024 12:33:02 -0600 Subject: [PATCH 10/19] fix equivalence check --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 82d2d99..b23b029 100644 --- a/Dockerfile +++ b/Dockerfile @@ -88,7 +88,7 @@ RUN apt update \ WORKDIR /artifacts RUN export ARCHITECTURE=x86_64 \ - && if [ $(uname -m) == "aarch64" ]; then export ARCHITECTURE=arm64; fi \ + && if [ "$(uname -m)" = "aarch64" ]; then export ARCHITECTURE=arm64; fi \ && curl -SfL https://github.com/NREL/EnergyPlus/releases/download/v${ENERGYPLUS_VERSION}/EnergyPlus-${ENERGYPLUS_VERSION}-${ENERGYPLUS_VERSION_SHA}-Linux-Ubuntu22.04-${ARCHITECTURE}.tar.gz -o energyplus.tar.gz \ && curl -SfL https://github.com/NREL/OpenStudio/releases/download/v${OPENSTUDIO_VERSION}/OpenStudio-${OPENSTUDIO_VERSION}+${OPENSTUDIO_VERSION_SHA}-Ubuntu-22.04-${ARCHITECTURE}.deb -o openstudio.deb From c71eb4c5dce086a99727433819a9dfacfbf47dd0 Mon Sep 17 00:00:00 2001 From: TShapinsky Date: Mon, 22 Jul 2024 08:43:16 -0600 Subject: [PATCH 11/19] update actions --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 11f58b9..940513e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,7 +18,7 @@ jobs: # timeout-minutes: 40 steps: - name: Checkout Code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -27,14 +27,14 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Log into container registry - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Docker meta - uses: docker/metadata-action@v4 + uses: docker/metadata-action@v5 id: meta with: images: | From 58f7ebb3011565884fc0c52fc651fae27419e1ba Mon Sep 17 00:00:00 2001 From: TShapinsky Date: Mon, 22 Jul 2024 10:55:30 -0600 Subject: [PATCH 12/19] add bcvtb to regain e+ support paridy with current release --- Dockerfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index b23b029..efa7aa3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -90,7 +90,8 @@ WORKDIR /artifacts RUN export ARCHITECTURE=x86_64 \ && if [ "$(uname -m)" = "aarch64" ]; then export ARCHITECTURE=arm64; fi \ && curl -SfL https://github.com/NREL/EnergyPlus/releases/download/v${ENERGYPLUS_VERSION}/EnergyPlus-${ENERGYPLUS_VERSION}-${ENERGYPLUS_VERSION_SHA}-Linux-Ubuntu22.04-${ARCHITECTURE}.tar.gz -o energyplus.tar.gz \ - && curl -SfL https://github.com/NREL/OpenStudio/releases/download/v${OPENSTUDIO_VERSION}/OpenStudio-${OPENSTUDIO_VERSION}+${OPENSTUDIO_VERSION_SHA}-Ubuntu-22.04-${ARCHITECTURE}.deb -o openstudio.deb + && curl -SfL https://github.com/NREL/OpenStudio/releases/download/v${OPENSTUDIO_VERSION}/OpenStudio-${OPENSTUDIO_VERSION}+${OPENSTUDIO_VERSION_SHA}-Ubuntu-22.04-${ARCHITECTURE}.deb -o openstudio.deb \ + && curl -SfL http://openstudio-resources.s3.amazonaws.com/bcvtb-linux.tar.gz -o bcvtb.tar.gz FROM python:${PYTHON_VERSION}-slim-${DEBIAN_VERSION} as dual-python @@ -230,3 +231,6 @@ RUN --mount=type=bind,from=energyplus-dependencies,source=/artifacts,target=/art && rm -rf /var/lib/apt/lists/* WORKDIR $HOME + +# Only the xml lib component of bcvtb is actaully required for communication, so we just extract that to save space +RUN --mount=type=bind,from=energyplus-dependencies,source=/artifacts,target=/artifacts tar -xzf /artifacts/bcvtb.tar.gz bcvtb/lib/xml From 96a2065b79c90a3a207748cb3ff18266748262bf Mon Sep 17 00:00:00 2001 From: TShapinsky Date: Tue, 23 Jul 2024 10:19:01 -0600 Subject: [PATCH 13/19] add old libgfortran --- Dockerfile | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index efa7aa3..d99069b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,8 @@ RUN apt update \ libhypre-dev \ curl \ git \ - build-essential + build-essential \ + dpkg-dev RUN python3 -m pip install \ Cython \ @@ -21,7 +22,8 @@ RUN python3 -m pip install \ nose-py3 \ setuptools==69.1.0 -RUN ln -s /usr/lib/$(uname -m)-linux-gnu/libblas.so /usr/lib/$(uname -m)-linux-gnu/libblas_OPENMP.so +RUN gnuArch="$(dpkg-architecture --query DEB_HOST_MULTIARCH)"; \ +ln -s /usr/lib/$gnuArch/libblas.so /usr/lib/$gnuArch/libblas_OPENMP.so WORKDIR /build @@ -53,9 +55,10 @@ RUN git clone --depth 1 -b ${SUNDIALS_VERSION} https://github.com/LLNL/sundials. && make -j4 \ && make install -RUN git clone --depth 1 -b Assimulo-${ASSIMULO_VERSION} https://github.com/modelon-community/Assimulo.git \ +RUN gnuArch="$(dpkg-architecture --query DEB_HOST_MULTIARCH)" \ + && git clone --depth 1 -b Assimulo-${ASSIMULO_VERSION} https://github.com/modelon-community/Assimulo.git \ && cd Assimulo \ - && python3 setup.py install --user --sundials-home=/usr --blas-home=/usr/lib/$(uname -m)-linux-gnu --lapack-home=/usr/lib/$(uname -m)-linux-gnu --superlu-home=/usr \ + && python3 setup.py install --user --sundials-home=/usr --blas-home=/usr/lib/${gnuArch} --lapack-home=/usr/lib/${gnuArch} --superlu-home=/usr \ && python3 setup.py bdist_wheel RUN git clone --depth 1 -b 2.4.1 https://github.com/modelon-community/fmi-library.git \ @@ -76,6 +79,12 @@ WORKDIR /artifacts RUN cp /build/Assimulo/build/dist/* . \ && cp /build/PyFMI/dist/* . +RUN gnuArch="$(dpkg-architecture --query DEB_HOST_ARCH_CPU)"; export gnuArch\ + && curl -SfL http://ftp.us.debian.org/debian/pool/main/g/gcc-7/libgfortran4_7.4.0-6_${gnuArch}.deb -o libgfortran4.deb \ + && curl -SfL http://ftp.us.debian.org/debian/pool/main/g/gcc-7/gcc-7-base_7.4.0-6_${gnuArch}.deb -o gcc-7.deb \ + && curl -SfL https://archive.debian.org/debian/pool/main/g/gcc-6/gcc-6-base_6.3.0-18+deb9u1_${gnuArch}.deb -o gcc-6.deb \ + && curl -SfL https://archive.debian.org/debian/pool/main/g/gcc-6/libgfortran3_6.3.0-18+deb9u1_${gnuArch}.deb -o libgfortran3.deb + FROM python:${PYTHON_VERSION}-slim-${DEBIAN_VERSION} as energyplus-dependencies ARG OPENSTUDIO_VERSION=3.8.0 ARG OPENSTUDIO_VERSION_SHA=f953b6fcaf @@ -87,11 +96,12 @@ RUN apt update \ curl WORKDIR /artifacts -RUN export ARCHITECTURE=x86_64 \ - && if [ "$(uname -m)" = "aarch64" ]; then export ARCHITECTURE=arm64; fi \ - && curl -SfL https://github.com/NREL/EnergyPlus/releases/download/v${ENERGYPLUS_VERSION}/EnergyPlus-${ENERGYPLUS_VERSION}-${ENERGYPLUS_VERSION_SHA}-Linux-Ubuntu22.04-${ARCHITECTURE}.tar.gz -o energyplus.tar.gz \ - && curl -SfL https://github.com/NREL/OpenStudio/releases/download/v${OPENSTUDIO_VERSION}/OpenStudio-${OPENSTUDIO_VERSION}+${OPENSTUDIO_VERSION_SHA}-Ubuntu-22.04-${ARCHITECTURE}.deb -o openstudio.deb \ - && curl -SfL http://openstudio-resources.s3.amazonaws.com/bcvtb-linux.tar.gz -o bcvtb.tar.gz + +RUN export gnuArch=x86_64; if [ "$(uname -m)" = "aarch64" ]; then gnuArch=arm64; fi; export gnuArch \ + && echo https://github.com/NREL/EnergyPlus/releases/download/v${ENERGYPLUS_VERSION}/EnergyPlus-${ENERGYPLUS_VERSION}-${ENERGYPLUS_VERSION_SHA}-Linux-Ubuntu22.04-${gnuArch}.tar.gz \ + && curl -SfL https://github.com/NREL/EnergyPlus/releases/download/v${ENERGYPLUS_VERSION}/EnergyPlus-${ENERGYPLUS_VERSION}-${ENERGYPLUS_VERSION_SHA}-Linux-Ubuntu22.04-${gnuArch}.tar.gz -o energyplus.tar.gz \ + && curl -SfL https://github.com/NREL/OpenStudio/releases/download/v${OPENSTUDIO_VERSION}/OpenStudio-${OPENSTUDIO_VERSION}+${OPENSTUDIO_VERSION_SHA}-Ubuntu-22.04-${gnuArch}.deb -o openstudio.deb \ + && curl -SfL https://openstudio-resources.s3.amazonaws.com/bcvtb-linux.tar.gz -o bcvtb.tar.gz FROM python:${PYTHON_VERSION}-slim-${DEBIAN_VERSION} as dual-python @@ -215,7 +225,12 @@ RUN apt update \ # RUN update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java \ # && update-alternatives --set javac /usr/lib/jvm/java-8-openjdk-amd64/bin/javac -RUN --mount=type=bind,from=modelica-dependencies,source=/artifacts,target=/artifacts pip3 install *.whl +RUN --mount=type=bind,from=modelica-dependencies,source=/artifacts,target=/artifacts pip3 install *.whl \ + && apt update \ + && gdebi -n gcc-6.deb \ + && gdebi -n libgfortran3.deb \ + && gdebi -n gcc-7.deb \ + && gdebi -n libgfortran4.deb RUN --mount=type=bind,from=energyplus-dependencies,source=/artifacts,target=/artifacts mkdir ${ENERGYPLUS_DIR} \ && tar -C $ENERGYPLUS_DIR/ --strip-components=1 -xzf energyplus.tar.gz \ From cd592a5943c998635bee45c78686461689ac9c29 Mon Sep 17 00:00:00 2001 From: TShapinsky Date: Wed, 24 Jul 2024 08:42:42 -0600 Subject: [PATCH 14/19] install sundials on final image --- Dockerfile | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index d99069b..152a6f7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ ARG PYTHON_VERSION=3.10.14 ARG DEBIAN_VERSION=bookworm FROM python:${PYTHON_VERSION}-slim-${DEBIAN_VERSION} as modelica-dependencies -ARG SUNDIALS_VERSION=v2.7.0 +ARG SUNDIALS_VERSION=v3.2.0 ARG ASSIMULO_VERSION=3.5.2 RUN apt update \ && apt install -y \ @@ -35,8 +35,8 @@ RUN curl -fSsL https://portal.nersc.gov/project/sparse/superlu/superlu_mt_3.1.ta RUN git clone --depth 1 -b ${SUNDIALS_VERSION} https://github.com/LLNL/sundials.git \ && cd sundials \ - && echo "target_link_libraries(sundials_idas_shared lapack blas superlu_mt_OPENMP)" >> src/idas/CMakeLists.txt \ - && echo "target_link_libraries(sundials_kinsol_shared lapack blas superlu_mt_OPENMP)" >> src/kinsol/CMakeLists.txt \ + # && echo "target_link_libraries(sundials_idas_shared lapack blas superlu_mt_OPENMP)" >> src/idas/CMakeLists.txt \ + # && echo "target_link_libraries(sundials_kinsol_shared lapack blas superlu_mt_OPENMP)" >> src/kinsol/CMakeLists.txt \ && mkdir build && cd build \ && cmake \ -LAH \ @@ -45,21 +45,22 @@ RUN git clone --depth 1 -b ${SUNDIALS_VERSION} https://github.com/LLNL/sundials. -DSUPERLUMT_INCLUDE_DIR=/usr/include \ -DSUPERLUMT_LIBRARY=/usr/lib/libsuperlu_mt_OPENMP.a \ -DSUPERLUMT_THREAD_TYPE=OpenMP \ - -DCMAKE_INSTALL_PREFIX=/usr \ + -DCMAKE_INSTALL_PREFIX=/artifacts/sundials \ -DSUPERLUMT_ENABLE=ON \ -DLAPACK_ENABLE=ON \ -DEXAMPLES_ENABLE=OFF \ -DEXAMPLES_ENABLE_C=OFF \ - -DBUILD_STATIC_LIBS=OFF \ + # -DBUILD_STATIC_LIBS=OFF \ .. \ && make -j4 \ - && make install + && make install \ + && cp -r /artifacts/sundials/* /usr RUN gnuArch="$(dpkg-architecture --query DEB_HOST_MULTIARCH)" \ && git clone --depth 1 -b Assimulo-${ASSIMULO_VERSION} https://github.com/modelon-community/Assimulo.git \ && cd Assimulo \ - && python3 setup.py install --user --sundials-home=/usr --blas-home=/usr/lib/${gnuArch} --lapack-home=/usr/lib/${gnuArch} --superlu-home=/usr \ - && python3 setup.py bdist_wheel + && python3 setup.py install --sundials-home=/usr --blas-home=/usr/lib/${gnuArch} --lapack-home=/usr/lib/${gnuArch} --superlu-home=/usr \ + && python3 setup.py bdist_wheel --sundials-home=/usr --blas-home=/usr/lib/${gnuArch} --lapack-home=/usr/lib/${gnuArch} --superlu-home=/usr RUN git clone --depth 1 -b 2.4.1 https://github.com/modelon-community/fmi-library.git \ && cd fmi-library \ @@ -220,6 +221,7 @@ RUN apt update \ && apt install -y \ gdebi-core \ openjdk-17-jdk \ + libgfortran5 \ && rm -rf /var/lib/apt/lists/* # RUN update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java \ @@ -230,7 +232,8 @@ RUN --mount=type=bind,from=modelica-dependencies,source=/artifacts,target=/artif && gdebi -n gcc-6.deb \ && gdebi -n libgfortran3.deb \ && gdebi -n gcc-7.deb \ - && gdebi -n libgfortran4.deb + && gdebi -n libgfortran4.deb \ + && cp -r /artifacts/sundials/* /usr RUN --mount=type=bind,from=energyplus-dependencies,source=/artifacts,target=/artifacts mkdir ${ENERGYPLUS_DIR} \ && tar -C $ENERGYPLUS_DIR/ --strip-components=1 -xzf energyplus.tar.gz \ From fee14011974dee4c15b519ef26753eb824e4b1a1 Mon Sep 17 00:00:00 2001 From: TShapinsky Date: Thu, 25 Jul 2024 13:32:58 -0600 Subject: [PATCH 15/19] bake shared libraries into Assimulo wheel --- .github/workflows/build.yml | 2 ++ Dockerfile | 67 +++++++++++++++++++------------------ 2 files changed, 37 insertions(+), 32 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 940513e..3dba9a1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,6 +44,8 @@ jobs: type=sha type=semver,pattern={{version}},enable=${{ github.event_name == 'release' }} type=semver,pattern={{major}},enable=${{ github.event_name == 'release' }} + type=semver,pattern={{major}}.{{minor}},enable=${{ github.event_name == 'release' }} + type=edge - name: Build and push uses: docker/build-push-action@v6 diff --git a/Dockerfile b/Dockerfile index 152a6f7..bfeb447 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,9 @@ ARG PYTHON_VERSION=3.10.14 ARG DEBIAN_VERSION=bookworm -FROM python:${PYTHON_VERSION}-slim-${DEBIAN_VERSION} as modelica-dependencies -ARG SUNDIALS_VERSION=v3.2.0 + +# Build modelica-dependencies on bullseye (this uses an older version of GLibc which allows for making manylinux wheels) +FROM python:${PYTHON_VERSION}-slim-bullseye AS modelica-dependencies +ARG SUNDIALS_VERSION=v7.1.1 ARG ASSIMULO_VERSION=3.5.2 RUN apt update \ && apt install -y \ @@ -12,15 +14,17 @@ RUN apt update \ curl \ git \ build-essential \ - dpkg-dev + dpkg-dev \ + && rm -rf /var/lib/apt/lists/* RUN python3 -m pip install \ Cython \ numpy \ scipy \ matplotlib \ - nose-py3 \ - setuptools==69.1.0 + setuptools==69.1.0 \ + auditwheel \ + patchelf RUN gnuArch="$(dpkg-architecture --query DEB_HOST_MULTIARCH)"; \ ln -s /usr/lib/$gnuArch/libblas.so /usr/lib/$gnuArch/libblas_OPENMP.so @@ -35,8 +39,6 @@ RUN curl -fSsL https://portal.nersc.gov/project/sparse/superlu/superlu_mt_3.1.ta RUN git clone --depth 1 -b ${SUNDIALS_VERSION} https://github.com/LLNL/sundials.git \ && cd sundials \ - # && echo "target_link_libraries(sundials_idas_shared lapack blas superlu_mt_OPENMP)" >> src/idas/CMakeLists.txt \ - # && echo "target_link_libraries(sundials_kinsol_shared lapack blas superlu_mt_OPENMP)" >> src/kinsol/CMakeLists.txt \ && mkdir build && cd build \ && cmake \ -LAH \ @@ -45,22 +47,22 @@ RUN git clone --depth 1 -b ${SUNDIALS_VERSION} https://github.com/LLNL/sundials. -DSUPERLUMT_INCLUDE_DIR=/usr/include \ -DSUPERLUMT_LIBRARY=/usr/lib/libsuperlu_mt_OPENMP.a \ -DSUPERLUMT_THREAD_TYPE=OpenMP \ - -DCMAKE_INSTALL_PREFIX=/artifacts/sundials \ + -DCMAKE_INSTALL_PREFIX=/usr \ -DSUPERLUMT_ENABLE=ON \ + -DSUNDIALS_INDEX_SIZE=32 \ -DLAPACK_ENABLE=ON \ -DEXAMPLES_ENABLE=OFF \ -DEXAMPLES_ENABLE_C=OFF \ - # -DBUILD_STATIC_LIBS=OFF \ .. \ && make -j4 \ - && make install \ - && cp -r /artifacts/sundials/* /usr + && make install RUN gnuArch="$(dpkg-architecture --query DEB_HOST_MULTIARCH)" \ - && git clone --depth 1 -b Assimulo-${ASSIMULO_VERSION} https://github.com/modelon-community/Assimulo.git \ + && git clone --depth 1 -b Assimulo-3.5.2 https://github.com/modelon-community/Assimulo.git \ && cd Assimulo \ - && python3 setup.py install --sundials-home=/usr --blas-home=/usr/lib/${gnuArch} --lapack-home=/usr/lib/${gnuArch} --superlu-home=/usr \ - && python3 setup.py bdist_wheel --sundials-home=/usr --blas-home=/usr/lib/${gnuArch} --lapack-home=/usr/lib/${gnuArch} --superlu-home=/usr + && python3 setup.py bdist_wheel --sundials-home=/usr --blas-home=/usr/lib/${gnuArch} --lapack-home=/usr/lib/${gnuArch} --superlu-home=/usr \ + && auditwheel repair --plat manylinux_2_31_$(uname -m) build/dist/*.whl \ + && pip3 install wheelhouse/*.whl RUN git clone --depth 1 -b 2.4.1 https://github.com/modelon-community/fmi-library.git \ && cd fmi-library \ @@ -73,20 +75,21 @@ RUN git clone --depth 1 -b 2.4.1 https://github.com/modelon-community/fmi-librar RUN git clone --depth 1 -b PyFMI-2.13.1 https://github.com/modelon-community/PyFMI.git \ && cd PyFMI \ - && python3 setup.py bdist_wheel --fmil-home=/build/fmi-libary/fmi_library + && python3 setup.py bdist_wheel --fmil-home=/build/fmi-libary/fmi_library --with-openmp\ + && auditwheel repair --plat manylinux_2_31_$(uname -m) dist/*.whl WORKDIR /artifacts -RUN cp /build/Assimulo/build/dist/* . \ - && cp /build/PyFMI/dist/* . +RUN cp /build/Assimulo/wheelhouse/* . \ + && cp /build/PyFMI/wheelhouse/* . -RUN gnuArch="$(dpkg-architecture --query DEB_HOST_ARCH_CPU)"; export gnuArch\ +RUN gnuArch="$(dpkg-architecture --query DEB_HOST_ARCH_CPU)"\ && curl -SfL http://ftp.us.debian.org/debian/pool/main/g/gcc-7/libgfortran4_7.4.0-6_${gnuArch}.deb -o libgfortran4.deb \ && curl -SfL http://ftp.us.debian.org/debian/pool/main/g/gcc-7/gcc-7-base_7.4.0-6_${gnuArch}.deb -o gcc-7.deb \ && curl -SfL https://archive.debian.org/debian/pool/main/g/gcc-6/gcc-6-base_6.3.0-18+deb9u1_${gnuArch}.deb -o gcc-6.deb \ && curl -SfL https://archive.debian.org/debian/pool/main/g/gcc-6/libgfortran3_6.3.0-18+deb9u1_${gnuArch}.deb -o libgfortran3.deb -FROM python:${PYTHON_VERSION}-slim-${DEBIAN_VERSION} as energyplus-dependencies +FROM python:${PYTHON_VERSION}-slim-${DEBIAN_VERSION} AS energyplus-dependencies ARG OPENSTUDIO_VERSION=3.8.0 ARG OPENSTUDIO_VERSION_SHA=f953b6fcaf ARG ENERGYPLUS_VERSION=24.1.0 @@ -94,7 +97,8 @@ ARG ENERGYPLUS_VERSION_SHA=9d7789a3ac RUN apt update \ && apt install -y \ - curl + curl \ + && rm -rf /var/lib/apt/lists/* WORKDIR /artifacts @@ -104,10 +108,10 @@ RUN export gnuArch=x86_64; if [ "$(uname -m)" = "aarch64" ]; then gnuArch=arm64; && curl -SfL https://github.com/NREL/OpenStudio/releases/download/v${OPENSTUDIO_VERSION}/OpenStudio-${OPENSTUDIO_VERSION}+${OPENSTUDIO_VERSION_SHA}-Ubuntu-22.04-${gnuArch}.deb -o openstudio.deb \ && curl -SfL https://openstudio-resources.s3.amazonaws.com/bcvtb-linux.tar.gz -o bcvtb.tar.gz -FROM python:${PYTHON_VERSION}-slim-${DEBIAN_VERSION} as dual-python +FROM python:${PYTHON_VERSION}-slim-${DEBIAN_VERSION} AS dual-python - ENV PYTHON_VERSION 3.8.19 - ENV GPG_KEY E3FF2839C048B25C084DEBE9B26995E310250568 + ENV PYTHON_VERSION=3.8.19 + ENV GPG_KEY=E3FF2839C048B25C084DEBE9B26995E310250568 RUN set -eux; \ \ @@ -210,10 +214,10 @@ FROM python:${PYTHON_VERSION}-slim-${DEBIAN_VERSION} as dual-python RUN python3.8 -m ensurepip --altinstall -FROM dual-python as alfalfa-dependencies +FROM dual-python AS alfalfa-dependencies -ENV ENERGYPLUS_DIR /usr/local/EnergyPlus -ENV HOME /alfalfa +ENV ENERGYPLUS_DIR=/usr/local/EnergyPlus +ENV HOME=/alfalfa WORKDIR /artifacts @@ -224,23 +228,22 @@ RUN apt update \ libgfortran5 \ && rm -rf /var/lib/apt/lists/* -# RUN update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java \ -# && update-alternatives --set javac /usr/lib/jvm/java-8-openjdk-amd64/bin/javac - -RUN --mount=type=bind,from=modelica-dependencies,source=/artifacts,target=/artifacts pip3 install *.whl \ +# Install Assimulo, PyFMI and Old Fortran Libraries +RUN --mount=type=bind,from=modelica-dependencies,source=/artifacts,target=/artifacts pip3 install Assimulo*.whl PyFMI*.whl \ && apt update \ && gdebi -n gcc-6.deb \ && gdebi -n libgfortran3.deb \ && gdebi -n gcc-7.deb \ - && gdebi -n libgfortran4.deb \ - && cp -r /artifacts/sundials/* /usr + && gdebi -n libgfortran4.deb +# Install EnergyPlus RUN --mount=type=bind,from=energyplus-dependencies,source=/artifacts,target=/artifacts mkdir ${ENERGYPLUS_DIR} \ && tar -C $ENERGYPLUS_DIR/ --strip-components=1 -xzf energyplus.tar.gz \ && ln -s $ENERGYPLUS_DIR/energyplus /usr/local/bin/ \ && ln -s $ENERGYPLUS_DIR/ExpandObjects /usr/local/bin/ \ && ln -s $ENERGYPLUS_DIR/runenergyplus /usr/local/bin/ +# Install OpenStudio RUN --mount=type=bind,from=energyplus-dependencies,source=/artifacts,target=/artifacts apt update \ && gdebi -n openstudio.deb \ && cd /usr/local/openstudio* \ From 9c2e95a079f24aaa7a47466570045ebb61bdba0b Mon Sep 17 00:00:00 2001 From: TShapinsky Date: Thu, 25 Jul 2024 13:36:25 -0600 Subject: [PATCH 16/19] add gha cache --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3dba9a1..fb7e29c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -56,3 +56,5 @@ jobs: platforms: linux/amd64,linux/arm64 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.output.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max From 8193bc961db9856b982c6198feda97b3a9128b65 Mon Sep 17 00:00:00 2001 From: TShapinsky Date: Thu, 25 Jul 2024 14:09:26 -0600 Subject: [PATCH 17/19] move modelica install after e+ install as modelica build step takes longer --- Dockerfile | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index bfeb447..892a5f7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -228,14 +228,6 @@ RUN apt update \ libgfortran5 \ && rm -rf /var/lib/apt/lists/* -# Install Assimulo, PyFMI and Old Fortran Libraries -RUN --mount=type=bind,from=modelica-dependencies,source=/artifacts,target=/artifacts pip3 install Assimulo*.whl PyFMI*.whl \ - && apt update \ - && gdebi -n gcc-6.deb \ - && gdebi -n libgfortran3.deb \ - && gdebi -n gcc-7.deb \ - && gdebi -n libgfortran4.deb - # Install EnergyPlus RUN --mount=type=bind,from=energyplus-dependencies,source=/artifacts,target=/artifacts mkdir ${ENERGYPLUS_DIR} \ && tar -C $ENERGYPLUS_DIR/ --strip-components=1 -xzf energyplus.tar.gz \ @@ -251,6 +243,15 @@ RUN --mount=type=bind,from=energyplus-dependencies,source=/artifacts,target=/art && ln -s ${ENERGYPLUS_DIR} EnergyPlus \ && rm -rf /var/lib/apt/lists/* + +# Install Assimulo, PyFMI and Old Fortran Libraries +RUN --mount=type=bind,from=modelica-dependencies,source=/artifacts,target=/artifacts pip3 install Assimulo*.whl PyFMI*.whl \ + && apt update \ + && gdebi -n gcc-6.deb \ + && gdebi -n libgfortran3.deb \ + && gdebi -n gcc-7.deb \ + && gdebi -n libgfortran4.deb + WORKDIR $HOME # Only the xml lib component of bcvtb is actaully required for communication, so we just extract that to save space From 0b1df660268497ece04fce714275f93e6e74b0eb Mon Sep 17 00:00:00 2001 From: TShapinsky Date: Fri, 26 Jul 2024 14:06:24 -0600 Subject: [PATCH 18/19] reduce image size to 1.8GB --- Dockerfile | 79 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 55 insertions(+), 24 deletions(-) diff --git a/Dockerfile b/Dockerfile index 892a5f7..7ce8d87 100644 --- a/Dockerfile +++ b/Dockerfile @@ -221,36 +221,67 @@ ENV HOME=/alfalfa WORKDIR /artifacts -RUN apt update \ - && apt install -y \ - gdebi-core \ - openjdk-17-jdk \ - libgfortran5 \ - && rm -rf /var/lib/apt/lists/* - # Install EnergyPlus -RUN --mount=type=bind,from=energyplus-dependencies,source=/artifacts,target=/artifacts mkdir ${ENERGYPLUS_DIR} \ - && tar -C $ENERGYPLUS_DIR/ --strip-components=1 -xzf energyplus.tar.gz \ - && ln -s $ENERGYPLUS_DIR/energyplus /usr/local/bin/ \ - && ln -s $ENERGYPLUS_DIR/ExpandObjects /usr/local/bin/ \ - && ln -s $ENERGYPLUS_DIR/runenergyplus /usr/local/bin/ +RUN --mount=type=bind,from=energyplus-dependencies,source=/artifacts,target=/artifacts set -eux; \ + mkdir ${ENERGYPLUS_DIR}; \ + tar -C $ENERGYPLUS_DIR/ --strip-components=1 -xzf energyplus.tar.gz; \ + cd ${ENERGYPLUS_DIR}; \ + rm -rf \ + ExampleFiles \ + DataSets \ + Documentation \ + MacroDataSets \ + python_standard_lib \ + WeatherData \ + libpython3.8.so.1.0 \ + ; \ + ln -s $ENERGYPLUS_DIR/energyplus /usr/local/bin/; \ + ln -s $ENERGYPLUS_DIR/ExpandObjects /usr/local/bin/; \ + ln -s $ENERGYPLUS_DIR/runenergyplus /usr/local/bin/; \ + ln -s /usr/local/lib/python3.8 ${ENERGYPLUS_DIR}/python_standard_lib; \ + ln -s /usr/local/lib/libpython3.8.so.1.0 ${ENERGYPLUS_DIR}/libpython3.8.so.1.0 # Install OpenStudio -RUN --mount=type=bind,from=energyplus-dependencies,source=/artifacts,target=/artifacts apt update \ - && gdebi -n openstudio.deb \ - && cd /usr/local/openstudio* \ - && rm -rf EnergyPlus \ - && ln -s ${ENERGYPLUS_DIR} EnergyPlus \ - && rm -rf /var/lib/apt/lists/* +RUN --mount=type=bind,from=energyplus-dependencies,source=/artifacts,target=/artifacts set -eux; \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + gdebi-core \ + openjdk-17-jre-headless \ + ; \ + gdebi -o "APT::Install-Recommends=1" -n openstudio.deb; \ + cd /usr/local/openstudio*; \ + rm -rf \ + EnergyPlus \ + Examples \ + *Release_Notes*.pdf \ + ; \ + ln -s ${ENERGYPLUS_DIR} EnergyPlus; \ + apt-get purge -y \ + gdebi-core \ + ; \ + apt-get autoremove -y; \ + rm -rf /var/lib/apt/lists/* # Install Assimulo, PyFMI and Old Fortran Libraries -RUN --mount=type=bind,from=modelica-dependencies,source=/artifacts,target=/artifacts pip3 install Assimulo*.whl PyFMI*.whl \ - && apt update \ - && gdebi -n gcc-6.deb \ - && gdebi -n libgfortran3.deb \ - && gdebi -n gcc-7.deb \ - && gdebi -n libgfortran4.deb +RUN --mount=type=bind,from=modelica-dependencies,source=/artifacts,target=/artifacts set -eux; \ + python3.10 -m pip install 'numpy>=1.19.5' 'scipy>=1.10.1' 'matplotlib>3'; \ + python3.10 -m pip install --no-deps Assimulo*.whl PyFMI*.whl; \ + pip3 cache purge; \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + gdebi-core \ + libgfortran5 \ + ; \ + gdebi -n gcc-6.deb; \ + gdebi -n libgfortran3.deb; \ + gdebi -n gcc-7.deb; \ + gdebi -n libgfortran4.deb; \ + apt-get purge -y \ + gdebi-core \ + ; \ + apt-get autoremove -y; \ + rm -rf /var/lib/apt/lists/* WORKDIR $HOME From d41ed303134b07e540b9120113d395d8943d9b16 Mon Sep 17 00:00:00 2001 From: TShapinsky Date: Fri, 2 Aug 2024 09:47:23 -0600 Subject: [PATCH 19/19] change apt to apt-get for api stability and dont install recommends for OpenStudio --- Dockerfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7ce8d87..582651a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,8 +5,8 @@ ARG DEBIAN_VERSION=bookworm FROM python:${PYTHON_VERSION}-slim-bullseye AS modelica-dependencies ARG SUNDIALS_VERSION=v7.1.1 ARG ASSIMULO_VERSION=3.5.2 -RUN apt update \ - && apt install -y \ +RUN apt-get update \ + && apt-get install -y \ cmake \ liblapack-dev \ libsuitesparse-dev \ @@ -95,8 +95,8 @@ ARG OPENSTUDIO_VERSION_SHA=f953b6fcaf ARG ENERGYPLUS_VERSION=24.1.0 ARG ENERGYPLUS_VERSION_SHA=9d7789a3ac -RUN apt update \ - && apt install -y \ +RUN apt-get update \ + && apt-get install -y \ curl \ && rm -rf /var/lib/apt/lists/* @@ -248,7 +248,7 @@ RUN --mount=type=bind,from=energyplus-dependencies,source=/artifacts,target=/art gdebi-core \ openjdk-17-jre-headless \ ; \ - gdebi -o "APT::Install-Recommends=1" -n openstudio.deb; \ + gdebi -o "APT::Install-Recommends=0" -n openstudio.deb; \ cd /usr/local/openstudio*; \ rm -rf \ EnergyPlus \