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

[Issue] azd init should inspect dockerfile ARGS #4606

Open
1 task
jongio opened this issue Dec 4, 2024 · 3 comments
Open
1 task

[Issue] azd init should inspect dockerfile ARGS #4606

jongio opened this issue Dec 4, 2024 · 3 comments

Comments

@jongio
Copy link
Member

jongio commented Dec 4, 2024

Output from azd version
1.11

Describe the bug

My Docker files require some arguments.

The Azure.Yaml Docker file buildArgs is nice once you get it, but isn't very intuitive on how to set up the build args.

It would be great if the AZD init process determined what Args are in the Docker file. And then automatically added them to the azure yaml file.

Final azure.yaml I created:
Image

My Dockerfile with the ARGS
Image

@v-xuto
Copy link
Member

v-xuto commented Dec 16, 2024

We are following up on this issue. cc @rajeshkamal5050

@Menghua1
Copy link
Member

@weikanglim My current approach is ​​to add a function that extracts the parameters following ARG in the Dockerfile under the service directory, and then write it as buildArgs in the azure.yaml file.

If there are no problems, please review this PR #4639.

@weikanglim
Copy link
Contributor

weikanglim commented Jan 8, 2025

After reading more about Docker build args, I feel that the UX we're delivering here may be unintuitive to a Docker user.

An observation here is that Docker build args are meant to be used as a passed-in CLI flag, in the docs: docker build --build-arg NODE_ENV=development

From this, I wonder if it's weird then for azd to treat this as an environment variable that is set inside azure.yaml.

Suggestion

Would it be more idiomatic to allow for azd package -- --build-arg NODE_ENV=development as a flag passthrough?

That way we avoid having this needing configuration upfront.

If assuming that we mean to change the semantics of build-arg from a CLI invocation argument, into a configuration argument, it may be more idiomatic to allow the user to express the packaging command to invoke:

package: docker build --build-arg <ALL MY arguments>

Creating a buildArg configuration feels like an abstraction that is less intuitive. We want users to write idiomatic Docker file and have azd be part of it, what we want to avoid is having the Docker user learn azd's docker configuration variant.

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

No branches or pull requests

4 participants