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

feature: Allow specifying Docker build target #2578

Closed
mikkelam opened this issue Feb 2, 2021 · 2 comments
Closed

feature: Allow specifying Docker build target #2578

mikkelam opened this issue Feb 2, 2021 · 2 comments
Labels
contributors/good-first-issue Good first issue for a contributor contributors/welcome Contributors are welcome to work on this priority/3-long-term type/feature Feature request

Comments

@mikkelam
Copy link

mikkelam commented Feb 2, 2021

Description:

I'm trying to use the DockerBuildArgs option to use a specific target in my Dockerfile like so :

...
    Metadata:
      Dockerfile: Dockerfile
      DockerContext: .
      DockerBuildArgs:
        target: prod
...

However it does not work. I'm getting multiple warnings from docker that build args were not consumed

Steps to reproduce:

Dockerfile like so

FROM public.ecr.aws/lambda/python:3.8 as prod

COPY app.py requirements.txt ./

RUN python3.8 -m pip install -r requirements.txt -t .

# Command can be overwritten by providing a different command in the template directly.
CMD ["app.lambda_handler"]

FROM prod as dev
CMD []

along with sam build

Observed result:

`[Warning] One or more build-args [target] were not consumed`

Expected result:

I would be able to use a specific target with sam

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: macos Big Sur
  2. sam --version: SAM CLI, version 1.15.0
@mgrandis
Copy link
Contributor

mgrandis commented Feb 2, 2021

It seems the DockerBuildArgs param is used to pass parameters to the DockerFile at build time.
That's why you get the warning for unused/not consumed parameter.
We are not supporting specifying a target for now but we'll review adding this feature.
This would basically mean allowing a DockerBuildTarget element under Metadata.

Docker python client reference: https://docker-py.readthedocs.io/en/stable/images.html

@mgrandis mgrandis added stage/pm-review Waiting for review by our Product Manager, please don't work on this yet type/feature Feature request labels Feb 2, 2021
@mgrandis mgrandis changed the title DockerBuildArgs not working feature: Allow specifying Docker build target Feb 2, 2021
@mgrandis mgrandis added contributors/good-first-issue Good first issue for a contributor contributors/welcome Contributors are welcome to work on this priority/3-long-term and removed stage/pm-review Waiting for review by our Product Manager, please don't work on this yet labels Feb 8, 2021
@mgrandis mgrandis added stage/pr Has a PR ready for review stage/waiting-for-release Fix has been merged to develop and is waiting for a release and removed stage/pr Has a PR ready for review labels Feb 25, 2021
@mgrandis mgrandis removed the stage/waiting-for-release Fix has been merged to develop and is waiting for a release label Mar 4, 2021
@mgrandis
Copy link
Contributor

mgrandis commented Mar 4, 2021

Released in 1.20.0

@mgrandis mgrandis closed this as completed Mar 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributors/good-first-issue Good first issue for a contributor contributors/welcome Contributors are welcome to work on this priority/3-long-term type/feature Feature request
Projects
None yet
Development

No branches or pull requests

2 participants