Issue
I am working on a project that needs pdf files created based on a webpage, and went with wkhtmltopdf. The project consists of a python-based web app that runs in an Ubuntu 20 environment. An Azure pipeline is used to deploy the project to a Linux-based Azure app service that uses Python 3. The project runs on a localhost, but deploying it to an Azure app service has been causing issues.
After searching and trial and error, I came up with deploying my project to the Azure pipeline in Ubuntu, and then once the project has been uploaded to the Azure app service, I go into Azure, navigate to the SSH for the app service, and manually install wkhtmltopdf. For some reason, the app service runs on Debian 9, so I cannot create a script in the .yml file for the pipeline. The wkhtmltopdf package that is installed by the pipeline doesn't work with Debian.
I was wondering if there is a way to automatically have the debian app service install wkhtmltopdf. It can be done manually via the SSH in Azure, but with a lot of builds, it would be very time consuming.
Another option is changing the yml file to Debian 9 (which appears not to be supported here), or changing the app service OS to Ubuntu, which I could not find out how to do after hours of searching. It appears that it is automatically Debian 9 based on here
Here is a screenshot of the SSH on Azure
Solution
I was able to get wkhtmltopdf to install in the Debian environment by creating a script in the /home directory. I then set the Startup Command in Azure to point to this script.
I don't think Azure runs any auto scripts if you give it a startup command, thus I start the application myself at the end of the script.
Here is the script:
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.stretch_amd64.deb
apt-get install -y ./wkhtmltox_0.12.6-1.stretch_amd64.deb
rm wkhtmltox_0.12.6-1.stretch_amd64.deb
gunicorn --bind=0.0.0.0 --timeout 600 app:app
Note that I also had to add a pip install python-dotenv
above pip install requirements.txt
in the .yml file. Not sure why, as dotenv is in the requirements file, but I would get a dependency exception without this line in the yml.
Answered By - davidsbro
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.