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

How does one specify build ARG to docker-build ? #14

Open
tjbaker opened this issue Dec 5, 2017 · 9 comments
Open

How does one specify build ARG to docker-build ? #14

tjbaker opened this issue Dec 5, 2017 · 9 comments

Comments

@tjbaker
Copy link

tjbaker commented Dec 5, 2017

Dockerspec Version

0.5.0

Ruby Version

2.3

Platform Details

macOS

$ docker --version
Docker version 17.09.0-ce, build afdb6d4

Scenario

How does one specify build ARGs that are required in the Dockerfile via the describe docker_build() method? I can't find any examples of passing ARG. Builds requiring passed in ARG values can not be tested as the arg won't have an appropriate value.

@tjbaker
Copy link
Author

tjbaker commented Dec 5, 2017

I essentially need to pass the docker build option is –build-arg to describe docker_build(). Ideas?

@tjbaker
Copy link
Author

tjbaker commented Dec 5, 2017

It looks like this project has no support for ARG.
https://github.com/zuazo/dockerspec/blob/master/lib/dockerspec/builder/matchers.rb#L34-L58

The parser code referenced in the comments does in-fact have ARG:
https://github.com/moby/moby/blob/master/builder/dockerfile/parser/parser.go#L188

@zuazo
Copy link
Owner

zuazo commented Dec 9, 2017

What is your use case? Can you provide a complete example? Maybe passing ENV variables could be enough for you.

AFAIK, adding ARG to the Dockerfile, will require that you pass --build-arg with those vars, so I think you could use ENV for that, couldn't you?

@tjbaker
Copy link
Author

tjbaker commented Dec 11, 2017

We have a generic Dockerfile that drives many images via docker-compose. ARG is used extensively to provide the values. When you have many services in the compose file and many args in the Dockerfile it is not feasible to use ENV and default everything since there is no common value.

ARG is a native feature to Docker and it should be supported via a testing framework such as this.

@tecnobrat
Copy link

We also need ARG support.

ENV vars are ARGS are very different. ENV vars are not used when building a docker image, only ARGS are.

@zuazo
Copy link
Owner

zuazo commented Feb 17, 2018

Thanks. I understand the difference.

Unfortunately recently I did not have a lot of time. My apologies for that. Anyway, if you do a PR, I will be happy to review it ASAP 😄 Maybe it will no be easy, IDK, but the code has a lot of comments to help you in the process. Any question you have, let me know on this issue.

@deploymentking
Copy link

@tjbaker Have you tried using default values? I was failing to use the ARG option with the same error but then I specified a default value and it worked a treat

ARG VERSION_ELK=6.2.2
ARG FLAVOUR_ELK=""
FROM docker.elastic.co/elasticsearch/elasticsearch${FLAVOUR_ELK}:${VERSION_ELK}

@hardyoyo
Copy link

hardyoyo commented Feb 1, 2019

Hi, it's been two years... any chance dockerspec will support build ARGs in addition to run-time ENVs?

@hardyoyo
Copy link

If you're OK with not running any build-related tests on the build for which you need to use --build-arg, you can always make a system call to the docker build command... these tests are after all just Ruby files. Here's an example of what we're doing: https://github.com/UCLALibrary/docker-cantaloupe/blob/84cc2dd70454f821746123feed899580af1b0655/spec/cantaloupe_spec.rb#L21-L29 This works for us because we test the build completely in a previous step. Ideally, yes, DockerSpec would provide support for --build-arg but until it does, a system call might get you by.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants