Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Initial MR for fastapi complete setup #96

Draft
wants to merge 26 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
108460f
initial setup
erinxocon Jul 28, 2020
299a7ea
more init
erinxocon Aug 1, 2020
4eecf33
ignore new line changes because I'm switching between windows and lin…
erinxocon Aug 2, 2020
87ec5dd
devcontainer setup
erinxocon Aug 2, 2020
73319be
force everything to be LF, except for Windows batch files that requir…
erinxocon Aug 2, 2020
6355038
dev container environment all up and working!
erinxocon Aug 3, 2020
7355faf
basic working crud project with sqlalchemy and fastapi!
erinxocon Aug 3, 2020
53615b5
add ability to render and view site via vscode tasks
erinxocon Aug 3, 2020
bc06eee
a bunch more boilerplate setup since I'm using traefik 1.7
erinxocon Aug 4, 2020
b05e5f6
a little more setup and cleanup
erinxocon Aug 4, 2020
76078a6
August 10, 2020 3:24 AM
erinxocon Aug 10, 2020
e2f418e
August 12, 2020 8:38 PM
erinxocon Aug 13, 2020
130bb97
August 13, 2020 9:37 AM
erinxocon Aug 13, 2020
4a6bf1c
update gitignore with some windows things
erinxocon Aug 16, 2020
62a6bf3
flesh out env vars
erinxocon Aug 16, 2020
0184a12
use pydantic settings instead of rolling my own
erinxocon Aug 16, 2020
952cc41
August 17, 2020 11:03 AM
erinxocon Aug 17, 2020
87dda14
August 17, 2020 10:52 PM
erinxocon Aug 18, 2020
7b20e28
August 18, 2020 2:09 PM
erinxocon Aug 18, 2020
676e370
August 21, 2020 2:51 PM
erinxocon Aug 21, 2020
adf66e2
big reorg because I can't decide what I want, and I really need to ge…
erinxocon Aug 24, 2020
a2e4b78
migrations module morning
erinxocon Aug 24, 2020
697fc50
August 24, 2020 11:52 PM
erinxocon Aug 25, 2020
7098e89
August 24, 2020 11:54 PM
erinxocon Aug 25, 2020
8879beb
get everything ready for development and final boilerplate code
erinxocon Aug 25, 2020
71cdada
fix script file name
erinxocon Aug 25, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// See https://aka.ms/vscode-remote/devcontainer.json for format details.
{
"name": "electioncal",
"context": "..",
"service": "fastapi",
"dockerComposeFile": [
"docker-compose.yml"
],
"workspaceFolder": "/code",
"extensions": [
"ms-python.python",
"bungcip.better-toml",
"waderyan.gitblame",
"oderwat.indent-rainbow",
"mechatroner.rainbow-csv",
"redhat.vscode-yaml",
"ms-python.vscode-pylance",
"visualstudioexptteam.vscodeintellicode",
"docsmsft.docs-markdown",
],
"shutdownAction": "stopCompose",
"postCreateCommand": "cd /code; pipenv sync --dev",
// uncomment the following line if you are developing on linux
// due to the way docker on linux handles file perms with dev containers
// "remoteUser": "code"
}
66 changes: 66 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
version: "3.3"

volumes:
local_postgres_data: {}

services:
traefik:
image: traefik:v1.7
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ../docker/local/traefik/traefik.toml:/traefik.toml
ports:
- "80:80"
- "8080:8080"

mailhog:
image: mailhog/mailhog
labels:
traefik.enable: "True"
traefik.backend: "mailhog"
traefik.mailhog.port: 8025
traefik.mailhog.frontend.rule: "Host:mailhog.docker"

postgres:
image: postgres:12-alpine
volumes:
- local_postgres_data:/var/lib/postgresql/data
env_file:
- ../envs/local/postgres

pgadmin:
image: dpage/pgadmin4
depends_on:
- postgres
env_file:
- ../envs/local/pgadmin
labels:
traefik.enable: "True"
traefik.backend: "pgadmin"
traefik.pgadmin.port: 5050
traefik.pgadmin.frontend.rule: "Host:pgadmin.docker"

fastapi:
build:
context: .
dockerfile: ../docker/local/fastapi/Dockerfile
image: electioncal_local_fastapi
depends_on:
- postgres
- traefik
volumes:
- ..:/code
- ../docker/local/fastapi/entrypoint:/entrypoint
- ../docker/local/fastapi/start:/start
- ../.history:/commandhistory
env_file:
- ../envs/local/fastapi
- ../envs/local/postgres
labels:
traefik.enable: "True"
traefik.backend: "fastapi"
traefik.fastapi.port: 8000
traefik.fastapi.frontend.rule: "Host:api.electioncal.docker"
traefik.static.port: 4242
traefik.static.frontend.rule: "Host:electioncal.docker"
command: sleep infinity
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* text=auto eol=lf
*.{cmd,[cC][mM][dD]} text eol=crlf
*.{bat,[bB][aA][tT]} text eol=crlf
82 changes: 82 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,85 @@
# File created using '.gitignore Generator' for Visual Studio Code: https://bit.ly/vscode-gig

# Created by https://www.toptal.com/developers/gitignore/api/python,windows
# Edit at https://www.toptal.com/developers/gitignore?templates=python,windows

### Python ###
# 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/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# 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/
pytestdebug.log

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

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

# pytype static type analyzer
.pytype/

### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# End of https://www.toptal.com/developers/gitignore/api/python,windows

# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)

site/*
!site/CNAME
!site/static
Expand Down
4 changes: 4 additions & 0 deletions .history/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}
20 changes: 20 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"python.pythonPath": ".venv/bin/python",
"python.terminal.activateEnvironment": true,
"python.formatting.provider": "black",
"editor.formatOnSave": true,
"python.formatting.blackPath": "black",
"python.sortImports.path": "isort",
"[yaml]": {
"editor.tabSize": 4
},
"[toml]": {
"editor.tabSize": 4
},
"[dockerfile]": {
"editor.formatOnSave": false
},
"python.languageServer": "Pylance",
"python.testing.promptToConfigure": false,
"python.testing.pytestEnabled": false,
}
59 changes: 59 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Run Uvicorn",
"type": "shell",
"command": [
"pipenv",
"run",
"/start"
],
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
},
{
"label": "Build Static Site",
"type": "shell",
"command": [
"pipenv",
"run",
"python",
"scripts/build_site.py"
],
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
},
{
"label": "Run Static Site",
"type": "shell",
"command": [
"pipenv",
"run",
"python",
"-m",
"http.server",
"--directory",
"site/",
"4242"
],
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
}
]
}
34 changes: 34 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
pytest = "*"
ipython = "*"
# sqlalchemy-stubs = "*"
# mypy = "*"
# black = "==19.10b0"
# isort = "*"

[packages]
fastapi = "~=0.60.2"
uvicorn = "~=0.11.8"
pydantic = {version = "~=1.6.1", extras = ['email']}
python-multipart = "~=0.0.5"
sqlalchemy = "~=1.3.18"
databases = {extras = ["postgresql"], version = "~=0.3.2"}
requests = "~=2.24.0"
alembic = "~=1.4.2"
twilio = "~=6.44.2"
tenacity = "~=6.2.0"
# static site stuff
mistune= "==2.0.0a4"
Pillow = "*"
tomlkit = "*"
jinja2 = "~=2.11.2"
icalendar = "*"
pendulum = "*"

[requires]
python_version = "3.8"
Loading