Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonycorletti committed Feb 7, 2020
0 parents commit cf4e9d6
Show file tree
Hide file tree
Showing 10 changed files with 431 additions and 0 deletions.
164 changes: 164 additions & 0 deletions .dockerignore
@@ -0,0 +1,164 @@
# Created by https://www.gitignore.io/api/python,linux,osx,windows,vagrant

### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

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

# 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/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# dotenv
.env

# virtualenv
.venv/
venv/
ENV/

# Spyder project settings
.spyderproject

# Rope project settings
.ropeproject


### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*


### OSX ###
*.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk


### Windows ###
# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

# Windows shortcuts
*.lnk


### Vagrant ###
.vagrant/
### Local rules, see .gitignore.tail to override! ###
shippable
.git

/tmp
32 changes: 32 additions & 0 deletions .editorconfig
@@ -0,0 +1,32 @@
# https://editorconfig.org/

root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8

# Use 2 spaces for the HTML files
[*.html]
indent_size = 2

# The JSON files contain newlines inconsistently
[*.json]
indent_size = 2

[**/admin/js/vendor/**]
indent_style = tab

# Minified JavaScript files shouldn't be changed
[**.min.js]
indent_style = tab

# Makefiles always use tabs for indentation
[Makefile]
indent_style = tab

# Batch files use tabs for indentation
[*.bat]
indent_style = tab
134 changes: 134 additions & 0 deletions .gitignore
@@ -0,0 +1,134 @@
# 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/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

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

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

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

# Pyre type checker
.pyre/

/tmp
keys/*.pem
hosts/*
!hosts/*.enc
11 changes: 11 additions & 0 deletions Dockerfile
@@ -0,0 +1,11 @@
FROM python:3.7-slim

RUN apt-get update -y \
&& apt-get install -y gcc libpq-dev

WORKDIR /app
COPY . /app

RUN pip3 install -r requirements.txt

CMD gunicorn main:api -c gunicorn_config.py
21 changes: 21 additions & 0 deletions README.md
@@ -0,0 +1,21 @@
# cloudrun-fastapi

Boilerplate for running [FastAPI](https://fastapi.tiangolo.com/) on [Google Cloud Run](https://cloud.google.com/run) with [Google Cloud Build](https://cloud.google.com/cloud-build) for deployment.

Future Features:

- PostgreSQL connection and migrations with Alembic
- Secrets Management with Google Cloud Secrets Manager
- Oauth & JWT Authentication and Authorization
- Google Cloud PubSub Integration
- Google Cloud Scheduler Integration

### Contributions & Suggestions

[Pull requests](https://github.com/anthcor/cloudrun-fastapi/compare) and [issues](https://github.com/anthcor/cloudrun-fastapi/issues/new) are very welcome!

---

### Authors

- [Anthony Corletti](https://github.com/anthcor)
25 changes: 25 additions & 0 deletions cloudbuild-template.yaml
@@ -0,0 +1,25 @@
steps:
- id: "docker_build"
name: "gcr.io/cloud-builders/docker"
args: ["build", "-t", "us.gcr.io/$PROJECT_ID/api", "."]

- id: "docker_push"
name: "gcr.io/cloud-builders/docker"
args: ["push", "us.gcr.io/$PROJECT_ID/api"]

- id: "cloud_run_deploy"
name: "gcr.io/google.com/cloudsdktool/cloud-sdk"
args:
[
"gcloud",
"run",
"deploy",
"fastapi-$BRANCH_NAME",
"--image=us.gcr.io/$PROJECT_ID/fastapi:latest",
"--port=8080",
"--platform=managed",
"--region=us-central1",
"--allow-unauthenticated",
"--revision-suffix=$SHORT_SHA",
"--set-env-vars=PROJECT_ID=$PROJECT_ID,SHORT_SHA=$SHORT_SHA",
]

0 comments on commit cf4e9d6

Please sign in to comment.