GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - pgroves/ci-cd-tutorial-sample-app: A sample Python app that implements a REST API, with database migrations and CI/CD support.

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

27 Commits
27 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
app
app
 
 
migrations
migrations
 
 
tests
tests
 
 
.env.template
.env.template
 
 
.flaskenv
.flaskenv
 
 
.gitignore
.gitignore
 
 
.travis.yml
.travis.yml
 
 
Dockerfile
Dockerfile
 
 
Procfile
Procfile
 
 
README.md
README.md
 
 
app.json
app.json
 
 
bootstrap.py
bootstrap.py
 
 
requirements-server.txt
requirements-server.txt
 
 
requirements.txt
requirements.txt
 
 
runtime.txt
runtime.txt
 
 
seed.py
seed.py
 
 

Repository files navigation

Build Status codebeat badge Maintainability

CD/CI Tutorial Sample Application

Description

This sample Python REST API application was written for a tutorial on implementing Continuous Integration and Delivery pipelines.

It demonstrates how to:

  • Write a basic REST API using the Flask microframework
  • Basic database operations and migrations using the Flask wrappers around Alembic and SQLAlchemy
  • Write automated unit tests with unittest

Also:

  • How to use GitHub Actions

Related article: https://medium.com/rockedscience/docker-ci-cd-pipeline-with-github-actions-6d4cd1731030

Requirements

  • Python 3.8
  • Pip
  • virtualenv, or conda, or miniconda

The psycopg2 package does require libpq-dev and gcc. To install them (with apt), run:

$ sudo apt-get install libpq-dev gcc

Installation

With virtualenv:

$ python -m venv venv
$ source venv/bin/activate
$ pip install -r requirements.txt

With conda or miniconda:

$ conda env create -n ci-cd-tutorial-sample-app python=3.8
$ source activate ci-cd-tutorial-sample-app
$ pip install -r requirements.txt

Optional: set the DATABASE_URL environment variable to a valid SQLAlchemy connection string. Otherwise, a local SQLite database will be created.

Initalize and seed the database:

$ flask db upgrade
$ python seed.py

Running tests

Run:

$ python -m unittest discover

Running the application

Running locally

Run the application using the built-in Flask server:

$ flask run

Running on a production server

Run the application using gunicorn:

$ pip install -r requirements-server.txt
$ gunicorn app:app

To set the listening address and port, run:

$ gunicorn app:app -b 0.0.0.0:8000

Running on Docker

Run:

$ docker build -t ci-cd-tutorial-sample-app:latest .
$ docker run -d -p 8000:8000 ci-cd-tutorial-sample-app:latest

Deploying to Heroku

Run:

$ heroku create
$ git push heroku master
$ heroku run flask db upgrade
$ heroku run python seed.py
$ heroku open

or use the automated deploy feature:

Deploy

For more information about using Python on Heroku, see these Dev Center articles:

  • Python on Heroku

About

A sample Python app that implements a REST API, with database migrations and CI/CD support.

Resources

Readme
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.