-
Hi, using AWS CDK (the aws equivalent to bicep) you can actually build a docker image from a local dockerfile when defining a resource. image: ecs.ContainerImage.fromAsset("../") Is that possible with bicep as well? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 7 replies
-
Closest you would get in would be using a Deployment script in your Bicep file (https://docs.microsoft.com/en-us/azure/azure-resource-manager/bicep/deployment-script-bicep) I would suggest that the building of your docket image would be better suited as a separate step during a CI/CD pipeline. |
Beta Was this translation helpful? Give feedback.
-
You could param utcValue string = utcNow()
resource acrDeploy 'Microsoft.Resources/deploymentScripts@2020-10-01' = {
name: 'acrDeploy'
location: resourceGroup().location
kind: 'AzureCLI'
properties: {
forceUpdateTag: utcValue
azCliVersion: '2.28.0'
timeout: 'PT30M'
scriptContent: 'az acr build --image sample/hello-world:v1 --registry myContainerRegistry008 --file Dockerfile .'
cleanupPreference: 'OnSuccess'
retentionInterval: 'P1D'
}
}
I am not 100% if that command would wait for your docker image to build before it deployed though. Check out the DeploymentScriptsAPI for more properties you may need as well. The previous article I listed has some samples for AZ CLI and powershell too. |
Beta Was this translation helpful? Give feedback.
-
Thanks @kevball2 With bicep? |
Beta Was this translation helpful? Give feedback.
-
This is an idea that I spent a while playing with for Bicep about 9 months ago - I even got to the point of building a prototype for it. The concept was that there's a special type of annotation that's processed by the client. The transformation turns the annotation into a variable during build/compile, and that variable is scoped to the resource. @build('dotnet', '../myproject.csproj')
resource container 'some awesome resource type' = {
properties: {
image: build.output.image
}
} There are some problems with this that I hadn't really solved:
|
Beta Was this translation helpful? Give feedback.
You could
I am not 100% if that command would wait for your docker image to build before it deployed though. Check out the DeploymentScriptsAPI for more properties you may need as well. The previous article I listed has some sample…