Can I do a custom checkout in a aws-ecr orb operation?

I am using the aws-ecr/build-and-push-image - it’s my first time using orbs. It works well for my Docker build use-case.

Here is my job:

jobs:
  test_image_php_build:
    jobs:
      - aws-ecr/build-and-push-image:
          name: "test_docker_php"
          context: "subscriptions-stage"
          account-url: AWS_ECR_ACCOUNT_URL
          extra-build-args: "--build-arg AWS_ECR_ACCOUNT_URL"
          repo: "qa"
          path: "tests-php/docker"
          tag: "php"
          executor: ubuntu20
          filters:
            branches:
              only:
                - evaluate-symfony-testing

executors:
  ubuntu20:
    machine:
      image: ubuntu-2004:202101-01

However my repo is huge, and I don’t need the whole of it - it takes around 100 seconds to clone. I only need one folder with the Dockerfile in it. Is there a way to customise the docker clone command while still making use of the orb? I dare say there is a way to do this by dropping the orb and doing the build manually, but I’d rather not do that.

1 Like

Hi @halfer! Thanks for your patience. Maybe @KyleTryon or @gmemstr can help?

1 Like

Hey @halfer :wave:

Just to make sure are we actually talking about git clone command? If so, funnily enough, this is not usually the case but this orb has a parameter for checkout as a boolean set to true by default.
https://circleci.com/developer/orbs/orb/circleci/aws-ecr#commands-build-and-push-image

Then we can inject our own steps to run prior to the other steps in the job
https://circleci.com/docs/2.0/reusing-config/#defining-pre-and-post-steps

You could do something like this:

jobs:
      - aws-ecr/build-and-push-image:
          name: "test_docker_php"
          checkout: false
          pre-steps:
            - run:
                name: Custom Clone
                command: git clone
          context: "subscriptions-stage"
          account-url: AWS_ECR_ACCOUNT_URL
          extra-build-args: "--build-arg AWS_ECR_ACCOUNT_URL"
          repo: "qa"
          path: "tests-php/docker"
          tag: "php"
          executor: ubuntu20
          filters:
            branches:
              only:
                - evaluate-symfony-testing
1 Like