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] Support passing build-arg to docker builds #1270

Closed
aaronpowell opened this issue Dec 14, 2022 · 4 comments
Closed

[Issue] Support passing build-arg to docker builds #1270

aaronpowell opened this issue Dec 14, 2022 · 4 comments
Labels
feature good first issue Good for newcomers
Milestone

Comments

@aaronpowell
Copy link
Contributor

When deploying apps that are within a container, such as Container Apps, there can be scenarios where you need to provide build-time variables to the Dockerfile. An example of this I described in this issue comment, but there are other reasons you may need an environment variable to trigger different aspects of the container build.

Looking at the Docker build function here:

func (d *Docker) Build(
ctx context.Context,
cwd string,
dockerFilePath string,
platform string,
buildContext string,
) (string, error) {
if strings.TrimSpace(platform) == "" {
platform = "amd64"
}
res, err := d.executeCommand(ctx, cwd, "build", "-q", "-f", dockerFilePath, "--platform", platform, buildContext)
if err != nil {
return "", fmt.Errorf("building image: %s: %w", res.String(), err)
}
return strings.TrimSpace(res.Stdout), nil
}

There's no way to provide a build-arg flag to the docker build command. I suggest we expand the docker.properties part the azure.yaml schema (

"docker": {
"type": "object",
"description": "This is only applicable when `host` is `containerapp`",
"additionalProperties": false,
"properties": {
"path": {
"type": "string",
"title": "The path to the Dockerfile",
"description": "Path to the Dockerfile is relative to your service",
"default": "./Dockerfile"
},
"context": {
"type": "string",
"title": "The docker build context",
"description": "When specified overrides the default context",
"default": "."
},
"platform": {
"type": "string",
"title": "The platform target",
"default": "amd64"
},
"tag": {
"type": "string",
"title": "The tag that will be applied to the built container image.",
"description": "If omitted, a unique tag will be generated based on the format: {appName}/{serviceName}-{environmentName}:azdev-deploy-{unix time (seconds)}. Use environment variable substitution to generate unique tags for a given release. For example, myapp/myimage:${DOCKER_IMAGE_TAG}."
}
}
}
},
) so that we can provide build-args as desired.

@ghost ghost added the needs-triage For new issues label Dec 14, 2022
@jongio
Copy link
Member

jongio commented Dec 14, 2022

Great idea! Thanks for the request.

aaronpowell added a commit to Azure-Samples/contoso-real-estate that referenced this issue Dec 19, 2022
manekinekko added a commit to Azure-Samples/contoso-real-estate that referenced this issue Jan 18, 2023
* feat: adding postgresql to devcontainer for the blog backend
* feat: adding strapi from a base template
Updated gitignore to allow the .env.example file. Using a dedicated gitignore in the cms folder for Strapi-specific stuff

* fix: fixing devcontainer
* feat: nextjs blog from sample
* feat: starting work on the azd integration
* feat: adding postgresql for the cms db
* fix: eslint issues
* chore: package-lock updates
* chore: cleanup for package-lock from bringing new projects in
* fix: env var in the postgres compose setup
* fix: generating the default db as blog not postgres
* fix: missing ignore for the strapi build cache
* fix: scripts for swa emulator to run blog
* chore: debugging launch for blog
* chore: removing blog from swa cli
* fix: removing the linked backends as nextjs hybrid doesn't use that,  API backends are disabled
* feat: moving blog from swa to container apps
* fix: moving away from SSG aspects due to Azure/azure-dev#1270
* fix: parameters for blog deployment
* fix: setting the module path for the azd things to deploy
* fix: removing package-lock from dockerfile as it doesn't exist due to workspaces
* fix: improving the outputs and naming of services to be more predictable
* fix: name of container apps service is lifted up to variable
This makes it easier to pass in as an argument using a params file

* fix: the params and individual service deployment of the CMS
* fix: individual service deployment of the blog frontend
* chore: remove website package
Website has been moved to a dedicated repo, this is cleanup of it

* chore: removing old SWA deployment action
* feat: adding azure storage strapi provider
* fix: refactoring the bicep files for deployment
- Changing `blog-cms` to just `cms` due to Azure/azure-dev#1290
- Adding more parameters to the cms deployment file that are the secrets
- moving serviceName tokenisation to the container-apps file rather than main, to make it consistent
- Fixing the service name for the portal

* fix: storage account path needs to be added to nextjs for next/image to work
* fix: variables not set properly for CMS setup
* fix: version of strapi azure storage plugin set
* fix: Missing flag in the env sample file
* fix: moving from domains to routePatterns for next/image
This means we don't need to know the storage account domain name, making the deployment more flexible

* chore: addressing package-lock after merge
* chore: adding readme guide for setting up blog
* fix: simplifying the password to avoid problems with yaml encoding
* chore: added section to readme for non-devcontainer usage
* fix: adding max retries to getting cosmos cert
* fix: forgot to update the database password on the service
* chore: fixing some package versions
* fix: incrementing vars in bash
* chore: improving the docs for devcontainer usage
Setting host requirements for the devcontainer

* chore: line endings are fun
* chore: reverting gitattributes to see if that fixes line endings
* fix: forcing ts/tsx to be lf line endings to avoid problems with linting on Windows
* chore(cms): update local dev guide

Co-authored-by: Wassim Chegham <github@wassim.dev>
anfibiacreativa pushed a commit to Azure-Samples/contoso-real-estate that referenced this issue Jan 22, 2023
* feat: adding postgresql to devcontainer for the blog backend
* feat: adding strapi from a base template
Updated gitignore to allow the .env.example file. Using a dedicated gitignore in the cms folder for Strapi-specific stuff

* fix: fixing devcontainer
* feat: nextjs blog from sample
* feat: starting work on the azd integration
* feat: adding postgresql for the cms db
* fix: eslint issues
* chore: package-lock updates
* chore: cleanup for package-lock from bringing new projects in
* fix: env var in the postgres compose setup
* fix: generating the default db as blog not postgres
* fix: missing ignore for the strapi build cache
* fix: scripts for swa emulator to run blog
* chore: debugging launch for blog
* chore: removing blog from swa cli
* fix: removing the linked backends as nextjs hybrid doesn't use that,  API backends are disabled
* feat: moving blog from swa to container apps
* fix: moving away from SSG aspects due to Azure/azure-dev#1270
* fix: parameters for blog deployment
* fix: setting the module path for the azd things to deploy
* fix: removing package-lock from dockerfile as it doesn't exist due to workspaces
* fix: improving the outputs and naming of services to be more predictable
* fix: name of container apps service is lifted up to variable
This makes it easier to pass in as an argument using a params file

* fix: the params and individual service deployment of the CMS
* fix: individual service deployment of the blog frontend
* chore: remove website package
Website has been moved to a dedicated repo, this is cleanup of it

* chore: removing old SWA deployment action
* feat: adding azure storage strapi provider
* fix: refactoring the bicep files for deployment
- Changing `blog-cms` to just `cms` due to Azure/azure-dev#1290
- Adding more parameters to the cms deployment file that are the secrets
- moving serviceName tokenisation to the container-apps file rather than main, to make it consistent
- Fixing the service name for the portal

* fix: storage account path needs to be added to nextjs for next/image to work
* fix: variables not set properly for CMS setup
* fix: version of strapi azure storage plugin set
* fix: Missing flag in the env sample file
* fix: moving from domains to routePatterns for next/image
This means we don't need to know the storage account domain name, making the deployment more flexible

* chore: addressing package-lock after merge
* chore: adding readme guide for setting up blog
* fix: simplifying the password to avoid problems with yaml encoding
* chore: added section to readme for non-devcontainer usage
* fix: adding max retries to getting cosmos cert
* fix: forgot to update the database password on the service
* chore: fixing some package versions
* fix: incrementing vars in bash
* chore: improving the docs for devcontainer usage
Setting host requirements for the devcontainer

* chore: line endings are fun
* chore: reverting gitattributes to see if that fixes line endings
* fix: forcing ts/tsx to be lf line endings to avoid problems with linting on Windows
* chore(cms): update local dev guide

Co-authored-by: Wassim Chegham <github@wassim.dev>
@rajeshkamal5050 rajeshkamal5050 added the good first issue Good for newcomers label Jan 23, 2023
@ghost ghost removed the needs-triage For new issues label Jan 23, 2023
@rajeshkamal5050 rajeshkamal5050 modified the milestones: Backlog, Gallium Jan 23, 2023
manekinekko added a commit to Azure-Samples/contoso-real-estate that referenced this issue Jan 24, 2023
* feat: adding postgresql to devcontainer for the blog backend
* feat: adding strapi from a base template
Updated gitignore to allow the .env.example file. Using a dedicated gitignore in the cms folder for Strapi-specific stuff

* fix: fixing devcontainer
* feat: nextjs blog from sample
* feat: starting work on the azd integration
* feat: adding postgresql for the cms db
* fix: eslint issues
* chore: package-lock updates
* chore: cleanup for package-lock from bringing new projects in
* fix: env var in the postgres compose setup
* fix: generating the default db as blog not postgres
* fix: missing ignore for the strapi build cache
* fix: scripts for swa emulator to run blog
* chore: debugging launch for blog
* chore: removing blog from swa cli
* fix: removing the linked backends as nextjs hybrid doesn't use that,  API backends are disabled
* feat: moving blog from swa to container apps
* fix: moving away from SSG aspects due to Azure/azure-dev#1270
* fix: parameters for blog deployment
* fix: setting the module path for the azd things to deploy
* fix: removing package-lock from dockerfile as it doesn't exist due to workspaces
* fix: improving the outputs and naming of services to be more predictable
* fix: name of container apps service is lifted up to variable
This makes it easier to pass in as an argument using a params file

* fix: the params and individual service deployment of the CMS
* fix: individual service deployment of the blog frontend
* chore: remove website package
Website has been moved to a dedicated repo, this is cleanup of it

* chore: removing old SWA deployment action
* feat: adding azure storage strapi provider
* fix: refactoring the bicep files for deployment
- Changing `blog-cms` to just `cms` due to Azure/azure-dev#1290
- Adding more parameters to the cms deployment file that are the secrets
- moving serviceName tokenisation to the container-apps file rather than main, to make it consistent
- Fixing the service name for the portal

* fix: storage account path needs to be added to nextjs for next/image to work
* fix: variables not set properly for CMS setup
* fix: version of strapi azure storage plugin set
* fix: Missing flag in the env sample file
* fix: moving from domains to routePatterns for next/image
This means we don't need to know the storage account domain name, making the deployment more flexible

* chore: addressing package-lock after merge
* chore: adding readme guide for setting up blog
* fix: simplifying the password to avoid problems with yaml encoding
* chore: added section to readme for non-devcontainer usage
* fix: adding max retries to getting cosmos cert
* fix: forgot to update the database password on the service
* chore: fixing some package versions
* fix: incrementing vars in bash
* chore: improving the docs for devcontainer usage
Setting host requirements for the devcontainer

* chore: line endings are fun
* chore: reverting gitattributes to see if that fixes line endings
* fix: forcing ts/tsx to be lf line endings to avoid problems with linting on Windows
* chore(cms): update local dev guide

Co-authored-by: Wassim Chegham <github@wassim.dev>
manekinekko added a commit to Azure-Samples/contoso-real-estate that referenced this issue Jan 25, 2023
* feat: adding postgresql to devcontainer for the blog backend
* feat: adding strapi from a base template
Updated gitignore to allow the .env.example file. Using a dedicated gitignore in the cms folder for Strapi-specific stuff

* fix: fixing devcontainer
* feat: nextjs blog from sample
* feat: starting work on the azd integration
* feat: adding postgresql for the cms db
* fix: eslint issues
* chore: package-lock updates
* chore: cleanup for package-lock from bringing new projects in
* fix: env var in the postgres compose setup
* fix: generating the default db as blog not postgres
* fix: missing ignore for the strapi build cache
* fix: scripts for swa emulator to run blog
* chore: debugging launch for blog
* chore: removing blog from swa cli
* fix: removing the linked backends as nextjs hybrid doesn't use that,  API backends are disabled
* feat: moving blog from swa to container apps
* fix: moving away from SSG aspects due to Azure/azure-dev#1270
* fix: parameters for blog deployment
* fix: setting the module path for the azd things to deploy
* fix: removing package-lock from dockerfile as it doesn't exist due to workspaces
* fix: improving the outputs and naming of services to be more predictable
* fix: name of container apps service is lifted up to variable
This makes it easier to pass in as an argument using a params file

* fix: the params and individual service deployment of the CMS
* fix: individual service deployment of the blog frontend
* chore: remove website package
Website has been moved to a dedicated repo, this is cleanup of it

* chore: removing old SWA deployment action
* feat: adding azure storage strapi provider
* fix: refactoring the bicep files for deployment
- Changing `blog-cms` to just `cms` due to Azure/azure-dev#1290
- Adding more parameters to the cms deployment file that are the secrets
- moving serviceName tokenisation to the container-apps file rather than main, to make it consistent
- Fixing the service name for the portal

* fix: storage account path needs to be added to nextjs for next/image to work
* fix: variables not set properly for CMS setup
* fix: version of strapi azure storage plugin set
* fix: Missing flag in the env sample file
* fix: moving from domains to routePatterns for next/image
This means we don't need to know the storage account domain name, making the deployment more flexible

* chore: addressing package-lock after merge
* chore: adding readme guide for setting up blog
* fix: simplifying the password to avoid problems with yaml encoding
* chore: added section to readme for non-devcontainer usage
* fix: adding max retries to getting cosmos cert
* fix: forgot to update the database password on the service
* chore: fixing some package versions
* fix: incrementing vars in bash
* chore: improving the docs for devcontainer usage
Setting host requirements for the devcontainer

* chore: line endings are fun
* chore: reverting gitattributes to see if that fixes line endings
* fix: forcing ts/tsx to be lf line endings to avoid problems with linting on Windows
* chore(cms): update local dev guide

Co-authored-by: Wassim Chegham <github@wassim.dev>
@savannahostrowski savannahostrowski modified the milestones: Gallium, Germanium Apr 5, 2023
aaronpowell added a commit to aaronpowell/azure-dev that referenced this issue May 19, 2023
Adding support for passing `buildArgs` to docker via the azure.yaml file
@weikanglim
Copy link
Contributor

weikanglim commented May 19, 2023

We should consider how this plays well with #1810

Also, do we expect envsubt to work with this parameter configuration? Or should the configuration be configurable via env variables?

@aaronpowell
Copy link
Contributor Author

We should consider how this plays well with #1810

Sure. I'll have a read of #1810 and add thoughts.

Also, do we expect envsubt to work with this parameter configuration? Or should the configuration be configurable via env variables?

I think we should support substitution of environment variables, both from a system level and from the azd output. I described a particular scenario in #121 (comment) in which I wanted to take the output from one service and use it in another via buildArgs, so that's my end goal here.

@savannahostrowski
Copy link
Contributor

Is this now complete via #2266 ?

moon920830 added a commit to moon920830/contoso-real-estate that referenced this issue Jul 14, 2023
* feat: adding postgresql to devcontainer for the blog backend
* feat: adding strapi from a base template
Updated gitignore to allow the .env.example file. Using a dedicated gitignore in the cms folder for Strapi-specific stuff

* fix: fixing devcontainer
* feat: nextjs blog from sample
* feat: starting work on the azd integration
* feat: adding postgresql for the cms db
* fix: eslint issues
* chore: package-lock updates
* chore: cleanup for package-lock from bringing new projects in
* fix: env var in the postgres compose setup
* fix: generating the default db as blog not postgres
* fix: missing ignore for the strapi build cache
* fix: scripts for swa emulator to run blog
* chore: debugging launch for blog
* chore: removing blog from swa cli
* fix: removing the linked backends as nextjs hybrid doesn't use that,  API backends are disabled
* feat: moving blog from swa to container apps
* fix: moving away from SSG aspects due to Azure/azure-dev#1270
* fix: parameters for blog deployment
* fix: setting the module path for the azd things to deploy
* fix: removing package-lock from dockerfile as it doesn't exist due to workspaces
* fix: improving the outputs and naming of services to be more predictable
* fix: name of container apps service is lifted up to variable
This makes it easier to pass in as an argument using a params file

* fix: the params and individual service deployment of the CMS
* fix: individual service deployment of the blog frontend
* chore: remove website package
Website has been moved to a dedicated repo, this is cleanup of it

* chore: removing old SWA deployment action
* feat: adding azure storage strapi provider
* fix: refactoring the bicep files for deployment
- Changing `blog-cms` to just `cms` due to Azure/azure-dev#1290
- Adding more parameters to the cms deployment file that are the secrets
- moving serviceName tokenisation to the container-apps file rather than main, to make it consistent
- Fixing the service name for the portal

* fix: storage account path needs to be added to nextjs for next/image to work
* fix: variables not set properly for CMS setup
* fix: version of strapi azure storage plugin set
* fix: Missing flag in the env sample file
* fix: moving from domains to routePatterns for next/image
This means we don't need to know the storage account domain name, making the deployment more flexible

* chore: addressing package-lock after merge
* chore: adding readme guide for setting up blog
* fix: simplifying the password to avoid problems with yaml encoding
* chore: added section to readme for non-devcontainer usage
* fix: adding max retries to getting cosmos cert
* fix: forgot to update the database password on the service
* chore: fixing some package versions
* fix: incrementing vars in bash
* chore: improving the docs for devcontainer usage
Setting host requirements for the devcontainer

* chore: line endings are fun
* chore: reverting gitattributes to see if that fixes line endings
* fix: forcing ts/tsx to be lf line endings to avoid problems with linting on Windows
* chore(cms): update local dev guide

Co-authored-by: Wassim Chegham <github@wassim.dev>
moon920830 added a commit to moon920830/contoso-real-estate that referenced this issue Jul 14, 2023
* feat: adding postgresql to devcontainer for the blog backend
* feat: adding strapi from a base template
Updated gitignore to allow the .env.example file. Using a dedicated gitignore in the cms folder for Strapi-specific stuff

* fix: fixing devcontainer
* feat: nextjs blog from sample
* feat: starting work on the azd integration
* feat: adding postgresql for the cms db
* fix: eslint issues
* chore: package-lock updates
* chore: cleanup for package-lock from bringing new projects in
* fix: env var in the postgres compose setup
* fix: generating the default db as blog not postgres
* fix: missing ignore for the strapi build cache
* fix: scripts for swa emulator to run blog
* chore: debugging launch for blog
* chore: removing blog from swa cli
* fix: removing the linked backends as nextjs hybrid doesn't use that,  API backends are disabled
* feat: moving blog from swa to container apps
* fix: moving away from SSG aspects due to Azure/azure-dev#1270
* fix: parameters for blog deployment
* fix: setting the module path for the azd things to deploy
* fix: removing package-lock from dockerfile as it doesn't exist due to workspaces
* fix: improving the outputs and naming of services to be more predictable
* fix: name of container apps service is lifted up to variable
This makes it easier to pass in as an argument using a params file

* fix: the params and individual service deployment of the CMS
* fix: individual service deployment of the blog frontend
* chore: remove website package
Website has been moved to a dedicated repo, this is cleanup of it

* chore: removing old SWA deployment action
* feat: adding azure storage strapi provider
* fix: refactoring the bicep files for deployment
- Changing `blog-cms` to just `cms` due to Azure/azure-dev#1290
- Adding more parameters to the cms deployment file that are the secrets
- moving serviceName tokenisation to the container-apps file rather than main, to make it consistent
- Fixing the service name for the portal

* fix: storage account path needs to be added to nextjs for next/image to work
* fix: variables not set properly for CMS setup
* fix: version of strapi azure storage plugin set
* fix: Missing flag in the env sample file
* fix: moving from domains to routePatterns for next/image
This means we don't need to know the storage account domain name, making the deployment more flexible

* chore: addressing package-lock after merge
* chore: adding readme guide for setting up blog
* fix: simplifying the password to avoid problems with yaml encoding
* chore: added section to readme for non-devcontainer usage
* fix: adding max retries to getting cosmos cert
* fix: forgot to update the database password on the service
* chore: fixing some package versions
* fix: incrementing vars in bash
* chore: improving the docs for devcontainer usage
Setting host requirements for the devcontainer

* chore: line endings are fun
* chore: reverting gitattributes to see if that fixes line endings
* fix: forcing ts/tsx to be lf line endings to avoid problems with linting on Windows
* chore(cms): update local dev guide

Co-authored-by: Wassim Chegham <github@wassim.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

5 participants