Deploying Docker Containers to Azure with Different Environment Variable Files
I have built a Docker image which I plan on deploying to Azure Container Instances.
The Docker image has a .env which stores all the keys and variables that it needs to function. I have two different production environment variable files (.env.prod1 and .env.prod2) and the goal is to deploy separate containers using each of these environment variable sets. These environment variable files are 50+ lines long, so I would prefer not to use the az container create --environment-variable
argument if it means I have to list down each variable.
What would be the best way to go about this?
Currently, it seems like I need to:
- Create an image with .env.prod1 copied in.
- Push this image (imageprod1:latest) to ACR and create an Azure Container Instance with the newly pushed image.
- Swap out .env.prod1 with .env.prod2, and create a new image.
- Deploy this new image (imageprod2:latest) to ACR and create an Azure container Instance with this image.
This seems inefficient and not as modular as I expect, and maybe there's a way to push one image and leverage Azure to specify the environment variables?
I am programming using VS Code and my code is in Python 3.11. I am comfortable with using the Azure CLI.
Thank you!