github.com/hs0210/hashicorp-terraform@v0.11.12-beta1/scripts/docker-release/build.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  # This script builds two docker images for the version referred to by the
     4  # current git HEAD.
     5  #
     6  # After running this, run tag.sh if the images that are built should be
     7  # tagged as the "latest" release.
     8  
     9  set -eu
    10  
    11  BASE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
    12  cd "$BASE"
    13  
    14  if [ "$#" -eq 0 ]; then
    15      # We assume that this is always running while git HEAD is pointed at a release
    16      # tag or a branch that is pointed at the same commit as a release tag. If not,
    17      # this will fail since we can't build a release image for a commit that hasn't
    18      # actually been released.
    19      VERSION="$(git describe)"
    20  else
    21      # This mode is here only to support release.sh, which ensures that the given
    22      # version matches the current git tag. Running this script manually with
    23      # an argument can't guarantee correct behavior since the "full" image
    24      # will be built against the current work tree regardless of which version
    25      # is selected.
    26      VERSION="$1"
    27  fi
    28  
    29  echo "-- Building release docker images for version $VERSION --"
    30  echo ""
    31  VERSION_SLUG="${VERSION#v}"
    32  
    33  docker build --no-cache "--build-arg=TERRAFORM_VERSION=${VERSION_SLUG}" -t hashicorp/terraform:${VERSION_SLUG} -f "Dockerfile-release" .
    34  docker build --no-cache -t "hashicorp/terraform:${VERSION_SLUG}-full" ../../