Deploy Python app to the best Heroku alternative

NodeChef is a Cloud PaaS that runs on Bare metal and the best alternative to Heroku if you want the best price to performance ratio. NodeChef also comes bundled with MongoDB, MySQL, PostgreSQL and redis databases. Unlike Heroku, there is no need to use third party addons for any of this. You can easily deploy your Python app written with any framework such as flask, waitress together with your database while saving cost and improving on performance.

NodeChef uses the Cloudfoundry python buildpack to build and package your python apps.

Visit the Python hosting page to review all the features provided by NodeChef

This article will provide a general guide on how to deploy your Python app by using the NodeChef CLI, connecting and using your repository from GitHub, Bitbucket or GitLab or zip your python project folder and then uploading it from the dashboard.

  • 1
    Setup a NodeChef application

    Log in and navigate to the Dashboard. Click on deployments and complete the form. You will be required to select the size of your container and the region where your cluster is to be hosted. You can also choose to create your python app with a MySQL, MongoDB or PostgreSQL database.

    Once the cluster is provisioned, a URL will be assigned to your project which will be displaced on the dashboard.

    Create your application on NodeChef
  • 2
    Prepare your python app for deployment

    Notes on Python projects.

    NodeChef automatically detects your project as Python if you do not explicitly specify if one of the below conditions is met.

    • Your project has a requirements.txt file in the root of the project folder.
    • Or your project has a file in the root of the project folder.

    Specify a Python version

    You can specify the version of python to use by including it in the runtime.txt file in the root folder of your project. See example below:


    Finding the versions of Python supported. Click here.

    NodeChef always uses the latest version of the Python buildpack.

    To request the latest Python version in a patch line, replace the patch version with x: 3.6.x To request the latest version in a minor line, replace the minor version: 3.x

    Start command.

    For python projects, specifying a start command is required. You can specify a start command in the root folder of your project by creating a file with name: Procfile.

    Example Procfile starting your app with gunicorn:

    web: gunicorn SERVER-NAME:APP-NAME

    Example Procfile starting running your web app on Waitress:

    waitress-serve --port=$PORT DJANGO-WEB-APP.wsgi:MY-APP

    Listening for connections

    NodeChef automatically sets the environment varabile PORT at runtime. You must listen for connections using the value of this variable. See below example:

    if __name__ == "__main__": port = int(os.getenv("PORT", 8080))'', port=port)
  • 3
    Deploying your python app.

    You can deploy your python app to NodeChef cloud hosting by uploading your project folder as a zip, using GIT or the NodeChef CLI.

    Deploying your Python app by uploading your project folder.

    You must first zip all the contents in your project folder or use a tar archive with gzip compression to bundle all the files in your project folder. You can then upload this bundle.

    The zip or tar.gz archive cannot exceed 256 megabytes in size. You can always find the form to upload your project from the dashboard by navigating to the task manager → App actions → Upload code.

    Deploy by Uploading your project folder
    You can set your environment variables from the dashboard before deploying your app. You do not have to keep them in a JSON file as seen in the above image. See how to do so by clicking here.

    Once you click the Deploy app button, you should be able to see the status of the deployment from the progress indicator which is displayed right below the Upload form.

    Deploying your Python app from your GitHub, GitLab or BitBucket repository.

    Firstly, if you did not sign up for a NodeChef account using a GIT repo provider, you must authorize NodeChef to access your GitLab, GitHub or BitBucket account. You only have to do this once per NodeChef account. Click “Connect to (repository)”, a shown below to start the authentication.

    NodeChef select Git integration from Task manager NodeChef Github,Bitbucket & GitLab authorization

    After you link your Account to a Git repo, you can selectively deploy from branches as well.

    NodeChef Git repository

    Deploying your Python app using the NodeChef CLI.

    Install the NodeChef CLI from npm as showm below:

    npm install -g nodechef-cli

    CD into your project folder and use the below command as seen below. You will have to login from the command line to deploy or use a deployment token if you generated one from the dashboard.

    // Log in using email and password instead of a deployment token. nc login prompts for your credentials nc login nc deploy -i my_first_python_app