From 7dad478ddac0caec8bafe55634884fa556558469 Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Tue, 30 Jun 2020 20:28:47 +0200 Subject: [PATCH] Bootstrap something to start --- .drone.yml | 18 ++++++++++++++++++ .gitignore | 12 ++++++++++++ Dockerfile | 9 +++++++++ Makefile | 10 ++++++++++ README.md | 15 +++++++++++++++ magic_app/app.py | 14 ++++++++++++++ magic_app/templates/index.html | 11 +++++++++++ pyproject.toml | 11 +++++++++++ requirements.txt | 1 + setup.py | 12 ++++++++++++ tox.ini | 25 +++++++++++++++++++++++++ 11 files changed, 138 insertions(+) create mode 100644 .drone.yml create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 Makefile create mode 100644 magic_app/app.py create mode 100644 magic_app/templates/index.html create mode 100644 pyproject.toml create mode 100644 requirements.txt create mode 100644 setup.py create mode 100644 tox.ini diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..4b08971 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,18 @@ +--- +matrix: + include: + - IMAGE: 3.8-buster + TOXENV: py38 + - IMAGE: 3.8-buster + TOXENV: lint + - IMAGE: 3.8-buster + TOXENV: sort + - IMAGE: 3.8-buster + TOXENV: format + +pipeline: + build: + image: python:${IMAGE} + commands: + - pip install tox + - tox -e ${TOXENV} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ca15349 --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +*.egg-info/ +*.pyc +.coverage +.eggs/ +.mypy_cache/ +.tox/ +.venv/ +__pycache__ +build/ +dist/ +pip-wheel-metadata/ +documentation/build/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..571de16 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM python:3.8-alpine + +WORKDIR /app + +ADD . /app + +RUN pip install -r requirements.txt + +CMD ["python", "magic_app/app.py"] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7ad377b --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +build: + @docker build -t autonomic/magicapp . + +run: + @docker run --rm -p 5000:5000 autonomic/magicapp + +publish: + @docker push autonomic/magicapp:v0.1.0 + +.PHONY: build run diff --git a/README.md b/README.md index c448a0c..12489ff 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,18 @@ # The Magic App A swarm of dreams. + +## Go Go Go No Docker + +```bash +$ python3 -m venv .venv && source .venv/bin/activate +$ pip install -r requirements.txt +$ python run.py +``` + +## Go Go Go Yes Docker + +```bash +$ make build +$ make run +``` diff --git a/magic_app/app.py b/magic_app/app.py new file mode 100644 index 0000000..c0712e9 --- /dev/null +++ b/magic_app/app.py @@ -0,0 +1,14 @@ +"""The Magic App.""" + +from flask import Flask, render_template + +app = Flask(__name__) + + +@app.route("/") +def home(): + return render_template("index.html") + + +if __name__ == "__main__": + app.run(host="0.0.0.0") diff --git a/magic_app/templates/index.html b/magic_app/templates/index.html new file mode 100644 index 0000000..9f1d967 --- /dev/null +++ b/magic_app/templates/index.html @@ -0,0 +1,11 @@ + + + + + + The Magic App + + + Hello, World. + + diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..50cb059 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,11 @@ +[build-system] +requires = [ + "setuptools", + "setuptools-scm", + "wheel", +] +build-backend = "setuptools.build_meta" + +[tool.black] +line-length = 80 +target-version = ["py38"] diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..8df7621 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +flask>=1.1.2,<2 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..9b68fa5 --- /dev/null +++ b/setup.py @@ -0,0 +1,12 @@ +from setuptools import find_packages, setup + +setup( + name="magic-app", + version="0.0.1a1", + url="https://git.autonomic.zone/autonomic-cooperative/the-magic-app", + author="Autonomic Cooperative", + author_email="helo@autonomic.zone", + description="The Magic App", + packages=find_packages(), + install_requires=["flask>=1.1.2,<2"], +) diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..dd715dd --- /dev/null +++ b/tox.ini @@ -0,0 +1,25 @@ +[tox] +envlist = + py38 + lint + sort + format +skip_missing_interpreters = True +isolated_build = True + +[testenv] + +[testenv:lint] +skipdist = True +deps = flake8 +commands = flake8 {posargs} magic_app/ + +[testenv:sort] +skipdist = True +deps = isort +commands = isort {posargs:-rc -c} -sp setup.cfg magic_app/ + +[testenv:format] +skipdist = True +deps = black +commands = black {posargs:--check} magic_app/