Skip to content

Commit e5c22f7

Browse files
authored
♻️ Refactor build setup (#173)
* ➕ 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
1 parent 542c572 commit e5c22f7

File tree

118 files changed

+300
-1362
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+300
-1362
lines changed

.github/workflows/deploy.yml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
build:
10+
strategy:
11+
matrix:
12+
image:
13+
- name: latest
14+
python_version: "3.7"
15+
- name: python3.7
16+
python_version: "3.7"
17+
- name: python3.6
18+
python_version: "3.6"
19+
- name: python3.5
20+
python_version: "3.5"
21+
- name: python2.7
22+
python_version: "2.7"
23+
- name: python3.6-alpine3.8
24+
python_version: "3.6"
25+
- name: python3.6-alpine3.7
26+
python_version: "3.6"
27+
- name: python2.7-alpine3.8
28+
python_version: "2.7"
29+
- name: python2.7-alpine3.7
30+
python_version: "2.7"
31+
fail-fast: true
32+
runs-on: ubuntu-18.04
33+
steps:
34+
- uses: actions/checkout@v2
35+
- name: Set up Python
36+
uses: actions/setup-python@v1
37+
with:
38+
python-version: "3.7"
39+
- name: Install Dependencies
40+
run: python3.7 -m pip install docker pytest
41+
- name: Deploy Image
42+
run: bash scripts/build-push.sh
43+
env:
44+
NAME: ${{ matrix.image.name }}
45+
DOCKERFILE: ${{ matrix.image.dockerfile }}
46+
PYTHON_VERSION: ${{ matrix.image.python_version }}
47+
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
48+
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

.github/workflows/main.yml .github/workflows/issue-manager.yml

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
name: Issue Manager
2+
13
on:
24
schedule:
35
- cron: "0 0 * * *"

.github/workflows/test.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
pull_request:
6+
types: [opened, synchronize]
7+
8+
jobs:
9+
build:
10+
strategy:
11+
matrix:
12+
image:
13+
- name: latest
14+
python_version: "3.7"
15+
- name: python3.7
16+
python_version: "3.7"
17+
- name: python3.6
18+
python_version: "3.6"
19+
- name: python3.5
20+
python_version: "3.5"
21+
- name: python2.7
22+
python_version: "2.7"
23+
- name: python3.6-alpine3.8
24+
python_version: "3.6"
25+
- name: python3.6-alpine3.7
26+
python_version: "3.6"
27+
- name: python2.7-alpine3.8
28+
python_version: "2.7"
29+
- name: python2.7-alpine3.7
30+
python_version: "2.7"
31+
fail-fast: true
32+
runs-on: ubuntu-18.04
33+
steps:
34+
- uses: actions/checkout@v2
35+
- name: Set up Python
36+
uses: actions/setup-python@v1
37+
with:
38+
python-version: "3.7"
39+
- name: Install Dependencies
40+
run: python3.7 -m pip install docker pytest
41+
- name: Test Image
42+
run: bash scripts/test.sh
43+
env:
44+
NAME: ${{ matrix.image.name }}
45+
DOCKERFILE: ${{ matrix.image.dockerfile }}
46+
PYTHON_VERSION: ${{ matrix.image.python_version }}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,4 @@ crashlytics-build.properties
109109

110110
# Custom
111111
Pipfile.lock
112+
poetry.lock

Pipfile

-23
This file was deleted.

README.md

+14-15
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
1-
[![Build Status](https://travis-ci.com/tiangolo/uwsgi-nginx-flask-docker.svg?branch=master)](https://travis-ci.com/tiangolo/uwsgi-nginx-flask-docker)
1+
[![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)
22

33
## Supported tags and respective `Dockerfile` links
44

5-
* [`python3.7`, `latest` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/python3.7/Dockerfile)
6-
* [`python3.6` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/python3.6/Dockerfile)
7-
* [`python3.6-index` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/python3.6-index/Dockerfile)
8-
* [`python3.6-alpine3.7` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/python3.6-alpine3.7/Dockerfile)
9-
* [`python3.6-alpine3.8` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/python3.6-alpine3.8/Dockerfile)
10-
* [`python3.5` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/python3.5/Dockerfile)
11-
* [`python3.5-index` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/python3.5/Dockerfile)
12-
* [`python2.7` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/python2.7/Dockerfile)
13-
* [`python2.7-index` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/python2.7-index/Dockerfile)
14-
* [`python2.7-alpine3.7` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/python2.7-alpine3.7/Dockerfile)
15-
* [`python2.7-alpine3.8` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/python2.7-alpine3.8/Dockerfile)
5+
* [`python3.7`, `latest` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/docker-images/python3.7.dockerfile)
6+
* [`python3.6` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/docker-images/python3.6.dockerfile)
7+
* [`python3.6-alpine3.8` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/docker-images/python3.6-alpine3.8.dockerfile)
8+
* [`python3.6-alpine3.7` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/docker-images/python3.6-alpine3.7.dockerfile)
9+
* [`python3.5` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/docker-images/python3.5.dockerfile)
10+
* [`python2.7` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/docker-images/python2.7.dockerfile)
11+
* [`python2.7-alpine3.8` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/docker-images/python2.7-alpine3.8.dockerfile)
12+
* [`python2.7-alpine3.7` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/docker-images/python2.7-alpine3.7.dockerfile)
1613

1714
**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`.
1815

19-
## Temporarily not supported
16+
## Python 3.7 not supported in in Alpine
2017

21-
* [`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)
18+
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.
19+
20+
It doesn't depend on this image but on uWSGI releases for Alpine.
2221

2322
# uwsgi-nginx-flask
2423

25-
**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.
24+
**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.
2625

2726
## Description
2827

.travis.yml backup.travis.yml

File renamed without changes.
File renamed without changes.

python2.7-alpine3.8/app/prestart.sh docker-images/app/prestart.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
echo "Running inside /app/prestart.sh, you could add migrations to this file, e.g.:"
44

55
echo "
6-
#! /usr/bin/env bash
6+
#! /usr/bin/env sh
77
88
# Let the DB start
99
sleep 10;
File renamed without changes.

python2.7-alpine3.7/entrypoint.sh docker-images/entrypoint.sh

+7-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ set -e
33

44
/uwsgi-nginx-entrypoint.sh
55

6-
# Explicitly add installed Python packages and uWSGI Python packages to PYTHONPATH
7-
# Otherwise uWSGI can't import Flask
8-
export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.7/site-packages:/usr/lib/python2.7/site-packages
9-
106
# Get the URL for static files from the environment variable
117
USE_STATIC_URL=${STATIC_URL:-'/static'}
128
# Get the absolute path of the static files from the environment variable
@@ -40,4 +36,11 @@ else
4036
printf "$content_server" > /etc/nginx/conf.d/nginx.conf
4137
fi
4238

39+
# For Alpine:
40+
# Explicitly add installed Python packages and uWSGI Python packages to PYTHONPATH
41+
# Otherwise uWSGI can't import Flask
42+
if [ -n "$ALPINEPYTHON" ] ; then
43+
export PYTHONPATH=$PYTHONPATH:/usr/local/lib/$ALPINEPYTHON/site-packages:/usr/lib/$ALPINEPYTHON/site-packages
44+
fi
45+
4346
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.

mypy.ini

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[mypy]
2+
disallow_untyped_defs = True
3+
ignore_missing_imports = True

pyproject.toml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[tool.poetry]
2+
name = "uwsgi-nginx-flask-docker"
3+
version = "0.1.0"
4+
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."
5+
authors = ["Sebastián Ramírez <[email protected]>"]
6+
license = "MIT"
7+
8+
[tool.poetry.dependencies]
9+
python = "^3.6"
10+
docker = "^4.2.0"
11+
pytest = "^5.4.1"
12+
13+
[tool.poetry.dev-dependencies]
14+
black = "^19.10b0"
15+
isort = "^4.3.21"
16+
autoflake = "^1.3.1"
17+
mypy = "^0.770"
18+
19+
[build-system]
20+
requires = ["poetry>=0.12"]
21+
build-backend = "poetry.masonry.api"

python2.7-alpine3.7/app/main.py

-18
This file was deleted.

python2.7-alpine3.7/app/prestart.sh

-12
This file was deleted.

python2.7-alpine3.8/app/main.py

-18
This file was deleted.

python2.7-alpine3.8/app/uwsgi.ini

-3
This file was deleted.

python2.7-alpine3.8/entrypoint.sh

-43
This file was deleted.

python2.7-index/Dockerfile

-11
This file was deleted.

python2.7-index/app/main.py

-23
This file was deleted.

python2.7-index/app/static/index.html

-10
This file was deleted.

python2.7/app/prestart.sh

-12
This file was deleted.

python2.7/app/uwsgi.ini

-3
This file was deleted.

0 commit comments

Comments
 (0)