diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 33cca21..16f6193 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -75,6 +75,7 @@ golang-1.10-git-2.14 test: *test_custom golang-1.10-git-2.16 test: *test_custom golang-1.10-git-2.17 test: *test_custom node-8.9-chrome-63.0-yarn-1.2 test: *test_custom +ruby-2.3-ansible-2.5.1-terraform-0.11 test: *test_custom www-gitlab-com test: *test_build gitlab-qa test: *test_build @@ -114,6 +115,7 @@ golang-1.10-git-2.14: *build_and_deploy_custom golang-1.10-git-2.16: *build_and_deploy_custom golang-1.10-git-2.17: *build_and_deploy_custom node-8.9-chrome-63.0-yarn-1.2: *build_and_deploy_custom +ruby-2.3-ansible-2.5.1-terraform-0.11: *build_and_deploy_custom www-gitlab-com: *build_and_deploy gitlab-qa: *build_and_deploy diff --git a/Dockerfile.custom b/Dockerfile.custom index a7ab2de..e3331a9 100644 --- a/Dockerfile.custom +++ b/Dockerfile.custom @@ -43,6 +43,14 @@ RUN if [ -n "$INSTALL_GOLANG_VERSION" ] ; then /scripts/install-golang "${INSTAL ARG POSTGRES_VERSION RUN if [ -n "$POSTGRES_VERSION" ] ; then /scripts/install-postgresql; fi +# Ansible +ARG ANSIBLE_VERSION +RUN if [ -n "$ANSIBLE_VERSION" ] ; then /scripts/install-ansible $ANSIBLE_VERSION; fi + +# Terraform +ARG TERRAFORM_VERSION +ARG TERRAFORM_DOWNLOAD_SHA256 +RUN if [ -n "$TERRAFORM_VERSION" ] ; then /scripts/install-terraform $TERRAFORM_VERSION $TERRAFORM_DOWNLOAD_SHA256; fi RUN locale-gen en_US.UTF-8 ENV LANG en_US.UTF-8 diff --git a/README.md b/README.md index 0e129b9..80443d4 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Assuming the image you want to add is called `new-image`.... 1. Add a test task: `new-image test: *test_build` 1. Add a new build task: `new-image: *build_and_deploy` -1. Add a Dockerfile: `Dockerfile.new-image` +1. Add a Dockerfile: `Dockerfile.new-image` ## Use a custom image with versioned features @@ -29,7 +29,7 @@ To add a new image to the build, edit [`.gitlab-ci.yml`](https://gitlab.com/gitl With custom images, the name of the image is used to define the contents (as opposed to use a bespoke Dockerfile build). -For this reason, the name needs to be correctly defined. +For this reason, the name needs to be correctly defined. The name is defined as `[feature]-[version]` pairs, separated by `-`. @@ -42,7 +42,7 @@ Here are some example build names: The first pair represents the base image and version. So `ruby-2.1-...` will use the `ruby:2.1` base image, while `golang-1.8` will use the `golang:1.8` base image. -Each of the following parts represents another feature and version. Available +Each of the following parts represents another feature and version. Available options are: 1. `golang` @@ -52,11 +52,13 @@ options are: 5. `yarn` 6. `phantomjs` 7. `postgres` +8. `terraform` +9. `ansible` ### Adding a new build -As an example, if you want to add new image for Ruby 2.4 with `git` 2.14 and `golang` 1.9, -the name would be `ruby-2.4-golang-1.9-git-2.14`. +As an example, if you want to add new image for Ruby 2.4 with `git` 2.14 and `golang` 1.9, +the name would be `ruby-2.4-golang-1.9-git-2.14`. 1. Add a test task: `ruby-2.4-golang-1.9-git-2.14 test: *test_custom` 1. Add a new build task: `ruby-2.4-golang-1.9-git-2.14: *build_and_deploy_custom` diff --git a/scripts/custom-docker-build b/scripts/custom-docker-build index 3614469..4493eb4 100755 --- a/scripts/custom-docker-build +++ b/scripts/custom-docker-build @@ -101,6 +101,23 @@ function print_postgres_args() { printf -- "--build-arg POSTGRES_VERSION=%s " "$1" } +function print_ansible_args() { + printf -- "--build-arg ANSIBLE_VERSION=%s " "$1" +} + +function print_terraform_args() { + case "$1" in + 0.11) + TERRAFORM_VERSION=0.11.7 + TERRAFORM_DOWNLOAD_SHA256=6b8ce67647a59b2a3f70199c304abca0ddec0e49fd060944c26f666298e23418 + ;; + *) echo "Unknown terraform version $1"; exit 1; + esac + + printf -- "--build-arg TERRAFORM_VERSION=%s " "$TERRAFORM_VERSION" + printf -- "--build-arg TERRAFORM_DOWNLOAD_SHA256=%s " "$TERRAFORM_DOWNLOAD_SHA256" +} + function parse_arguments() { read base read base_version @@ -116,6 +133,8 @@ function parse_arguments() { node) print_node_args $version ;; yarn) print_yarn_args $version ;; postgresql) print_postgres_args $version ;; + ansible) print_ansible_args $version ;; + terraform) print_terraform_args $version ;; *) exit 1;; esac done diff --git a/scripts/install-ansible b/scripts/install-ansible new file mode 100755 index 0000000..c63265b --- /dev/null +++ b/scripts/install-ansible @@ -0,0 +1,12 @@ +#!/bin/bash + +set -xeou pipefail + +ANSIBLE_VERSION=$1 + +apt-get update +apt-get install -y python-pip python-dev +apt-get clean -yqq + +pip install --upgrade cffi +pip install "ansible==${ANSIBLE_VERSION}" diff --git a/scripts/install-terraform b/scripts/install-terraform new file mode 100755 index 0000000..84c1e20 --- /dev/null +++ b/scripts/install-terraform @@ -0,0 +1,13 @@ +#!/bin/bash + +set -xeou pipefail + +TERRAFORM_VERSION=${1} +TERRAFORM_DOWNLOAD_SHA256=${2} + +TERRAFORM_DOWNLOAD_URL="https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip" + +curl -fsSL "$TERRAFORM_DOWNLOAD_URL" -o terraform.zip +echo "${TERRAFORM_DOWNLOAD_SHA256} terraform.zip" | sha256sum -c - +unzip -d /usr/local/bin terraform.zip +rm terraform.zip