i am trying to deploy a vercel based app using ci cd system, i add gitlabci yml file and using enviroment variable, while running i got the following error
it seems the error originated while trying to install the required dependencies but i cannot seem to think whats the problem
here is my requirements.txt
dj-database-url==1.0.0
Django==4.1.3
django-cors-headers==3.13.0
django-crispy-forms==1.14.0
django-environ==0.7.0
django-livereload-server==0.4
django-storages==1.13.1
django-widget-tweaks==1.4.12
djangorestframework==3.14.0
psycopg2-binary==2.9.1
sqlparse==0.4.3
i expect my app can be built smoothly
Related
I have a few questions that I am hoping someone can answer here. I realize I have knowledge gap and I am hoping someone here can fill it or at least point me towards the right direction.
I had built a Flask API that I could run inside a Docker Container on Ubuntu OS. To create a Swagger API Documentation, I added to my Flask application:
from flask_swagger_ui import get_swaggerui_blueprint
Rather than moving forward, I stopped the Docker and ran it again and as expected, It resulted in "502 Gateway error". Upon Checking Docker logs here is what I noticed:
ModuleNotFoundError: No module named 'flask_swagger_ui'
I understood this problem as I needed to add this dependency inside my docker. I added the following code to my
"requirements.txt" file: flask_swagger_ui==3.36.0.
However this did not change anything and I still received the same error. I tried adding the module directly into the Dockerfile I created through this code but that did not work either:
RUN pip install flask_swagger_ui
Doing one or both of these things results in 502 Gateway error. I have tried to add several other modules to my application Like Pandas and Sklearn but they result in the same error. I can NOT make any changes to my application without getting Bad Gateway.
To figure out what is wrong, I removed all the changes I had made and got it back to where the only dependency is Flask 2.0.1 in my "requiements.txt". After testing that the Docker is running fine, In a state of confusion, I removed "start.sh", "Dockerfile" and "requirements.txt" and put them in trash bin and restarted Docker.
To my bewilderment, The Docker was working fine! with all the files mentioned above in the trash bin! Since at this point now I was completely lost, I added all the dependencies back again to see if it works this time and got stuck with the same 502 Error and the Logs showed the same issue.
My question then is:
How do I add a dependency to my application?
How on Earth is my Docker container still running after 3 required files in trash bin? I stopped and restarted Docker again, As far as I know, It should not have worked.
Removing "Flask 2.0.1" from the requirements.txt file while it was in my directory and restarting my docker did not affect my Docker application at all and it was running fine. What is happening?
Here is my Dockerfile:
FROM tiangolo/uwsgi-nginx-flask:python3.8-alpine3.7
RUN apk --update add bash nano
RUN pip install pandas flask_swagger_ui
ENV STATIC_URL /static
ENV STATIC_PATH /home/faraz/python_docker/TestApp/app/static
COPY ./requirements.txt /home/faraz/python_docker/TestApp/requirements.txt
RUN pip install -r requirements.txt
and here is my requirements.txt:
Flask==2.0.1
flask_swagger_ui==3.36.0
pandas==1.2.4
Finally, my "start.sh":
#!/bin/bash
app="docker.test"
docker build -t ${app} .
docker run -d -p 56733:80 \
--name=${app} \
-v $PWD:/app ${app}
I had posted another question when I was building my API and the link below will take you to it:Method Not Allowed The method is not allowed for the requested URL. 405 Error
As per suggested by one of the comments: Here is the Github Repository:
https://github.com/frazali32/Docker-Flask-API
I found the answer to my issue. As I had suspected, It was nothing but Knowledge gap. The concept is explained brilliantly in the forum below:
Rebuild Docker container on file changes
Basically,Deleting or changing something locally does nothing to the container unless you are mounting it as a volume or you do not rebuild. In my case, I deleted the Docker Image created in my first attempt, Built another Image and restarted the Docker. It works now!
From within VSCode, using the Azure web service extension, I can deploy a Hello-World flask app successfully to my Azure web app (linux, python 3.6 stack).
When I try to deploy my real flask app (with dependencies listed in a requirements.txt) file, and I specify "pip install --upgrade -r requirements.txt" as the web app "startup command" in the Azure portal, browsing the web app page gives an "Application Error".
The log for my web app shows the startup code failing when trying to build "psutil" due to the error unable to execute 'gcc': No such file or directory.
When the above failed, I also tried using "wheels" as part of my deployment as described here (https://blogs.msdn.microsoft.com/azureossds/2015/06/29/install-native-python-modules-on-azure-web-apps-api-apps/), but that didn't seem to change anything (same 'missing gcc' error).
Is this the correct way to deploy a flask app with python library dependencies from VSCode? I would expect that the deployment process would automatically process the requirements.txt (without having to specify the startup command) and I would expect it to be able to install the python libraries without error.
Due to you were using Azure WebApp for Linux based on Docker Container, the MSDN blog Install Python Modules on Azure App Services for Azure WebApp for Windows is not useful for your issue.
So for your issue of missing gcc error, per my experience, the solution to fix it is to configure a custom Linux container which had been pre-installed the gcc tool-chains and then to deploy your app into it from VS Code.
As references, please try to follow the documents below.
Configure a custom Linux container for Azure App Service . To install the gcc toolchains in a custom docker image via change the Docker file like install openssh as the section Enable SSH said.
Deploy to Azure using Docker from VS Code with Azure App Service extension.
This is my first experience deploying a Flask web app to Azure.
I followed this tutorial.
The default demo app they have works fine for me.
Afterwards, I pushed my Flask app via git. The log shows deployment was successful. However, when I browse the hosted app via link provided in "Application Properties", I get a 500 error as follows:
The page cannot be displayed because an internal server error has
occurred.
Most likely causes: IIS received the request; however, an internal
error occurred during the processing of the request. The root cause of
this error depends on which module handles the request and what was
happening in the worker process when this error occurred. IIS was not
able to access the web.config file for the Web site or application.
This can occur if the NTFS permissions are set incorrectly. IIS was
not able to process configuration for the Web site or application. The
authenticated user does not have permission to use this DLL. The
request is mapped to a managed handler but the .NET Extensibility
Feature is not installed.
The only off-base thing I can see by browsing the wwwroot via KUDU is that none of the packages I have installed in my local virtual environment are installed on Azure despite the existence of the "requirements.txt" file in wwwroot.
My understanding is that Azure would pip install any non existent package that it finds in the requirements.txt upon GIT successful push. But it doesn't seem to be happening for me.
Am I doing something wrong and the missing packages is just a symptom or could it be the cause the issue?
Notes:
My Flask app works fine locally (linux) and on a 3rd party VPS
I redeployed several times starting from scratch to no avail (I use local GIT method)
I cloned the Azure Flask demo app locally, changed just the app folder and pushed back to Azure, yet no success.
Azure is set to Python 2.7 same as my virtual env locally
As suggested in the tutorial linked above, I deleted the "env" folder and redeployed to trick Azure to reinstall the virtual env. It did but with its own default packages not the one in my requirements.txt.
My requirements.txt has the following:
bcrypt==3.1.0 cffi==1.7.0 click==6.6 Flask==0.11.1 Flask-Bcrypt==0.7.1
Flask-Login==0.3.2 Flask-SQLAlchemy==2.1 Flask-WTF==0.12
itsdangerous==0.24 Jinja2==2.8 MarkupSafe==0.23 pycparser==2.14
PyMySQL==0.7.7 python-http-client==1.2.3 six==1.10.0 smtpapi==0.3.1
SQLAlchemy==1.0.14 Werkzeug==0.11.10 WTForms==2.1
As Azure Web Apps will run a deploy.cmd script as the deployment task to control which commands or tasks will be run during the deployment.
You can use the command of Azure-CLI azure site deploymentscript --python to get the python applications' deployment task script.
And you can find the following script in this deploy.cmd sciprt:
IF NOT EXIST "%DEPLOYMENT_TARGET%\requirements.txt" goto postPython
IF EXIST "%DEPLOYMENT_TARGET%\.skipPythonDeployment" goto postPython
echo Detected requirements.txt. You can skip Python specific steps with a .skipPythonDeployment file.
So the .skipPythonDeployment will skip all the following steps in deployment task, including creating virtual environment.
You can try to remove .skipPythonDeployment from your application, and try again.
Additionally, please refer to https://github.com/projectkudu/kudu/wiki/Custom-Deployment-Script for more info.
I need to run a python application on Heroku that uses Open Cv as in this question: Python web application with OpenCV in Heroku
Unfortunately, Heroku does not seem to be able to fetch this build pack. I always get the error:Fetching set buildpack BUILDPACK_URL=https://github.com/diogojc/heroku-buildpack-python-opencv-scipy.git#cedar14... failed
Any idea how I can attempt to fix this issue? It this build pack working for others?
I recently tried this build pack and while heroku was able to fetch it successfully, it did not unpack the opencv zip correctly for installation and I was unable to use it for my flask application.
Take a look at the Anaconda build pack here!
https://github.com/kennethreitz/conda-buildpack
This build pack allows you to specify a conda-requirements.txt file, which you can use to include opencv.
The steps I followed to deploy an opencv Heroku app were:
create a web app and link it to a heroku project
heroku buildpacks:add https://github.com/kennethreitz/conda-buildpack
add a file called "conda-requirements.txt" to the same directory as your web app and add "opencv" to the file.
deploy the app and check to make sure that heroku is giving you something like this in the output:
remote: # packages in environment at /app/.heroku/miniconda:
remote: #
remote: opencv 3.1.0 np112py27_1
if it doesn't work, check the heroku logs to make sure the problem is with the build pack. If you're only trying to get opencv to work, only use this anaconda build pack, don't add any other build packs. Hope that helps!
In my flask app I often use abiword in a subprocess call. Now I am trying to migrate that application to heroku however I am running into some trouble when trying to get abiword installed
Following the approach on this website
http://theprogrammingbutler.com/blog/archives/2011/07/28/running-pdftotext-on-heroku/
does not seem to work because when I use ./configure I get the error that several packages were not found and I cant use apt-get on heroku to install them.
What can I do to create a full buildpack to add to my heroku buildpacks?