Skip to content

Commit 8c09b45

Browse files
authored
Initial commit
0 parents  commit 8c09b45

File tree

20 files changed

+1715
-0
lines changed

20 files changed

+1715
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.245.0/containers/python-3/.devcontainer/base.Dockerfile
2+
3+
# [Choice] Python version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.10, 3.9, 3.8, 3.7, 3.6, 3-bullseye, 3.10-bullseye, 3.9-bullseye, 3.8-bullseye, 3.7-bullseye, 3.6-bullseye, 3-buster, 3.10-buster, 3.9-buster, 3.8-buster, 3.7-buster, 3.6-buster
4+
ARG VARIANT="3.10-bullseye"
5+
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}

.devcontainer/devcontainer.json

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.0/containers/python-3
3+
{
4+
"name": "Python 3",
5+
"forwardPorts": [8000],
6+
"build": {
7+
"dockerfile": "Dockerfile",
8+
"context": "..",
9+
"args": {
10+
// Update 'VARIANT' to pick a Python version: 3, 3.10, 3.9, 3.8, 3.7, 3.6
11+
// Append -bullseye or -buster to pin to an OS version.
12+
// Use -bullseye variants on local on arm64/Apple Silicon.
13+
"VARIANT": "3.8-bullseye",
14+
// Options
15+
"NODE_VERSION": "none"
16+
}
17+
},
18+
19+
// Configure tool-specific properties.
20+
"customizations": {
21+
// Configure properties specific to VS Code.
22+
"vscode": {
23+
// Set *default* container specific settings.json values on container create.
24+
"settings": {
25+
"python.defaultInterpreterPath": "/usr/local/bin/python",
26+
"python.linting.enabled": true,
27+
"python.linting.pylintEnabled": true,
28+
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
29+
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
30+
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
31+
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
32+
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
33+
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
34+
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
35+
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
36+
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint"
37+
},
38+
39+
// Add the IDs of extensions you want installed when the container is created.
40+
"extensions": [
41+
"ms-python.python",
42+
"ms-python.vscode-pylance",
43+
"GitHub.copilot"
44+
]
45+
}
46+
},
47+
48+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
49+
// "forwardPorts": [],
50+
51+
// Use 'postCreateCommand' to run commands after the container is created.
52+
"postCreateCommand": "pip3 install --user -r requirements.txt",
53+
54+
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
55+
"remoteUser": "vscode",
56+
"features": {
57+
"azure-cli": "latest"
58+
}
59+
}

.github/workflows/docker_image.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Docker Image CI
2+
3+
on:
4+
# Using pattern as described in https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#using-filters
5+
pull_request:
6+
branches:
7+
- main
8+
push:
9+
branches:
10+
- main
11+
# Allow mannually trigger
12+
workflow_dispatch:
13+
14+
jobs:
15+
16+
build:
17+
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- uses: actions/checkout@v3
22+
- run: echo "Job being triggered by ${{ github.event_name }} event"
23+
- name: Build the Codespaces container image
24+
run: docker build . --file .devcontainer/Dockerfile
25+
- run: echo "Job status is ${{ job.status }}."

.github/workflows/web_app.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Build and deploy Python app to Azure Web App
2+
3+
env:
4+
AZURE_WEBAPP_NAME: your-app-name # set this to your application's name
5+
WORKING_DIRECTORY: '.' # set this to the path to your path of working directory inside github repository, defaults to the repository root
6+
PYTHON_VERSION: '3.9'
7+
STARTUP_COMMAND: 'gunicorn -w 2 -k uvicorn.workers.UvicornWorker webapp.main:app' # set this to the startup command required to start the gunicorn server. default it is empty
8+
9+
on:
10+
# uncomment the next two lines to deploy on every push to main
11+
#push:
12+
# branches: [ "main" ]
13+
workflow_dispatch:
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
build-and-deploy:
20+
runs-on: ubuntu-latest
21+
environment: dev
22+
steps:
23+
# checkout the repo
24+
- uses: actions/checkout@master
25+
# setup python
26+
- name: Setup Python
27+
uses: actions/setup-python@v1
28+
with:
29+
python-version: ${{ env.PYTHON_VERSION }}
30+
# install dependencies
31+
- name: python install
32+
working-directory: ${{ env.WORKING_DIRECTORY }}
33+
run: |
34+
sudo apt install python${{ env.PYTHON_VERSION }}-venv
35+
python -m venv --copies antenv
36+
source antenv/bin/activate
37+
pip install setuptools
38+
pip install -r requirements.txt
39+
# Azure login
40+
- uses: azure/login@v1
41+
with:
42+
creds: ${{ secrets.AZURE_CREDENTIALS }}
43+
- uses: azure/appservice-settings@v1
44+
with:
45+
app-name: ${{ env.AZURE_WEBAPP_NAME }}
46+
mask-inputs: false
47+
general-settings-json: '{"linuxFxVersion": "PYTHON|${{ env.PYTHON_VERSION }}"}' #'General configuration settings as Key Value pairs'
48+
# deploy web app
49+
- uses: azure/webapps-deploy@v2
50+
with:
51+
app-name: ${{ env.AZURE_WEBAPP_NAME }}
52+
package: ${{ env.WORKING_DIRECTORY }}
53+
startup-command: ${{ env.STARTUP_COMMAND }}
54+
# Azure logout
55+
- name: logout
56+
run: |
57+
az logout

.gitignore

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
pip-wheel-metadata/
24+
share/python-wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
30+
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33+
*.manifest
34+
*.spec
35+
36+
# Installer logs
37+
pip-log.txt
38+
pip-delete-this-directory.txt
39+
40+
# Unit test / coverage reports
41+
htmlcov/
42+
.tox/
43+
.nox/
44+
.coverage
45+
.coverage.*
46+
.cache
47+
nosetests.xml
48+
coverage.xml
49+
*.cover
50+
*.py,cover
51+
.hypothesis/
52+
.pytest_cache/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
target/
76+
77+
# Jupyter Notebook
78+
.ipynb_checkpoints
79+
80+
# IPython
81+
profile_default/
82+
ipython_config.py
83+
84+
# pyenv
85+
.python-version
86+
87+
# pipenv
88+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
90+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
91+
# install all needed dependencies.
92+
#Pipfile.lock
93+
94+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
95+
__pypackages__/
96+
97+
# Celery stuff
98+
celerybeat-schedule
99+
celerybeat.pid
100+
101+
# SageMath parsed files
102+
*.sage.py
103+
104+
# Environments
105+
.env
106+
.venv
107+
env/
108+
venv/
109+
ENV/
110+
env.bak/
111+
venv.bak/
112+
113+
# Spyder project settings
114+
.spyderproject
115+
.spyproject
116+
117+
# Rope project settings
118+
.ropeproject
119+
120+
# mkdocs documentation
121+
/site
122+
123+
# mypy
124+
.mypy_cache/
125+
.dmypy.json
126+
dmypy.json
127+
128+
# Pyre type checker
129+
.pyre/

CODE_OF_CONDUCT.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Microsoft Open Source Code of Conduct
2+
3+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
4+
5+
Resources:
6+
7+
- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/)
8+
- [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
9+
- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) Microsoft Corporation.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE

0 commit comments

Comments
 (0)