Unable to start a Node.js Container image on Azure Spot Container Instance

87 Views Asked by At

I made a container image here, which I am using to deploy Container Instance.

I set 8 environment variables & 3 secured environment variables which are required in my Node.js App (which is basically a Discord bot code using Firebase)

This image, when I run locally, works as expected, but when deployed on Azure Container Instance (spot container), there are no startup logs indicating that it has started.

My config for this container:

CPU - 1 vCPU Memory - 1 GB Restart Policy - Never OS Type - Linux Location - West Europe Container type - Spot Container

Azure portal says:

One or more of the containers in 'perpetual-mechanical-array-bot' are in a Waiting' state and may not be running. Click here to view container statuses.

I even tried to connect via portal, but this happens:

Connection closed. Press Enter to reconnect.

Since my container image works locally, I wish to know what additional source code changes I might have to do so that it will start properly in Azure Container Instance.

I do not have quota for Standard ACI, but I was able to create Standard ACI. But I wanted Standard Spot ACI, so I sent a support request to increase limit. I haven't tried deploying on Standard ACI because my container image is not that Mission Critical.

1

There are 1 best solutions below

0
On BEST ANSWER

After a thorough debugging, I found out that there were 2 reasons my container was failing to start.

  1. Entry point was incorrect
  2. Supplying a multiline private key as (secure) environment variable throwed error ("Incorrect pem private key" or something similar)

Solution:

  1. Fixed the build instructions so that entry point is now correct.
  2. Used base64 encoding to encode multiline env variable into single line & modified the codebase accordingly to accept & decode the value.

I'm using Cloud Firestore, which has multiline private key. One good approach I found was to base64 encode private key.