Skip to content

Auto Deploy

TenteEEEE edited this page Oct 7, 2019 · 3 revisions

Here I show a way for deploying the pantie patch server on your server.

See and install github_webhook.
<Your directory>ppds.py

from github_webhook import Webhook
from flask import Flask
import subprocess

app = Flask(__name__)
webhook = Webhook(app)

@app.route("/")
def index():
    return "Github Webhook Server"

@webhook.hook()
def on_push(data):
    print("Got push with: {0}".format(data))
    subprocess.Popen(['bash', '<Your directory>/deploy.sh'])

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=<specified port>)

<Your directory>deploy.sh

cd /var/tmp
git clone https://github.com/TenteEEEE/quiche_pantie_patch.git --depth 1
docker build -t pantie_patch:latest ./quiche_pantie_patch
docker image prune -f
cd <Your directory>
docker-compose up -d

<Your directory>docker-compose.yml

version: "3"
services:
  pantie_patch:
    image: pantie_patch:latest
    hostname: pantie_patch
    ports:
      - "9999:5000"
    volumes:
      - /media/pantie-patch/converted:/quiche_pantie_patch/converted:cached
      - /media/pantie-patch/logs:/quiche_pantie_patch/logs:cached
    command: bash -c "git pull ; python3 update_all.py & gunicorn --bind 0.0.0.0:5000 restapi:app"

/etc/systemd/system/ppds.service

[Unit]
Description = Pantie Patch Deploy Server

[Service]
WorkingDirectory = <Your directory>
ExecStart = <your gunicorn> -b 0.0.0.0:<specified port> ppds:app --chdir <Your directory>
ExecStop = /bin/kill -s TERM $MAINPID
Type = simple
Restart = always

[Install]
WantedBy=multi-user.target

sudo systemctl daemon-reload && sudo systemctl enable ppds.service