Skip to content

Commit f399a60

Browse files
committed
Initial commit
0 parents  commit f399a60

10 files changed

Lines changed: 451 additions & 0 deletions

File tree

.gitignore

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# PKG Deploy
2+
.vagrant/
3+
4+
### OSX ###
5+
.DS_Store
6+
.AppleDouble
7+
.LSOverride
8+
9+
# Icon must end with two \r
10+
Icon
11+
12+
# Thumbnails
13+
._*
14+
15+
# Files that might appear on external disk
16+
.Spotlight-V100
17+
.Trashes
18+
19+
# Directories potentially created on remote AFP share
20+
.AppleDB
21+
.AppleDesktop
22+
Network Trash Folder
23+
Temporary Items
24+
.apdisk
25+
26+
# Editors
27+
.vscode/
28+
29+
### Python ###
30+
# Byte-compiled / optimized / DLL files
31+
__pycache__/
32+
*.py[cod]
33+
34+
# C extensions
35+
*.so
36+
37+
# Distribution / packaging
38+
.Python
39+
venv/
40+
env/
41+
develop-eggs/
42+
dist/
43+
downloads/
44+
eggs/
45+
lib/
46+
lib64/
47+
parts/
48+
sdist/
49+
var/
50+
*.egg-info/
51+
.installed.cfg
52+
*.egg
53+
54+
# PyInstaller
55+
# Usually these files are written by a python script from a template
56+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
57+
*.manifest
58+
#*.spec
59+
60+
# Installer logs
61+
pip-log.txt
62+
pip-delete-this-directory.txt
63+
64+
# Unit test / coverage reports
65+
htmlcov/
66+
.tox/
67+
.coverage
68+
.cache
69+
nosetests.xml
70+
coverage.xml
71+
.testmondata
72+
73+
# Translations
74+
*.mo
75+
*.pot
76+
77+
# Sphinx documentation
78+
docs/_build/
79+
80+
# PyBuilder
81+
target/
82+
83+
84+
### Django ###
85+
*.log
86+
*.pot
87+
*.pyc
88+
__pycache__/
89+
local_settings.py
90+
91+
# Local dev
92+
.env
93+
.localenv
94+
*.sqlite3

.pkgdeploy/config_deb.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: pkgdeploy-fastapi
2+
format: deb
3+
distribution: ubuntu18
4+
architecture: 64-bit
5+
description: A simple FastAPI project to show how PKG Deploy works
6+
url: http://www.pkgdeploy.com
7+
license: GPLv3
8+
maintainer: PKG Deploy Devs <devs@pkgdeploy.com>
9+
10+
build:
11+
user: pkgdeploy
12+
group: pkgdeploy
13+
directory: /opt/pkgdeploy/fastapi/
14+
requires:
15+
- python3-pip
16+
- python3-venv
17+
- python3-distutils
18+
commands: |
19+
python3 -m venv ./venv/
20+
./venv/bin/pip install pipenv
21+
# PIPENV_VENV_IN_PROJECT ensures the pipenv venv is created in the project
22+
# directory so it is copied and owned by the correct user after install
23+
PIPENV_VENV_IN_PROJECT=1 ./venv/bin/pipenv sync
24+
25+
install:
26+
requires:
27+
- python3
28+
- python3-distutils
29+
- nginx
30+
user: pkgdeploy
31+
group: pkgdeploy
32+
copy:
33+
- source: ./
34+
destination: /opt/pkgdeploy/fastapi/
35+
user: pkgdeploy
36+
group: pkgdeploy
37+
permissions: 755
38+
- source: .pkgdeploy/nginx.conf
39+
destination: /etc/nginx/sites-enabled/fastapi.conf
40+
- source: .pkgdeploy/fastapi.socket
41+
destination: /etc/systemd/system/fastapi.socket
42+
- source: .pkgdeploy/fastapi.service
43+
destination: /etc/systemd/system/fastapi.service
44+
45+
after_install: |
46+
unlink /etc/nginx/sites-enabled/default
47+
systemctl enable --now nginx
48+
nginx -s reload
49+
systemctl enable --now fastapi.socket
50+
51+
after_upgrade: |
52+
nginx -s reload
53+
systemctl daemon-reload
54+
systemctl restart fastapi.socket

.pkgdeploy/config_rpm.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: pkgdeploy-fastapi
2+
format: rpm
3+
distribution: centos7
4+
architecture: 64-bit
5+
description: A simple FastAPI project to show how PKG Deploy works
6+
url: http://www.pkgdeploy.com
7+
license: GPLv3
8+
maintainer: PKG Deploy Devs <devs@pkgdeploy.com>
9+
10+
build:
11+
user: pkgdeploy
12+
group: pkgdeploy
13+
directory: /opt/pkgdeploy/fastapi/
14+
requires:
15+
- python36-pip
16+
commands: |
17+
python3.6 -m venv ./venv/
18+
./venv/bin/pip install pipenv
19+
# PIPENV_VENV_IN_PROJECT ensures the pipenv venv is created in the project
20+
# directory so it is copied and owned by the correct user after install
21+
PIPENV_VENV_IN_PROJECT=1 ./venv/bin/pipenv sync
22+
23+
install:
24+
requires:
25+
- python36
26+
- nginx
27+
user: pkgdeploy
28+
group: pkgdeploy
29+
copy:
30+
- source: ./
31+
destination: /opt/pkgdeploy/fastapi/
32+
user: pkgdeploy
33+
group: pkgdeploy
34+
permissions: 755
35+
- source: .pkgdeploy/nginx.conf
36+
destination: /etc/nginx/conf.d/fastapi.conf
37+
- source: .pkgdeploy/fastapi.socket
38+
destination: /etc/systemd/system/fastapi.socket
39+
- source: .pkgdeploy/fastapi.service
40+
destination: /etc/systemd/system/fastapi.service
41+
42+
after_install: |
43+
rm -f /etc/nginx/conf.d/default.conf
44+
sed -i '/listen 80 default_server/d' /etc/nginx/nginx.conf
45+
systemctl enable --now nginx
46+
nginx -s reload
47+
systemctl enable --now fastapi.socket
48+
49+
after_upgrade: |
50+
nginx -s reload
51+
systemctl daemon-reload
52+
systemctl restart fastapi.socket

.pkgdeploy/fastapi.service

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[Unit]
2+
Description=Basic FastAPI app to show off PKG Deploy
3+
Requires=fastapi.socket
4+
After=network.target fastapi.socket
5+
6+
[Service]
7+
Type=notify
8+
User=pkgdeploy
9+
Group=pkgdeploy
10+
WorkingDirectory=/opt/pkgdeploy/fastapi
11+
ExecStart=/opt/pkgdeploy/fastapi/venv/bin/pipenv run gunicorn main:app -w 4 -k uvicorn.workers.UvicornWorker --bind unix:/var/run/fastapi.sock
12+
ExecReload=/bin/kill -s HUP $MAINPID
13+
KillMode=mixed
14+
TimeoutStopSec=5
15+
PrivateTmp=true
16+
17+
[Install]
18+
WantedBy=multi-user.target

.pkgdeploy/fastapi.socket

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[Unit]
2+
Description=FastAPI gunicorn socket
3+
PartOf=fastapi.service
4+
5+
[Socket]
6+
ListenStream=/var/run/fastapi.sock
7+
User=nginx
8+
9+
[Install]
10+
WantedBy=sockets.target

.pkgdeploy/nginx.conf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
server {
2+
listen 80;
3+
client_max_body_size 4G;
4+
5+
location / {
6+
proxy_set_header Host $http_host;
7+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
8+
proxy_set_header X-Forwarded-Proto $scheme;
9+
proxy_redirect off;
10+
proxy_buffering off;
11+
proxy_pass http://fastapi;
12+
}
13+
}
14+
15+
upstream fastapi {
16+
server unix:/var/run/fastapi.sock;
17+
}

Pipfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[[source]]
2+
url = "https://pypi.python.org/simple"
3+
verify_ssl = true
4+
name = "pypi"
5+
6+
[dev-packages]
7+
8+
[packages]
9+
fastapi = "*"
10+
uvicorn = "*"
11+
gunicorn = "*"
12+
13+
[requires]
14+
python_version = "3.6"

0 commit comments

Comments
 (0)