github.com/someshkoli/terratest@v0.41.1/test-docker-images/README.md (about)

     1  # Gruntwork Terratest Docker Images
     2  
     3  As part of writing [Unit Tests with Terratest](/README.md#unit-tests), we recommend using [Packer](https://packer.io) to
     4  build a Docker image using the same script [provisioners](https://www.packer.io/docs/templates/provisioners.html) that
     5  Packer uses to configure the Amazon Machine Image you would normally build for production usage. Docker images build 10x
     6  faster than AMIs and launch 100x faster, reducing our cycle time while developing.
     7  
     8  But Packer's Docker image builds can still be slower than desired because, unlike a native `docker build` command against
     9  a `Dockerfile`, Packer does not use any [image caching](https://docs.docker.com/v17.09/engine/userguide/eng-image/dockerfile_best-practices/).
    10  As a result, each `packer build` creates the Docker image from scratch. Unfortunately, much of the Docker image build
    11  time is spent downloading libraries like `curl` and `sudo` which we assume are present on the AWS AMI associated with
    12  Ubuntu, Amazon Linux, CentOS, or any other Linux distro we're supporting.
    13  
    14  We solve this problem by creating canonical Gruntwork Terratest Docker Images which have most of the desired libraries
    15  pre-installed. We upload these images to a public Docker Hub repo such as https://hub.docker.com/r/gruntwork/ubuntu-test/ so
    16  that Packer templates that build Docker images can reference them directly as in the following example.
    17  
    18  ### Sample Packer Builder
    19  
    20  ```json
    21  {
    22    "builders": [{
    23      "name": "ubuntu-ami",
    24      "type": "amazon-ebs"
    25      // ... (other params omitted) ...
    26    },{
    27      "name": "ubuntu-docker",
    28      "type": "docker",
    29      "image": "gruntwork/ubuntu-test:18.04",
    30      "commit": "true"
    31    }],
    32    "provisioners": [
    33      // ...
    34    ],
    35    "post-processors": [{
    36      "type": "docker-tag",
    37      "repository": "gruntwork/example",
    38      "tag": "latest",
    39      "only": ["ubuntu-docker"]
    40    }]
    41  }
    42  ```