In this blog you will be able to learn the following
- Containerize your node app using Dockerfile
- Build and create your own image using docker
- Setup your Azure Services like resource group, Azure Container Registry, Azure Container Env and Azure Container Apps
- Setup your Azure Container Registry and Setup Access Keys
- Deploy your image to Azure Container Registry
- Create your Azure container app via Azure CLI
Create a folder and open it in VS code
Open terminal and initialize node project
Let’s create express API
Configure package.json to run the app
Lets run the app
Create dockerfile
Create docker ignore
Next step is installing docker desktop in our local computer.
Once installed, let's open it, and explore
These are the containers available in your computer. As you can see there are no containers yet.
These are the images available in your computer. As you can see there are no images yet.
These are the image builds available in your computer. As you can see there are no image builds yet.
Now let's build our new image using docker command :
docker build -t azdockernode .
Check the docker desktop > Builds : you will see it is now building your image
Once completed it will be available in Images list in your docker desktop
Let's install Azure CLI
Download the installer from the official website of microsoft
Login our azure account
az login
Create resource group
az group create --name myrg1 --location eastus
Create Azure Container Registry
az acr create --resource-group myrg1 --name myrg1acr1 --sku Basic --location eastus
You can now see your ACR in your resource group
Now, let's setup the access key so we can publish our local image later on.
it will generate username and password, later we will use this credentials to push our image to this azure container registry
Let's login our ACR in terminal
We need to tag our local image to Azure container registry
docker tag azdockernode myrg1acr1.azurecr.io/azdockernode
We need to tag our local image to Azure container registry
docker tag azdockernode myrg1acr1.azurecr.io/azdockernode
Now let's push our image to the Azure Container Registry
docker push myrg1acr1.azurecr.io/azdockernode
To verify the completion of push. You can go to azure portal > myrg1acr1 (your Azure container registry)> repository
Next step is to create Azure Container Apps Environment
az containerapp env create
--name mycontainerenv1
--resource-group myrg1
--location eastus
Finally, lets create the container app
az containerapp create
--name mycontainerapp1
--resource-group myrg1
--image myrg1acr1.azurecr.io/azdockernode
--environment mycontainerenv1
--cpu 1
--memory 2Gi
--target-port 3000
--ingress external
--registry-server myrg1acr1.azurecr.io
--registry-username myrg1acr1
--registry-password <<PASSWORD FROM Azure Container Registry Admin>>
once successful you will see some json like this
We can verify again in the Azure Portal if it's created
Finally, you made it!
Thank you for reading!
Top comments (0)