diff --git a/buildbucket/Dockerfile b/buildbucket/Dockerfile index 45bf4520b3c4046a31174c73f4d17a756a0de71f..bcc061642a440a3d094d5eaed6cc54adc6152b40 100644 --- a/buildbucket/Dockerfile +++ b/buildbucket/Dockerfile @@ -1,5 +1,5 @@ # To build: -# docker build -t gitlab.ssec.wisc.edu:5555/cspp_geo/cspp-geo-gridded-glm/buildbucket . +# docker build -t gitlab.ssec.wisc.edu:5555/cspp_geo/cspp-geo-gridded-glm/buildbucket:r$(date '+%Y%m%d') . FROM centos:7 WORKDIR /work @@ -7,12 +7,14 @@ WORKDIR /work COPY buildbucket_environment.yaml . COPY package.sh . -# Download miniconda -RUN curl -o miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -# Install miniconda (copied from https://hub.docker.com/r/continuumio/miniconda3/dockerfile) -RUN /bin/bash miniconda.sh -b -p $HOME/miniconda && \ - ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \ - echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc && \ +# Install the `which` command for debugging +RUN yum -y install which git && yum clean all + +# Download and install miniconda +# Copied from https://hub.docker.com/r/continuumio/miniconda3/dockerfile) +RUN curl -o miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \ + /bin/bash miniconda.sh -b -p $HOME/miniconda && \ + ln -s $HOME/miniconda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \ + echo ". $HOME/miniconda/etc/profile.d/conda.sh" >> ~/.bashrc && \ echo "conda activate base" >> ~/.bashrc RUN /bin/bash -c "$HOME/miniconda/bin/conda env create -n build -f buildbucket_environment.yaml" - diff --git a/buildbucket/README.md b/buildbucket/README.md index 81c20bf47d4186a684760f2d755fec782a47e6c9..221cab9421ae8ac837474df9b08fb547945bda6d 100644 --- a/buildbucket/README.md +++ b/buildbucket/README.md @@ -5,4 +5,18 @@ environment for the Gridded GLM tool. ## Built Bucket Creation Instructions -TODO \ No newline at end of file +The below commands will build the buildbucket image, tagged with the current +date, and then push it to the container registry on gitlab. + +```bash +docker build -t gitlab.ssec.wisc.edu:5555/cspp_geo/cspp-geo-gridded-glm/buildbucket:r$(date '+%Y%m%d') . +docker push gitlab.ssec.wisc.edu:5555/cspp_geo/cspp-geo-gridded-glm/buildbucket:r$(date '+%Y%m%d') +``` + +After testing the image you can tag it as latest by doing: + +```bash +docker tag gitlab.ssec.wisc.edu:5555/cspp_geo/cspp-geo-gridded-glm/buildbucket:r$(date '+%Y%m%d') gitlab.ssec.wisc.edu:5555/cspp_geo/cspp-geo-gridded-glm/buildbucket:latest +docker push gitlab.ssec.wisc.edu:5555/cspp_geo/cspp-geo-gridded-glm/buildbucket:latest + +``` diff --git a/buildbucket/package.sh b/buildbucket/package.sh old mode 100644 new mode 100755 index 74104c14de8f2d0562af960e3dded116bf30c82f..0a7132a051d4df4d79846d079fca0f18cbc90632 --- a/buildbucket/package.sh +++ b/buildbucket/package.sh @@ -1,23 +1,25 @@ -#!/usr/bin/env bash +#!/bin/bash -le # purpose: Create package and place it in /dock # requires: /gridded_glm to be mounted with package contents (gridded_glm in repository) -set -ex +# note: The shebang at the top of this file is needed as-is. The '-l' will +# load the .bashrc which allows us to use conda. The '-e' triggers exit +# on error behavior. We cannot use '/usr/bin/env bash -le' since most +# linux versions only parse the first two arguments of a shebang. -USAGE="Usage: package.sh vX.Y.Z [lmatools_ref glmtools_ref]" if [ $# -eq 1 ]; then version=$1 lmatools_ref=minvaluegrids glmtools_ref=ugf-newgrid -else if [ $# -eq 3 ]; then +elif [ $# -eq 3 ]; then version=$1 lmatools_ref=minvaluegrids glmtools_ref=ugf-newgrid else - echo $USAGE + echo "Usage: package.sh vX.Y.Z [lmatools_ref glmtools_ref]" exit 1 fi -# conda activate build +conda activate build # Debug Info which python @@ -27,6 +29,10 @@ echo "Version specified: ${version}" echo "lmatools reference: ${lmatools_ref}" echo "glmtools reference: ${glmtools_ref}" +# Turn on command printing here because we don't need all of the `conda` +# internal bash commands to pollute our output +set -x + # Install glmtools and related packages # All dependencies should have been built with the buildbucket # Careful: Could result in missing dependencies but we want reproducibility @@ -35,7 +41,7 @@ pip install --no-deps git+https://github.com/deeplycloudy/stormdrain.git pip install --no-deps git+https://github.com/deeplycloudy/glmtools.git@${glmtools_ref} # Build a tarball version of the current conda environment -conda_tb=conda_lmatools-${lmatools}_glmtools-${glmtools_ref}.tar.gz +conda_tb=conda_lmatools-${lmatools_ref}_glmtools-${glmtools_ref}.tar.gz conda pack -n build -o ${conda_tb} # Build up our package directory