Azure / azure-dev

A developer CLI that reduces the time it takes for you to get started on Azure. The Azure Developer CLI (azd) provides a set of developer-friendly commands that map to key stages in your workflow - code, build, deploy, monitor, repeat.
https://aka.ms/azd
MIT License
408 stars 198 forks source link

[Issue] Docker buildargs does not support interpolation #4062

Closed crgarcia12 closed 1 month ago

crgarcia12 commented 4 months ago

Describe the bug If you have a Static App (like React) and a backend api in ACA, it would be nice if we could take the output of the infra deployment (the url) and pass it as buildArgs in the dockerfile:

For example:

# main.biceps
...
output REACT_APP_BACKEND_URL string = backend.outputs.uri
# azure.yaml - Notice the environment variables!
...
    frontend:
        project: "src/frontend"
        host: containerapp
        language: ts
        dist: build
        docker:
            path: Dockerfile
            buildArgs:
                - REACT_APP_BACKEND_URL=${REACT_APP_BACKEND_URL}
# deploy infra and populate outputs as environment variables
azd provision --environment dev
# utilize environment variables to interpolate the azure.yaml
azd deploy 
jongio commented 3 months ago

@vhvb1989 This should work right?

vhvb1989 commented 3 months ago

@vhvb1989 This should work right?

No. build-args don't support references to env values. This is a feature request (which is not that hard). The only thing to consider is security, as you will want to use --secret instead of --build-arg when referencing a secret from the system environment.

vhvb1989 commented 3 months ago

@wbreza FYI