Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Nusnus committed Aug 21, 2020
0 parents commit 4942f82
Show file tree
Hide file tree
Showing 47 changed files with 940 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ACTIVE_ENV='DEVELOPMENT'
MICROSERVICE_NAME='service_name'
PORT=5000
4 changes: 4 additions & 0 deletions .flaskenv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FLASK_APP="src.app:app"
FLASK_ENV=DEVELOPMENT

host=0.0.0.0
156 changes: 156 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
# 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/

### JetBrains template

# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff:
.idea/workspace.xml
.idea/tasks.xml

# Sensitive or high-churn files:
.idea/dataSources/
.idea/dataSources.ids
.idea/dataSources.xml
.idea/dataSources.local.xml
.idea/sqlDataSources.xml
.idea/dynamic.xml
.idea/uiDesigner.xml
.idea/*
.idea

# Gradle:
.idea/gradle.xml
.idea/libraries

# Mongo Explorer plugin:
.idea/mongoSettings.xml
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "sdk"]
path = sdk
url = [email protected]:PyBackendBoilerplate/sdk.git
71 changes: 71 additions & 0 deletions .style.yapf
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Code style formatting settings
# https://github.com/google/yapf

[style]

# Which predefined style this style is based on.
BASED_ON_STYLE = google

# The number of columns to use for indentation.
INDENT_WIDTH = 4

# Max line length
COLUMN_LIMIT = 120


# Put closing brackets on a separate line, dedented, if the bracketed
# expression can't fit in a single line. Applies to all kinds of brackets,
# including function definitions and calls. For example:
#
# config = {
# 'key1': 'value1',
# 'key2': 'value2',
# } # <--- this bracket is dedented and on a separate line
DEDENT_CLOSING_BRACKETS = True

# Do not split consecutive brackets. Only relevant when
# dedent_closing_brackets is set. For example:
#
# call_func_that_takes_a_dict(
# {
# 'key1': 'value1',
# 'key2': 'value2',
# }
# )
#
# would reformat to:
#
# call_func_that_takes_a_dict({
# 'key1': 'value1',
# 'key2': 'value2',
# })
COALESCE_BRACKETS = True

# Let spacing indicate operator precedence.
# For example:
#
# a = 1 * 2 + 3 / 4
# b = 1 / 2 - 3 * 4
# c = (1 + 2) * (3 - 4)
# d = (1 - 2) / (3 + 4)
# e = 1 * 2 - 3
# f = 1 + 2 + 3 + 4
# will be formatted as follows to indicate precedence:
#
# a = 1*2 + 3/4
# b = 1/2 - 3*4
# c = (1+2) * (3-4)
# d = (1-2) / (3+4)
# e = 1*2 - 3
# f = 1 + 2 + 3 + 4
ARITHMETIC_PRECEDENCE_INDICATION = True

# If a comma separated list (dict, list, tuple, or function def)
# is on a line that is too long, split such that all elements are on a single line.
#SPLIT_ALL_COMMA_SEPARATED_VALUES = TRUE


# More settings
# https://github.com/google/yapf#knobs
# https://gist.github.com/krnd/3b8c5834c5c5c5097638ec10729787f7
# https://github.com/google/yapf/blob/51ffe2d07930a509ecb2ef454a7b251eeeac0a59/yapf/yapflib/style.py
62 changes: 62 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
// 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
"configurations": [
{
"name": "Python: Gunicorn",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/.venv/bin/gunicorn",
"env": {
// Keeps Python from generating .pyc files (__pycache__)
"PYTHONDONTWRITEBYTECODE": "1"
},
"args": [
"--config",
"src/config/gunicorn_conf.py",
"src.app:app"
]
// "postDebugTask": "Kill flask process if debugger was detached before the process was closed"
},
{
"name": "Python: Docker (Remote Attach)",
"type": "python",
"request": "attach",
"port": 10001,
"host": "localhost",
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/app"
}
]
},
{
"name": "Python: Flask",
"type": "python",
"request": "launch",
"module": "flask",
"args": [
"run"
],
"jinja": true,
"env": {
// Keeps Python from generating .pyc files (__pycache__)
"PYTHONDONTWRITEBYTECODE": "1"
}
},
{
"name": "Python: Script",
"type": "python",
"request": "launch",
"program": "src/main.py",
"console": "integratedTerminal",
"env": {
// Keeps Python from generating .pyc files (__pycache__)
"PYTHONDONTWRITEBYTECODE": "1"
}
// "cwd": "${fileDirname}"
}
]
}
18 changes: 18 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"python.pythonPath": "${workspaceFolder}/.venv/bin/python3",
"python.languageSever": "Pylance",
"python.analysis.autoSearchPaths": true,
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"editor.formatOnSave": true,
"python.formatting.provider": "yapf",
"terminal.integrated.env.osx": {
"PYTHONPATH": "${env:PYTHONPATH}:${workspaceFolder}/src"
},
"terminal.integrated.env.linux": {
"PYTHONPATH": "${env:PYTHONPATH}:${workspaceFolder}/src"
},
"terminal.integrated.env.windows": {
"PYTHONPATH": "${env:PYTHONPATH};${workspaceFolder}/src"
}
}
12 changes: 12 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Kill flask process if debugger was detached before the process was closed",
"type": "shell",
"command": "lsof -wni tcp:5000 | awk 'NR>1{kill -9 $2}'"
}
]
}
33 changes: 33 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# For more information, please refer to https://aka.ms/vscode-docker-python
FROM python:3.8

EXPOSE 5000

# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE 1

# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED 1

WORKDIR /app

ADD sdk sdk
ADD src src

ADD .env .
ADD .flaskenv .

# Install pip requirements
ADD requirements requirements
ADD install_requirements.sh .
RUN ./install_requirements.sh

# Switching to a non-root user, please refer to https://aka.ms/vscode-docker-python-user-rights
RUN useradd appuser && chown -R appuser /app
USER appuser

# gunicorn --check-config APP_MODULE

# During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug
# docker-compose up will run this
CMD ["gunicorn", "--config", "src/config/gunicorn_conf.py", "src.app:app"]
Loading

0 comments on commit 4942f82

Please sign in to comment.