Install Linux dependencies in Azure App Service permanently using Azure DevOps

Viewed 68

I created a CI/CD DevOps pipeline for deploying the Django app. After the deployment, manually I go to SSH in the azure app service to execute the below Linux dependencies

apt-get update && apt install -y libxrender1 libxext6
apt-get install -y libfontconfig1

After every deployment, this package is removed automatically. Is there any way to install these Linux dependencies permanently?

1 Answers

I suppose you are using Azure App Service Linux. Azure App Service Linux uses its own customized Docker image to host your application.

Unfortunately you cannot customize Azure Linux App Service Docker image, but you can use App Service Linux container with your own custom Docker image that includes your Linux dependencies.

https://github.com/Azure-Samples/docker-django-webapp-linux

Dockerfile example:

# For more information, please refer to https://aka.ms/vscode-docker-python
FROM python:3.8-slim

EXPOSE 8000
EXPOSE 27017

# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE=1

# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1

# Install pip requirements
COPY requirements.txt .
RUN python -m pip install -r requirements.txt \
&& apt-get update && apt install -y libxrender1 libxext6 \
&& apt-get install -y libfontconfig1

WORKDIR /app
COPY . /app

RUN chmod u+x /usr/local/bin/init.sh
EXPOSE 8000
ENTRYPOINT ["init.sh"]

init.sh example:

#!/bin/bash
set -e

python /app/manage.py runserver 0.0.0.0:8000

https://docs.microsoft.com/en-us/azure/developer/python/tutorial-containerize-deploy-python-web-app-azure-01

Related