question

JooSacramento-2052 avatar image
0 Votes"
JooSacramento-2052 asked JooSacramento-2052 commented

Installing dependencies on container image

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-webapps-content-deploymentazure-app-configuration
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Replying because there has been some progress.

For context - I had already been able to install the desired packages on the container via SSH. However, those package updates were not reflected on the web app. For it to be reflected, I had to add the following Application Setting: "LD_LIBRARY_PATH", value="/usr/bin" (this is the directory where installed packages are stored).

The next part is making sure the package is installed everytime the app service is restarted. For this, I read that we can include a startup.sh script which Azure App Service checks for. We can even confirm it in the logs, before running the Startup Command indicated in the portal, it checks for a Startup file.

However, after placing my startup.sh script in the home/site/wwwroot folder, it doesn't seem to be recognised on app start.

Are STARTUP_FILE and STARTUP_COMMAND mutually exclusive?

0 Votes 0 ·

1 Answer

ryanchill avatar image
0 Votes"
ryanchill answered JooSacramento-2052 commented

Hopefully, I can clear up some confusion @JooSacramento-2052 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.


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi!

First of all, thanks for your reply.
The solution was just like you mentioned - except, since I wasn't able to properly configure the STARTUP_FILE, I just set the startup command to run the startup.sh script I FTP'd, like so:
./home/site/wwwroot/startup.sh

(inside the .sh were the dependencies I need to install as well as the 'java-jar' command to run the app)


1 Vote 1 ·