Giter VIP home page Giter VIP logo

openshift-diy-python-how-to's Introduction

How to: Flask and Gunicorn (Python 3.5.3) in OpenShift

A step by step guide. Check the commit history of the step-by-step branch!. In each step, the bold part will take you to the commit in the step-by-step branch (read the comments!). The 'Go to x' will show you the source of x.

  1. Create the pre_build script: This script will be executed before the build step. Time to install Python 3.5.3 (if it's not there already), create your virtualenv fodler (same) and clean up your temporary directory. Go to pre_build
  2. Create the build script: In this step, our requirements are installed in our virtual environment. We'll use Flask and Gunicorn (more on this later). Go to build
  3. Create a "Hello world!" Flask app: This Flask application will be served by Gunicorn later. It's simple... it's just a "Hello world!"... nothing too interesting. Go to demo.py
  4. Create requirements.txt: This requirements will be installed in the build step. I put here everything that my app needs to run in Python. So I'll put here "Flask". Go to requirements.txt
  5. **Create dev_requirements.txt**](https://github.com/aaossa/openshift-diy-python-how-to/commit/188438799034e2ea758f99b8cf9364b39a4e6ebe): In this file I put everything that my app needs to be executed from bash scripts (like Gunicorn and Virtualenv) and for testing (like Pytest). In this case I put "Gunicorn". [Go to dev_requirements.txt`
  6. Create the start script: The start script launches the application. Here I activate the virtual environment and use Gunicorn to serve in the background. Read the script, I liked it. Go to start
  7. Create the stop script: This script uses the pid file created by Gunicorn in the start script to kill the process properly. Go to stop

This template provides Python 3.5.3, a "Hello world!" Flask app and a Gunicorn configuration that serves the Flask app. Now that everything that needs to be said has already been said... Take this code and use it with just one command

rhc app-create <app_name> diy-0.1 --from-code https://github.com/aaossa/openshift-diy-python-how-to.git

NOTE: To install Python, activate the environment, etc., the pre_build script must be triggered. How to do that? Just push a commit. Install Python from source takes a lot of time (~10+ minutes). To set up Travis CI to deploy automatically to OpenShift read the wiki!

Why I did this? This steps can be applied to any language, server configuration, etc. in OpenShift. Just use the action_hooks scripts to set up everything. I liked it

openshift-diy-python-how-to's People

Contributors

aaossa avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.