Installing dependencies on container image

João Sacramento 26 Reputation points
2022-04-22T15:50:33.423+00:00

Hi!

I have an Azure App Service running on a Linux service plan.
We run a .jar app which we deploy via FTP.
Due to some updates to the .jar, we have some dependencies that we need to install. I've been looking on the documentation for how I can include commands when starting up the container, but I can't seem to find a direct way.

I have looked through the documentation, but am a bit confused. I don't know if you could help me sort these ideias, but if you would bear with me:
It's the App Service itself which runs the docker command to setup the container where the app will be run, correct?

Is there no way to control the docker command that's run? For example, where is the dockerfile used by Azure App Service stored?
I've seen some documentation suggesting adding a 'startup.sh' script which the App Service reads by default. Would this be a viable alternative? Write up the .sh script and add it via FTP? Can it be done via the 'Startup command' field on the Configurations tab?

Thank you in advance!

Azure App Configuration
Azure App Configuration
An Azure service that provides hosted, universal storage for Azure app configurations.
209 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,963 questions
{count} votes

Accepted answer
  1. Ryan Hill 26,226 Reputation points Microsoft Employee
    2022-04-25T22:01:49.2+00:00

    Hopefully, I can clear up some confusion @João Sacramento but if I haven't, please comment down below.

    It's the App Service itself which runs the docker command to setup the container where the app will be run, correct?

    Yes, that is correct.

    Is there no way to control the docker command that's run?

    You can use the Startup Command input entry on the General Settings under the App Service > Configuration blade. This command will be passed as the STARTUP_COMMAND environment variable. See Azure App Service on Linux FAQ / Built-in images for an appropriate startup command.

    For example, where is the dockerfile used by Azure App Service stored?

    It's pulled from mcr.microsoft.com/azure-app-service/{runtime}. These are blessed images the guarantee base images are cached and therefore pulled in a timely manner.

    I've seen some documentation suggesting adding a 'startup.sh' script which the App Service reads by default. Would this be a viable alternative? Write up the .sh script and add it via FTP? Can it be done via the 'Startup command' field on the Configurations tab?

    You can certainly FTP your startup.sh and set it as the startup command for your app service i.e. /home/site/deployments/tools/your-startup-script.sh

    Are STARTUP_FILE and STARTUP_COMMAND mutually exclusive?

    Not really. You can examine your log stream and notice the platform will echo both (snippet down below). If STARTUP_FILE is configured and found, the platform will adhere to that and run it, but if the startup file is not found, it will fall back to the STARTUP_COMMAND if it is set.

       2022-04-25T21:04:12.548539411Z Add private certificates to keystore if exists...  
       2022-04-25T21:04:12.548973208Z Configuring max heap = 1346 MB  
       2022-04-25T21:04:12.578821728Z STARTUP_FILE=  
       2022-04-25T21:04:12.586873280Z STARTUP_COMMAND=java -jar /home/site/wwwroot/app.jar --server.port=80  
       2022-04-25T21:04:12.586888680Z No STARTUP_FILE available.  
       2022-04-25T21:04:12.586893280Z Running STARTUP_COMMAND: java -jar /home/site/wwwroot/app.jar --server.port=80  
       2022-04-25T21:04:12.606642861Z Error: Unable to access jarfile /home/site/wwwroot/app.jar  
       2022-04-25T21:04:12.606682160Z Finished running startup file 'java -jar /home/site/wwwroot/app.jar --server.port=80'. Exit code: '1'.  
       2022-04-25T21:04:12.606687860Z Custom startup complete. Now, exiting with exit code '1'  
    

    Now on to the nitty gritty, installing dependencies but it seems like you're more than halfway there. The crossing T's and dotted i's will depend on which Java runtime your app is. As long as you have the XML module descriptor file and the necessary jar files, you just need to modify your startup script to install those dependencies via your runtime CLI.


0 additional answers

Sort by: Most helpful