From 586198792585fee635bbb4df2c30ea694bac3405 Mon Sep 17 00:00:00 2001 From: Patrick Godwin <patrick.godwin@ligo.org> Date: Thu, 18 Mar 2021 05:32:18 -0700 Subject: [PATCH] move conda Dockerfile from gitlab-ci.yml to own file, switch to multi-stage build to slim container size --- .gitlab-ci.Dockerfile.conda | 91 +++++++++++++++++++++++++++++++++++++ .gitlab-ci.yml | 58 ++++++----------------- 2 files changed, 106 insertions(+), 43 deletions(-) create mode 100644 .gitlab-ci.Dockerfile.conda diff --git a/.gitlab-ci.Dockerfile.conda b/.gitlab-ci.Dockerfile.conda new file mode 100644 index 0000000000..5b64fc8605 --- /dev/null +++ b/.gitlab-ci.Dockerfile.conda @@ -0,0 +1,91 @@ +# This is a Dockerfile to build a conda GstLAL +# runtime container. + +ARG CI_REGISTRY_IMAGE +ARG CI_COMMIT_REF_NAME + +# Build stage +FROM $CI_REGISTRY_IMAGE/dependencies/conda:$CI_COMMIT_REF_NAME AS build + +# Labeling/packaging stuff: +LABEL name="GstLAL Runtime Package, conda" \ + maintainer="Patrick Godwin <patrick.godwin@ligo.org>" \ + date="2021-03-18" + +# Copy source to container +COPY gstlal /gstlal +COPY gstlal-ugly /gstlal-ugly +COPY gstlal-inspiral /gstlal-inspiral +COPY gstlal-burst /gstlal-burst + +# Switch to bash shell +SHELL ["/bin/bash", "-c"] + +# Install gstlal +RUN . /opt/conda/etc/profile.d/conda.sh && \ + conda activate base && \ + export PREFIX="/opt/conda" && \ + export CONDA_BUILD="1" && \ + conda activate base && \ + cd /gstlal && \ + ./00init.sh && \ + ./configure --prefix=/opt/conda --without-doxygen && \ + make -j$NUM_CORES && \ + make install -j$NUM_CORES +RUN rm -rf gstlal + +# Install gstlal-ugly +RUN . /opt/conda/etc/profile.d/conda.sh && \ + conda activate base && \ + export PREFIX="/opt/conda" && \ + export CONDA_BUILD="1" && \ + conda activate base && \ + cd /gstlal-ugly && \ + ./00init.sh && \ + ./configure --prefix=/opt/conda --without-doxygen --without-gds && \ + make -j$NUM_CORES && \ + make install -j$NUM_CORES +RUN rm -rf gstlal-ugly + +# Install gstlal-burst +RUN . /opt/conda/etc/profile.d/conda.sh && \ + conda activate base && \ + export PREFIX="/opt/conda" && \ + export CONDA_BUILD="1" && \ + conda activate base && \ + cd /gstlal-burst && \ + ./00init.sh && \ + ./configure --prefix=/opt/conda --without-doxygen && \ + make -j$NUM_CORES && \ + make install -j$NUM_CORES +RUN rm -rf gstlal-burst + +# Install gstlal-inspiral +RUN . /opt/conda/etc/profile.d/conda.sh && \ + conda activate base && \ + export PREFIX="/opt/conda" && \ + export CONDA_BUILD="1" && \ + conda activate base && \ + cd /gstlal-inspiral && \ + ./00init.sh && \ + ./configure --prefix=/opt/conda --without-doxygen --disable-massmodel && \ + make -j$NUM_CORES && \ + make install -j$NUM_CORES +RUN rm -rf gstlal-inspiral + +# Run stage +ARG CI_REGISTRY_IMAGE +ARG CI_COMMIT_REF_NAME + +FROM $CI_REGISTRY_IMAGE/dependencies/conda:$CI_COMMIT_REF_NAME AS run + +# Copy build artifacts +COPY --from=build /opt/conda /opt/conda + +# Export environment variables: +ENV PKG_CONFIG_PATH /opt/conda/lib/pkgconfig +ENV GST_PLUGIN_PATH /opt/conda/lib/gstreamer-1.0 +ENV GSTLAL_FIR_WHITEN 0 +ENV TMPDIR /tmp + +ENTRYPOINT bash diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7ecb6789bd..e88a6321ac 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -63,10 +63,15 @@ stages: COPY gstlal-inspiral/share/conda/dev-environment.yml . RUN conda config --set always_yes yes RUN conda config --add channels conda-forge - RUN conda update -n base conda - RUN conda env update -n base -f dev-environment.yml - RUN conda install vim wget curl + RUN conda update -n base conda && \ + conda clean -af + RUN conda env update -n base -f dev-environment.yml && \ + conda clean -af + RUN conda install vim wget curl && \ + conda clean -af RUN rm -f dev-environment.yml + ENV PKG_CONFIG_PATH /opt/conda/lib/pkgconfig + ENV GST_PLUGIN_PATH /opt/conda/lib/gstreamer-1.0 ENTRYPOINT bash EOF - docker build -t $IMAGE_TAG . @@ -335,46 +340,13 @@ docker:conda: script: - IMAGE_TAG=$CI_REGISTRY_IMAGE/conda:$CI_COMMIT_REF_NAME - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY - - | - cat <<EOF > Dockerfile - FROM $CI_REGISTRY_IMAGE/dependencies/conda:$CI_COMMIT_REF_NAME - COPY gstlal /gstlal - COPY gstlal-ugly /gstlal-ugly - COPY gstlal-inspiral /gstlal-inspiral - COPY gstlal-burst /gstlal-burst - RUN cd /gstlal && \ - ./00init.sh && \ - PREFIX=/opt/conda CONDA_BUILD="1" ./configure --prefix=/opt/conda --without-doxygen && \ - make -j$NUM_CORES && \ - make install -j$NUM_CORES && \ - cd .. && \ - rm -rf gstlal && \ - RUN cd /gstlal-ugly && \ - ./00init.sh && \ - PREFIX=/opt/conda CONDA_BUILD="1" ./configure --prefix=/opt/conda --without-doxygen --without-gds && \ - make -j$NUM_CORES && \ - make install -j$NUM_CORES && \ - cd .. && \ - rm -rf gstlal-ugly && \ - RUN cd /gstlal-inspiral && \ - ./00init.sh && \ - PREFIX=/opt/conda CONDA_BUILD="1" ./configure --prefix=/opt/conda --without-doxygen && \ - make -j$NUM_CORES && \ - make install -j$NUM_CORES && \ - cd .. && \ - rm -rf gstlal-inspiral && \ - RUN cd /gstlal-burst && \ - ./00init.sh && \ - PREFIX=/opt/conda CONDA_BUILD="1" ./configure --prefix=/opt/conda && \ - make -j$NUM_CORES && \ - make install -j$NUM_CORES && \ - cd .. && \ - rm -rf gstlal-burst && \ - ENV PKG_CONFIG_PATH /opt/conda/lib/pkgconfig - ENV GST_PLUGIN_PATH /opt/conda/lib/gstreamer-1.0 - ENTRYPOINT bash - EOF - - docker build -t $IMAGE_TAG . + - > + docker build --pull + --build-arg CI_REGISTRY_IMAGE=$CI_REGISTRY_IMAGE + --build-arg CI_COMMIT_REF_NAME=$CI_COMMIT_REF_NAME + -t $IMAGE_TAG + --file .gitlab-ci.Dockerfile.conda + . - docker push $IMAGE_TAG needs: - dependencies/conda -- GitLab