I recently made some changes to the structure of my Flask app hosted on heroku and now heroku has decided to detect it as a Node.js app intead of a Python app. My application uses both python (Flask) for the backend api and javascript for the front end.
The changes I made included integrating npm and bower into my application to streamline the javascript development of the app.
The problem was introduced when I added a package.json to my root directory when I started using npm. It seems that the build detection script runs the nodejs detection first (here) which leads to this code: if [ -f $1/package.json ]; then
echo "Node.js" && exit 0 executing and Heroku thinks it's a nodejs app and exits before the python detection has a chance to run.
To solve this I had to manually tell Heroku that I wanted a python build using this command
heroku config:set BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-python.
The package.json file is causing Heroku to detect it as a node.js app. To prevent this, add the file name to a .slugignore file:
echo 'package.json' >> .slugignore
git add .slugignore
.slugignore is like .gitignore. It resides in the root directory of your repository and should contain a list of filenames and wildcard patterns. The matching files remain in your git repository, but are deleted from the slug after you push to Heroku. The deletion occurs before the buildpacks run, so the node.js buildpack won't find package.json and the app won't be misidentified as a node.js app.
Related
I made a website in node.js and I have used child process to run python scripts and use their results in my website. But when I host my application on heroku, heroku is unable to run the python scripts.
I have noticed that heroku was able to run python scripts which only had inbuilt python packages like sys, json but it was failing for scripts which were using external packages like requests, beautifulsoup.
Attempt-1
I made a requirements.txt file inside the project folder and pushed my code to heroku again. But it was still not working. I noticed that heroku uses the requirements.txt file only for python based web applications but not for node.js applications.
Attempt-2
I made a python virtual env inside the project folder and imported the required python packages into the venv. I then removed gitignore from the venv and pushed the whole venv folder to heroku. It still didn't work.
Please let me know if anyone came across a way to handle this.
You can use a Procfile to specify a command to install the python dependencies then start the server.
Procfile:
web: pip install -r requirements.txt && npm start
Place Procfile in your project's root directory and deploy to heroku.
Solution:
Have a requirements.txt file in your project folder.
After you create a heroku app using "heroku create", heroku will identify your app as python based and will not download any of the node dependencies.
Now, go to your heroku profile and go to your app's settings. There is an option named "Add Buildpack" in there. Click on that and add node.js as one of the buildpacks.
Go back to your project and push it to heroku. This time heroku will identify your app as both python and node.js based and will download all the required files.
I am pushing a Rails web app to Azure and while pushing I'm am getting a remote:
Error: ENOENT: no such file or directory,
stat '/home/site/repository/include/python2.7'
remote: An error has occurred during web site deployment.
remote: Kudu Sync failed
I tried adding the WEBSITE_RUN_FROM_PACKAGE as a config variable but that deploys from a zip which I'm not sure I want to do and the app wasn't working with that. I've read that I might need a symlink but not really sure thats the way to go.
Here is complete step by step guide to deploy rails app in Azure you can refer:
https://gist.github.com/JeremyC-za/edb758525d5d98870f009dc1bba54d15
You have to set an environment variable like so:
KUDU_SELECT_NODE_VERSION_CMD=true
It changes the behavior of selectNodeVersion function run by deploy.sh
Note:
Rails apps are created with a package.json file and Azure uses this file to determine what type of app you're trying to deploy. Flags the app as a node.js in default scenario web site, and generates a deployment script , because of this reason it gets failed.
Hope it helps.
I'm trying to connect my heroku app to git repository.And also I can't able to push an existing repository with heroku app.While I'm trying to push with
git push heroku master
I found
fatal: 'heroku' does not appear to be a git repository
fatal: Could not read from remote repository.
How can I solve this?
If you already have the heroku app and want to connect it you can use the cli to list your apps heroku apps
=== name#email.com Apps
app_name
app_name_2
Then connect it with can use heroku git:remote -a app_name as well
From this question: How to connect to the selected app with heroku CLI
It is worth noting that this does basically the same thing as creating the remote as #rdegges suggested.
You can check to make sure you are
In the correct (git) directory and have cloned it down
Have the heroku remote to push to
By running git remote -v, should look something like this:
heroku https://git.heroku.com/app_name.git (fetch)
heroku https://git.heroku.com/app_name.git (push)
origin git#ssh.route/app_name.git (fetch)
origin git#ssh.route/app_name.git (push)
Found a very well thought out and thorough answer to heroku in general here: https://stackoverflow.com/a/5129733/5491808
That error means that: in your current project you have not yet 'initialized' Heroku.
Are you creating a NEW Heroku app? If so, you can run the following command to fix things:
heroku create
If you're trying to work with an EXISTING Heroku app, you need to setup your 'heroku remote' by doing the following:
git remote add heroku https://git.heroku.com/your-app-name.git
In order to connect with Heroku from anywhere you need these 3 files-
File name Procfile ( generic file - no file extension)
File name runtime.txt
File name requirements.txt
For details github link
(please fork it & give me a star)
I have an app on heroku named as floating-river-39482 .And I'm trying to deploy the app by giving the command git push heroku master .
But I got an error from terminal like this
remote: ! No such app as sleepy-inlet-36834.
fatal: repository 'https://git.heroku.com/sleepy-inlet-36834.git/' not found
In this error message the name of the app is sleepy-inlet-36834 .But I'm trying to push the app floating-river-39482 .
I don't have an app named sleepy-inlet-36834.
How can I correct this error?
It looks like you've somehow got your Git repository referencing an old (or deleted) Heroku application.
What you can do most easily is open up your .git/config file in your project, and switch out the https://git.heroku.com/sleepy-inlet-36834.git/ URL with the correct one for your Heroku application: https://git.heroku.com/floating-river-39482.git.
Then give it another go =)
To explain further: Heroku works by using Git to setup a 'remote'. Remotes are just places you can push (or pull) code from. Git creates remotes by listing them in your project's .git/config file.
I am having issues deploying my Pyramid app on Heroku. It runs fine locally but as soon as I try to launch it I receive this error "pkg_resources.DistributionNotFound: mymedaproject". mymedaproject is the name of my project and is not a python library which is why I am confused. I followed the instructions from this recipe to get to this point:
http://pyramid-cookbook.readthedocs.org/en/latest/deployment/heroku.html
Any ideas?
May be you forgot to put your python project mymedaproject in development mode. What follows is the relevant part of the cookbook recipe.
Create a Procfile
$ echo "web: ./run" > Procfile
Create run with the following:
#!/bin/bash
python setup.py develop
python runapp.py
The first line puts your python project in development mode and enables Paste to load it using your INI file. Make sure Procfile, run, runapp.py and setup.py are in same directory.
References
Getting Started with Python on Heroku
Process Types and the Procfile
Optimization
running a script using a Procfile should work without making it executable
$ echo "web: sh ./run" > Procfile
Check your .gitignore file that it isn't blocking any egg or egg-info information.
If it is, Heroku won't be receiving the egg for your application.