/ghost-in-shell

Stelligent ghost in shell project repository

Primary LanguageCSSMIT LicenseMIT

Python app inside a docker image

This repo shows how to work with a small Python flask application that displays and serves static web files.

Besides, it shows how to make above app work inside a docker image for enabling deployment to any platform.

Setup Development Environment

Choose a platform

  • Our platform of choice - MacOS

Install required tools

  • Prerequisites:
  1. python 3
  2. docker
  3. VC (optional)

Build a Virtual Environment

Verify the content of Requiriments file

            cat requirements.txt

Create a Virtual Environment

            python3 -m venv venv

Install Required Tools in Virtual Environment

            venv/bin/pip install -r requirements.txt

Run python app

Verify the content of flask app

            cat app.py

Verify that app works

            venv/bin/python app.py
  • Check created web endpoints.

Dockerise Created App

Verify and improve Dockerfile

  • Follow best practicies while writing a Dockerfile

Build a docker image

            docker build . -t my-python-server

Run a docker image

            docker run --rm --name flask-app -p 5000:5000 my-python-server