Dockerize a basic app

This commit is contained in:
Kenneth Allen 2023-06-26 16:22:19 +10:00
commit 1da0f08bc2
7 changed files with 149 additions and 0 deletions

1
.dockerignore Normal file
View File

@ -0,0 +1 @@
__pycache__/

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
__pycache__/

14
Dockerfile Normal file
View File

@ -0,0 +1,14 @@
FROM python:3.11
RUN pip3 install poetry
RUN poetry config virtualenvs.create false
RUN mkdir /opt/app
WORKDIR /opt/app
COPY pyproject.toml poetry.lock ./
RUN poetry install --no-dev
COPY ./ ./
CMD ["flask", "run", "--host", "0.0.0.0"]

8
app.py Normal file
View File

@ -0,0 +1,8 @@
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return 'Web App with Python Flask!'

6
docker-compose.yaml Normal file
View File

@ -0,0 +1,6 @@
services:
app:
build: .
init: true
ports:
- "127.0.0.1:5123:5000"

104
poetry.lock generated Normal file
View File

@ -0,0 +1,104 @@
[[package]]
name = "blinker"
version = "1.6.2"
description = "Fast, simple object-to-object and broadcast signaling"
category = "main"
optional = false
python-versions = ">=3.7"
[[package]]
name = "click"
version = "8.1.3"
description = "Composable command line interface toolkit"
category = "main"
optional = false
python-versions = ">=3.7"
[package.dependencies]
colorama = {version = "*", markers = "platform_system == \"Windows\""}
[[package]]
name = "colorama"
version = "0.4.6"
description = "Cross-platform colored terminal text."
category = "main"
optional = false
python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7"
[[package]]
name = "flask"
version = "2.3.2"
description = "A simple framework for building complex web applications."
category = "main"
optional = false
python-versions = ">=3.8"
[package.dependencies]
blinker = ">=1.6.2"
click = ">=8.1.3"
itsdangerous = ">=2.1.2"
Jinja2 = ">=3.1.2"
Werkzeug = ">=2.3.3"
[package.extras]
async = ["asgiref (>=3.2)"]
dotenv = ["python-dotenv"]
[[package]]
name = "itsdangerous"
version = "2.1.2"
description = "Safely pass data to untrusted environments and back."
category = "main"
optional = false
python-versions = ">=3.7"
[[package]]
name = "jinja2"
version = "3.1.2"
description = "A very fast and expressive template engine."
category = "main"
optional = false
python-versions = ">=3.7"
[package.dependencies]
MarkupSafe = ">=2.0"
[package.extras]
i18n = ["Babel (>=2.7)"]
[[package]]
name = "markupsafe"
version = "2.1.3"
description = "Safely add untrusted strings to HTML/XML markup."
category = "main"
optional = false
python-versions = ">=3.7"
[[package]]
name = "werkzeug"
version = "2.3.6"
description = "The comprehensive WSGI web application library."
category = "main"
optional = false
python-versions = ">=3.8"
[package.dependencies]
MarkupSafe = ">=2.1.1"
[package.extras]
watchdog = ["watchdog (>=2.3)"]
[metadata]
lock-version = "1.1"
python-versions = "^3.10"
content-hash = "d7a65ba75d9fd1d70398a76955d93d28129b8c09a3b56e10fef71ce427090c8b"
[metadata.files]
blinker = []
click = []
colorama = []
flask = []
itsdangerous = []
jinja2 = []
markupsafe = []
werkzeug = []

15
pyproject.toml Normal file
View File

@ -0,0 +1,15 @@
[tool.poetry]
name = "poetry-test"
version = "0.1.0"
description = ""
authors = ["Kenneth Allen <kenneth@kallen.dev>"]
[tool.poetry.dependencies]
python = "^3.10"
Flask = "^2.3.2"
[tool.poetry.dev-dependencies]
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"