Specify docker image using {{ .Revision }} variable


Is there a way to specify an image using a variable? The workflow I am trying to create is:

  1. Build a Docker image for each microservice (6 in total).
  2. Fan out, 6 Docker images, execute tests.
  3. Fan in, label those images as :latest or :production on our AWS ECR repo.

So the config.yml I’d like to create is something like this, to build and test “service1”. Is this at all possible? I can’t seem to use {{.Revision}} or ${ CIRCLE_SHA1 } when specifying the image.

      - image: docker:17.05.0-ce-git
      - checkout
      - setup_remote_docker
      - run:
          name: Build docker image
          command: |
            apk -v --update add python py-pip > /dev/null 2>&1
            pip install --upgrade awscli==1.14.5 > /dev/null 2>&1
            $(aws ecr get-login --no-include-email --region eu-west-1)

            # Pull the last build for cache purposes
            docker pull 123456783723.dkr.ecr.eu-west-1.amazonaws.com/service1:latest

            # Build the new one, which needs testing
            docker build --cache-from=123456783723.dkr.ecr.eu-west-1.amazonaws.com/service1 -t service1 service1

            # Push docker image to AWS ECR
            docker tag service1 123456783723.dkr.ecr.eu-west-1.amazonaws.com/service1:testing-${CIRCLE_SHA1}
            docker push 123456783723.dkr.ecr.eu-west-1.amazonaws.com/service1:testing-${CIRCLE_SHA1}

      - image: 817002343723.dkr.ecr.eu-west-1.amazonaws.com/service1:testing-{{ .Revision }}
      - image: elasticsearch:2.4
      - run:
          name: Execute Test Suite inside Docker Container
          command: |
            cd /app
            npm test

  version: 2
      - build
      - test-service1:
            - build

The only way I can do this is a kind of docker-in-docker system where I use the CircleCI off-the-shelf docker container to pull down my docker container and run it with docker-compose.

What’s the preferred method here?


This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.