Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to specify a target image to build #36

Closed
rob4629 opened this issue May 29, 2019 · 7 comments
Closed

Unable to specify a target image to build #36

rob4629 opened this issue May 29, 2019 · 7 comments
Labels
question Further information is requested

Comments

@rob4629
Copy link

rob4629 commented May 29, 2019

Orb version

6.0.0

What happened

I'm trying to call the build-and-push-image job, but was wondering whether I can pass in a target image for the build step?

Expected behavior

Essentially I’m using a multi-stage build in my Dockerfile, where the last image contains all of the test code. I would like to push the previous image to ECR, but can’t see how to do this using the build-and-push-image job.

commands:
  build_and_push_image_to_ecr:
    description: "Build Docker image and push to ECR"
    steps:
      - aws-ecr/build-and-push-image:
          account-url: AWS_ECR_ACCOUNT_URL
          create-repo: true
          repo: $SERVICE_REPO
          tag: $CIRCLE_SHA1

Would it be possible to specify a target image?

@iynere
Copy link
Contributor

iynere commented May 29, 2019

wouldn't you just use the push-image command in that case ? @rob4629

@rob4629
Copy link
Author

rob4629 commented May 29, 2019

I'm planning to do that just now, it means adding in an additional docker build step (w/ target image specified) prior to push-image.

I was just wondering if the ability to specify a target build image existed, or if it was possible to add this functionality. (I'm not skilled enough to open a PR to add this functionality... and also don't know if others would find it useful)

@iynere
Copy link
Contributor

iynere commented May 29, 2019

well, this should help you w/ the docker build step @rob4629 http://github.com/circleci-public/docker-orb

i guess i'm not sure what you mean by 'target build' ? the idea here is that your 'target' is your ECR account url + your repo name + your tag, i believe

@iynere
Copy link
Contributor

iynere commented May 29, 2019

@iynere iynere added the question Further information is requested label May 29, 2019
@rob4629
Copy link
Author

rob4629 commented May 29, 2019

under the hood, all it's doing is this :
https://github.com/CircleCI-Public/aws-ecr-orb/blob/master/src/commands/build-image.yml#L41-L45

Right. All I was wondering was whether that command could be amended to

docker build \
          <<#parameters.extra-build-args>><<parameters.extra-build-args>><</parameters.extra-build-args>> \
          -f << parameters.dockerfile >> \
          -t $<< parameters.account-url >>/<< parameters.repo >>:<< parameters.tag >> \
          --target << parameters.target_image >> \
          << parameters.path >>

@iynere
Copy link
Contributor

iynere commented May 29, 2019

ahh, i see. you should already be able to do that by passing --target YOUR_TARGET to the extra-build-args parameter @rob4629

@iynere iynere closed this as completed May 29, 2019
@rob4629
Copy link
Author

rob4629 commented May 29, 2019

Great, thanks for confirming.

Update
That works, thank you for your swift resolution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants