This article describes how to build a Docker image of GoCD-agent used for JEDI project.

This Docker image is provisioned with the necessary tools (such as parallel compiler, git, cmake, shell interpreters etc.) and libraries (zlib, jasper, netcdf, esmf, hdf5, and ncep libraries etc.)

Step-by-step guide

The GoCD GitHub account includes the GoCD agent repository, we will use the docker-gocd-agent-ubuntu-16.04 as example to demonstration:

  1. Fork the docker-gocd-agent-ubuntu-16.04 to your personal GitHub repository, such as docker-gocd-agent-ubuntu-16.04@WeatherLab
  2. Edit the Dockerfile, add the necessary tools and libraries.

    Dockerfile
    # Copyright 2017 ThoughtWorks, Inc.
    #
    # Licensed under the Apache License, Version 2.0 (the "License");
    # you may not use this file except in compliance with the License.
    # You may obtain a copy of the License at
    #
    #     http://www.apache.org/licenses/LICENSE-2.0
    #
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.
    
    ###############################################################################################
    # This file is autogenerated by the repository at https://github.com/gocd/docker-gocd-agent.
    # Please file any issues or PRs at https://github.com/gocd/docker-gocd-agent
    ###############################################################################################
    
    FROM ubuntu:16.04
    MAINTAINER GoCD <go-cd-dev@googlegroups.com>
    
    LABEL gocd.version="17.7.0" \
      description="GoCD agent based on ubuntu version 16.04" \
      maintainer="GoCD <go-cd-dev@googlegroups.com>" \
      gocd.full.version="17.7.0-5147" \
      gocd.git.sha="53fdb1b15184f93966059a42429bf9ed0bfdee59"
    
    ADD "https://download.gocd.org/binaries/17.7.0-5147/generic/go-agent-17.7.0-5147.zip" /tmp/go-agent.zip
    ADD https://github.com/krallin/tini/releases/download/v0.14.0/tini-static-amd64 /usr/local/sbin/tini
    ADD https://github.com/tianon/gosu/releases/download/1.10/gosu-amd64 /usr/local/sbin/gosu
    
    # allow mounting ssh keys, dotfiles, and the go server config and data
    VOLUME /godata
    
    # force encoding
    ENV LANG=en_US.utf8
    
    RUN \
    # add mode and permissions for files we added above
      chmod 0755 /usr/local/sbin/tini && \
      chown root:root /usr/local/sbin/tini && \
      chmod 0755 /usr/local/sbin/gosu && \
      chown root:root /usr/local/sbin/gosu && \
    # add our user and group first to make sure their IDs get assigned consistently,
    # regardless of whatever dependencies get added
      groupadd -g 1000 go && \ 
      useradd -u 1000 -g go -d /home/go -m go && \
      echo deb 'http://ppa.launchpad.net/openjdk-r/ppa/ubuntu xenial main' > /etc/apt/sources.list.d/openjdk-ppa.list && \ 
      echo 'deb http://ppa.launchpad.net/george-edison55/cmake-3.x/ubuntu trusty main' | tee -a /etc/apt/sources.list.d/cmake.list && \
      apt-key adv --keyserver keyserver.ubuntu.com --recv-keys DA1A4A13543B466853BAF164EB9B1D8886F44E2A && \ 
      apt-get update && \ 
      apt-get install -y openjdk-8-jre-headless git subversion mercurial openssh-client bash unzip libcurl4-openssl-dev autoconf automake gcc g++ make gfortran libexpat1-dev wget vim file texinfo cmake csh ksh mlocate openssh-server net-tools && \ 
      apt-get autoclean && \
      updatedb && \
    # unzip the zip file into /go-agent, after stripping the first path prefix
      unzip /tmp/go-agent.zip -d / && \
      mv go-agent-17.7.0 /go-agent && \
      rm /tmp/go-agent.zip && \
      cd /usr/local/src/ && \
      wget --no-check-certificate https://www.open-mpi.org/software/ompi/v2.1/downloads/openmpi-2.1.0.tar.gz && \
      tar xf openmpi-2.1.0.tar.gz && \
      rm openmpi-2.1.0.tar.gz && \
      cd openmpi-2.1.0 && \
      opal_check_cma_happy=0 ./configure --enable-mpi-cxx  && \
      make -j `nproc` all && make install && \
      cd /usr/local/src && \
      rm -rf openmpi-2.1.0
    
    ADD docker-entrypoint.sh /
    
    ENTRYPOINT ["/docker-entrypoint.sh"]
  3. Create automatic build in Docker hub, and trigger the building for the first time. In the future, the building will be triggered automatically by the changes committed in docker-gocd-agent-ubuntu-16.04@WeatherLab

  4. Once the build is successful, the Docker images is ready for use with command "docker pull weatherlab/docker-gocd-agent-ubuntu-16.04"