Skip to content

Commit

Permalink
flask-poetry project
Browse files Browse the repository at this point in the history
  • Loading branch information
cnuss committed Oct 15, 2024
1 parent 006a6ba commit be88a25
Show file tree
Hide file tree
Showing 6 changed files with 348 additions and 13 deletions.
103 changes: 103 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# Virtual environments
.venv/
env/
venv/
ENV/
env.bak/
venv.bak/

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# pyright
pyrightconfig.json

# Pyre type checker
.pyre/

# Profiling data
*.prof
*.log
*.dat
*.lprof

# Editor files
.vscode/
.idea/
*.swp
*~
*.swo

# MacOS-specific files
.DS_Store

# Docker
docker-compose.override.yml
42 changes: 29 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,46 @@
# A CHANGEME-FRAMEWORK App Running On AWS Lambda
# A Python + Flask (w/Poetry) App Running On AWS Lambda

![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/scaffoldly/scaffoldly-examples/scaffoldly.yml?branch=CHANGEME-BRANCHNAME&link=https%3A%2F%2Fgithub.com%2Fscaffoldly%2Fscaffoldly-examples%2Factions)
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/scaffoldly/scaffoldly-examples/scaffoldly.yml?branch=python-flask-poetry&link=https%3A%2F%2Fgithub.com%2Fscaffoldly%2Fscaffoldly-examples%2Factions)

This application was generated with the following command:

```bash
CHANGEME-CREATECOMMAND
```
1. `poetry new flask-poetry && cd flask-poeetry`
1. `poetry add flask`

Then, the [Simple Example](https://github.com/pallets/flask/?tab=readme-ov-file#a-simple-example) from [`flask`](https://github.com/pallets/flask) was added to [`flask_poetry/__init__.py`](flask_poetry/__init__.py).

✨ No modifications or SDKs were made or added to the code to "make it work" in AWS Lambda.

Check out our other [examples](https://github.com/scaffoldly/scaffoldly-examples) and Learn more at [scaffoldly.dev](https://scaffoldly.dev)!

### Working example

[CHANGEME-URL](CHANGEME-URL)
[https://7dkca5ogwlgdjc66e4wc5braiu0ewgma.lambda-url.us-east-1.on.aws](https://7dkca5ogwlgdjc66e4wc5braiu0ewgma.lambda-url.us-east-1.on.aws)

## First, Scaffoldly Config was added...

In the project's [`CHANGEME-CONFIGFILE`](CHANGEME-CONFIGFILE) file, the `scaffoldly` configuration was added:
In the project's [`pyproject.toml`](pyproject.toml) file, the `scaffoldly` configuration was added:

- Note 1
- Note 2
- `poetry` is installed using the `packages` directive
- The `prepare` command in `flask` will have `poetry` make a `.venv` when `poetry install` is invoked.
- The `files` command for `flask` includes all of the files/and directories needed at runtime.
- The `start` command in `flask` will start `flask` using `poetry run`

```
CHANGEME-CONFIG
[tool.scaffoldly]
runtime = "python:3.13"
handler = "localhost:5000"
files = ["pyproject.toml", "poetry.lock"]
packages = ["pip:poetry"]
[tool.scaffoldly.services.flask]
files = [".venv", "flask_poetry"]
packages = ["pip:poetry"]
[tool.scaffoldly.services.flask.scripts]
prepare = "poetry config virtualenvs.in-project true"
install = "poetry install"
start = "poetry run flask --app flask_poetry run"
```

See the [Scaffoldly Docs](https://scaffoldly.dev/docs/config/) for additional configuration directives.
Expand All @@ -41,10 +57,10 @@ See the [Scaffoldly Docs](https://scaffoldly.dev/docs/cli/#scaffoldly-deploy) fo

```bash
🚀 Deployment Complete!
🆔 App Identity: CHANGEME-IDENTITY
🆔 App Identity: arn:aws:iam::123456789012:role/flask-poetry-9c9f0eac
📄 Env Files: .env.main, .env
📦 Image Size: CHANGEME-IMAGESIZE MB
🌎 URL: CHANGEME-URL
📦 Image Size: 1.12 GB
🌎 URL: https://7dkca5ogwlgdjc66e4wc5braiu0ewgma.lambda-url.us-east-1.on.aws
```

## GitHub Action added for CI/CD
Expand Down
7 changes: 7 additions & 0 deletions flask_poetry/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from flask import Flask

app = Flask(__name__)

@app.route("/")
def hello():
return "Hello, World!"
179 changes: 179 additions & 0 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[tool.poetry]
name = "flask-poetry"
version = "0.1.0"
description = ""
authors = ["Christian Nuss <christian.nuss@gmail.com>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.13"
flask = "^3.0.3"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.scaffoldly]
runtime = "python:3.13"
handler = "localhost:5000"
files = ["pyproject.toml", "poetry.lock"]
packages = ["pip:poetry"]

[tool.scaffoldly.services.flask]
files = [".venv", "flask_poetry"]
packages = ["pip:poetry"]

[tool.scaffoldly.services.flask.scripts]
prepare = "poetry config virtualenvs.in-project true"
install = "poetry install"
start = "poetry run flask --app flask_poetry run"
Empty file added tests/__init__.py
Empty file.

0 comments on commit be88a25

Please sign in to comment.