Skip to content

Commit

Permalink
♻️ Refactor build setup (#173)
Browse files Browse the repository at this point in the history
* ➕ Move from Pipenv to Poetry

* 👷 Add GitHub Actions for CI

* 👷 Disable Travis

* 🔥 Centralize and simplify building setup

* 🔧 Update scripts and testing setup

* ✅ Update tests with new setup

* 🙈 Add poetry.lock to .gitignore

* 🔧 Add mypy config

* 📝 Update README

* 🐛 Fix Python 2.7 base image
  • Loading branch information
tiangolo authored May 7, 2020
1 parent 542c572 commit e5c22f7
Show file tree
Hide file tree
Showing 118 changed files with 300 additions and 1,362 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Deploy

on:
push:
branches:
- master

jobs:
build:
strategy:
matrix:
image:
- name: latest
python_version: "3.7"
- name: python3.7
python_version: "3.7"
- name: python3.6
python_version: "3.6"
- name: python3.5
python_version: "3.5"
- name: python2.7
python_version: "2.7"
- name: python3.6-alpine3.8
python_version: "3.6"
- name: python3.6-alpine3.7
python_version: "3.6"
- name: python2.7-alpine3.8
python_version: "2.7"
- name: python2.7-alpine3.7
python_version: "2.7"
fail-fast: true
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: "3.7"
- name: Install Dependencies
run: python3.7 -m pip install docker pytest
- name: Deploy Image
run: bash scripts/build-push.sh
env:
NAME: ${{ matrix.image.name }}
DOCKERFILE: ${{ matrix.image.dockerfile }}
PYTHON_VERSION: ${{ matrix.image.python_version }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: Issue Manager

on:
schedule:
- cron: "0 0 * * *"
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Test

on:
push:
pull_request:
types: [opened, synchronize]

jobs:
build:
strategy:
matrix:
image:
- name: latest
python_version: "3.7"
- name: python3.7
python_version: "3.7"
- name: python3.6
python_version: "3.6"
- name: python3.5
python_version: "3.5"
- name: python2.7
python_version: "2.7"
- name: python3.6-alpine3.8
python_version: "3.6"
- name: python3.6-alpine3.7
python_version: "3.6"
- name: python2.7-alpine3.8
python_version: "2.7"
- name: python2.7-alpine3.7
python_version: "2.7"
fail-fast: true
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: "3.7"
- name: Install Dependencies
run: python3.7 -m pip install docker pytest
- name: Test Image
run: bash scripts/test.sh
env:
NAME: ${{ matrix.image.name }}
DOCKERFILE: ${{ matrix.image.dockerfile }}
PYTHON_VERSION: ${{ matrix.image.python_version }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,4 @@ crashlytics-build.properties

# Custom
Pipfile.lock
poetry.lock
23 changes: 0 additions & 23 deletions Pipfile

This file was deleted.

29 changes: 14 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
[![Build Status](https://travis-ci.com/tiangolo/uwsgi-nginx-flask-docker.svg?branch=master)](https://travis-ci.com/tiangolo/uwsgi-nginx-flask-docker)
[![Test](https://github.com/tiangolo/uwsgi-nginx-flask-docker/workflows/Test/badge.svg)](https://github.com/tiangolo/uwsgi-nginx-flask-docker/actions?query=workflow%3ATest) [![Deploy](https://github.com/tiangolo/uwsgi-nginx-flask-docker/workflows/Deploy/badge.svg)](https://github.com/tiangolo/uwsgi-nginx-flask-docker/actions?query=workflow%3ADeploy)

## Supported tags and respective `Dockerfile` links

* [`python3.7`, `latest` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/python3.7/Dockerfile)
* [`python3.6` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/python3.6/Dockerfile)
* [`python3.6-index` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/python3.6-index/Dockerfile)
* [`python3.6-alpine3.7` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/python3.6-alpine3.7/Dockerfile)
* [`python3.6-alpine3.8` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/python3.6-alpine3.8/Dockerfile)
* [`python3.5` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/python3.5/Dockerfile)
* [`python3.5-index` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/python3.5/Dockerfile)
* [`python2.7` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/python2.7/Dockerfile)
* [`python2.7-index` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/python2.7-index/Dockerfile)
* [`python2.7-alpine3.7` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/python2.7-alpine3.7/Dockerfile)
* [`python2.7-alpine3.8` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/python2.7-alpine3.8/Dockerfile)
* [`python3.7`, `latest` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/docker-images/python3.7.dockerfile)
* [`python3.6` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/docker-images/python3.6.dockerfile)
* [`python3.6-alpine3.8` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/docker-images/python3.6-alpine3.8.dockerfile)
* [`python3.6-alpine3.7` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/docker-images/python3.6-alpine3.7.dockerfile)
* [`python3.5` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/docker-images/python3.5.dockerfile)
* [`python2.7` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/docker-images/python2.7.dockerfile)
* [`python2.7-alpine3.8` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/docker-images/python2.7-alpine3.8.dockerfile)
* [`python2.7-alpine3.7` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/docker-images/python2.7-alpine3.7.dockerfile)

**Note**: Note: There are [tags for each build date](https://hub.docker.com/r/tiangolo/uwsgi-nginx-flask/tags). If you need to "pin" the Docker image version you use, you can select one of those tags. E.g. `tiangolo/uwsgi-nginx-flask:python3.7-2019-10-14`.

## Temporarily not supported
## Python 3.7 not supported in in Alpine

* [`python3.7-alpine3.7` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/python3.7-alpine3.7/Dockerfile) and [`python3.7-alpine3.8` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/python3.7-alpine3.8/Dockerfile) Temporarily not supported as uWSGI has not been released with Python 3.7 support for [Alpine 3.7](https://pkgs.alpinelinux.org/package/v3.7/main/x86/uwsgi-python3) nor for [Alpine 3.8](https://pkgs.alpinelinux.org/package/v3.8/main/x86/uwsgi-python3)
As uWSGI has not been released with Python 3.7 support for [Alpine 3.7](https://pkgs.alpinelinux.org/package/v3.7/main/x86/uwsgi-python3) and [Alpine 3.8](https://pkgs.alpinelinux.org/package/v3.8/main/x86/uwsgi-python3), it is still not supported.

It doesn't depend on this image but on uWSGI releases for Alpine.

# uwsgi-nginx-flask

**Docker** image with **uWSGI** and **Nginx** for **Flask** web applications in **Python 3.7**, **Python 3.6**, **Python 3.5** and **Python 2.7** running in a single container. Optionally using Alpine Linux.
**Docker** image with **uWSGI** and **Nginx** for **Flask** web applications in **Python 3.5** and above, and **Python 2.7** running in a single container. Optionally using Alpine Linux.

## Description

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
echo "Running inside /app/prestart.sh, you could add migrations to this file, e.g.:"

echo "
#! /usr/bin/env bash
#! /usr/bin/env sh
# Let the DB start
sleep 10;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ set -e

/uwsgi-nginx-entrypoint.sh

# Explicitly add installed Python packages and uWSGI Python packages to PYTHONPATH
# Otherwise uWSGI can't import Flask
export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.7/site-packages:/usr/lib/python2.7/site-packages

# Get the URL for static files from the environment variable
USE_STATIC_URL=${STATIC_URL:-'/static'}
# Get the absolute path of the static files from the environment variable
Expand Down Expand Up @@ -40,4 +36,11 @@ else
printf "$content_server" > /etc/nginx/conf.d/nginx.conf
fi

# For Alpine:
# Explicitly add installed Python packages and uWSGI Python packages to PYTHONPATH
# Otherwise uWSGI can't import Flask
if [ -n "$ALPINEPYTHON" ] ; then
export PYTHONPATH=$PYTHONPATH:/usr/local/lib/$ALPINEPYTHON/site-packages:/usr/lib/$ALPINEPYTHON/site-packages
fi

exec "$@"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[mypy]
disallow_untyped_defs = True
ignore_missing_imports = True
21 changes: 21 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[tool.poetry]
name = "uwsgi-nginx-flask-docker"
version = "0.1.0"
description = "Docker image with uWSGI and Nginx for Flask applications in Python 3.6 and above and Python 2.7 running in a single container. Optionally with Alpine Linux."
authors = ["Sebastián Ramírez <[email protected]>"]
license = "MIT"

[tool.poetry.dependencies]
python = "^3.6"
docker = "^4.2.0"
pytest = "^5.4.1"

[tool.poetry.dev-dependencies]
black = "^19.10b0"
isort = "^4.3.21"
autoflake = "^1.3.1"
mypy = "^0.770"

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
18 changes: 0 additions & 18 deletions python2.7-alpine3.7/app/main.py

This file was deleted.

12 changes: 0 additions & 12 deletions python2.7-alpine3.7/app/prestart.sh

This file was deleted.

18 changes: 0 additions & 18 deletions python2.7-alpine3.8/app/main.py

This file was deleted.

3 changes: 0 additions & 3 deletions python2.7-alpine3.8/app/uwsgi.ini

This file was deleted.

43 changes: 0 additions & 43 deletions python2.7-alpine3.8/entrypoint.sh

This file was deleted.

11 changes: 0 additions & 11 deletions python2.7-index/Dockerfile

This file was deleted.

23 changes: 0 additions & 23 deletions python2.7-index/app/main.py

This file was deleted.

10 changes: 0 additions & 10 deletions python2.7-index/app/static/index.html

This file was deleted.

12 changes: 0 additions & 12 deletions python2.7/app/prestart.sh

This file was deleted.

3 changes: 0 additions & 3 deletions python2.7/app/uwsgi.ini

This file was deleted.

Loading

0 comments on commit e5c22f7

Please sign in to comment.