Code Monkey home page Code Monkey logo

first-s2i-python-app's Introduction

first-s2i-python-app

This is my first try using the source-2-image tool to get a skeleton django up and running.

Steps to create

These steps were done on a mac Prerequisites:

  • Python 3.5 installed
  • Docker for Mac installed
  • s2i installed

Setup base directory and virtualenv

mkdir first-s2i-python-app
cd first-s2i-python-app
virtualenv ve

Install Django and Gunicorn and requirements

pip install Django Gunicorn
pip freeze > requirements.txt

Start the Django project and move some key files around

django-admin startproject helloworld .
mv helloworld/wsgi.py .

See Notes below as to why we move the wsgi.py file around

Create s2i images

s2i build . centos/python-35-centos7 first-s2i-python-app-image

Run newly created image

docker run -p 8080:8080 first-s2i-python-app-image

and then you should be able to see "It Worked!" if you load http://127.0.0.1:8080

Some Notes

I have learned that to invoke some of automatic wiring of s2i for django projects, the following files must be at the root of the git repo:

  • requirements.txt
  • manage.py
  • wsgi.py

Web Server

Since we put the wsgi.py file at the root of the repo and we have specified Gunicorn in the requirements.txt file, then when running the image, a default Gunicorn server is used.

Had we not put either of the two prequisties in place, then s2i would have used python manage.py runserver to host the web application

Helpful references

Image Build Shortcuts

To build image

s2i build . centos/python-35-centos7 first-s2i-python-app-image

To run the django app using runserver

docker run -p 8080:8080 first-s2i-python-app-image

and then you should be able to see "It Worked!" if you load http://127.0.0.1:8080

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.