Skip to content
Snippets Groups Projects
Verified Commit 17d92a57 authored by David Hoese's avatar David Hoese
Browse files

Fix buildbucket image creation to work better with conda

parent 19f74193
No related branches found
No related tags found
No related merge requests found
# To build: # 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 FROM centos:7
WORKDIR /work WORKDIR /work
...@@ -7,12 +7,14 @@ WORKDIR /work ...@@ -7,12 +7,14 @@ WORKDIR /work
COPY buildbucket_environment.yaml . COPY buildbucket_environment.yaml .
COPY package.sh . COPY package.sh .
# Download miniconda # Install the `which` command for debugging
RUN curl -o miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh RUN yum -y install which git && yum clean all
# Install miniconda (copied from https://hub.docker.com/r/continuumio/miniconda3/dockerfile)
RUN /bin/bash miniconda.sh -b -p $HOME/miniconda && \ # Download and install miniconda
ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \ # Copied from https://hub.docker.com/r/continuumio/miniconda3/dockerfile)
echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc && \ 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 echo "conda activate base" >> ~/.bashrc
RUN /bin/bash -c "$HOME/miniconda/bin/conda env create -n build -f buildbucket_environment.yaml" RUN /bin/bash -c "$HOME/miniconda/bin/conda env create -n build -f buildbucket_environment.yaml"
...@@ -5,4 +5,18 @@ environment for the Gridded GLM tool. ...@@ -5,4 +5,18 @@ environment for the Gridded GLM tool.
## Built Bucket Creation Instructions ## Built Bucket Creation Instructions
TODO The below commands will build the buildbucket image, tagged with the current
\ No newline at end of file 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
```
#!/usr/bin/env bash #!/bin/bash -le
# purpose: Create package and place it in /dock # purpose: Create package and place it in /dock
# requires: /gridded_glm to be mounted with package contents (gridded_glm in repository) # 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 if [ $# -eq 1 ]; then
version=$1 version=$1
lmatools_ref=minvaluegrids lmatools_ref=minvaluegrids
glmtools_ref=ugf-newgrid glmtools_ref=ugf-newgrid
else if [ $# -eq 3 ]; then elif [ $# -eq 3 ]; then
version=$1 version=$1
lmatools_ref=minvaluegrids lmatools_ref=minvaluegrids
glmtools_ref=ugf-newgrid glmtools_ref=ugf-newgrid
else else
echo $USAGE echo "Usage: package.sh vX.Y.Z [lmatools_ref glmtools_ref]"
exit 1 exit 1
fi fi
# conda activate build conda activate build
# Debug Info # Debug Info
which python which python
...@@ -27,6 +29,10 @@ echo "Version specified: ${version}" ...@@ -27,6 +29,10 @@ echo "Version specified: ${version}"
echo "lmatools reference: ${lmatools_ref}" echo "lmatools reference: ${lmatools_ref}"
echo "glmtools reference: ${glmtools_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 # Install glmtools and related packages
# All dependencies should have been built with the buildbucket # All dependencies should have been built with the buildbucket
# Careful: Could result in missing dependencies but we want reproducibility # 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 ...@@ -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} pip install --no-deps git+https://github.com/deeplycloudy/glmtools.git@${glmtools_ref}
# Build a tarball version of the current conda environment # 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} conda pack -n build -o ${conda_tb}
# Build up our package directory # Build up our package directory
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment