Giter Site home page Giter Site logo

mon-ius / flask-deploy Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 34 KB

A simple script for deploying flask apps with Nginx, PostgreSQL , HTTPS and Systemd Daemon.

License: MIT License

Shell 1.75% Python 98.25%
flask flask-application python nginx uwsgi-nginx https docker systemd postgresql greenlet

flask-deploy's Introduction

flask-deploy

A simple scripts for deploying flask apps with Nginx, PostgreSQL , HTTPS and Systemd Daemon.

Install

Using pip

pip install flask-deploy

Usage

Deploy on current directory

change directory to your flask project

flask-deploy or fd

Principle and Variable

  • usr : current user on Linux
    • root
  • domain : domain name of the site
    • xx.flask.org
  • env : root location of the project
    • exampleProject/
  • loc : location of directory storing the config files
    • exampleProject/xx.flask.org/

Features

DNS support

  • cloudflare
  • aliyun

Server support

  • NGINX
  • Caddy(Future)

MiddleWare support

  • uSWGI
  • gevent
  • gunicorn(Future)

Docker support

  • PostgreSQL DataBase

System Service

  • Systemd(Linux)

Assumptions

  • You're user : www
  • You have experience with Linux

requirements

Assumed you have these following conditions.

OutSide

  • server

    • example : centos

    • ip address :

  • domain

    • example : www.example.com
  • DNS

    • redirect =>

Software and enviroment

  • git
  • wget
  • curl
  • Nginx
  • docker-ce
  • Anaconda3
  • Python3.6+
  • uWSGI
  • Gevnet

Start

Following these steps, then select things you want. All of things will be generated.

  • create a user (For example : www)
  • Switch to python virtual env
  • python init.py

Then change to ROOT or sudoer with following things.

Get SSL

  • Run sudo ./domain.sh

It will generate the certifications(.cer,.key) for your project if you first run it.

Configure nginx for FLASK Application

  • sudo mv ./domain.conf /etc/nginx/sites-enabled

It will add the configuration file to NGINX for your project if you first run it.

Run FLASK Application as Systemd Daemon

  • sudo mv ./domain.service /etc/systemd/system

  • sudo systemctl enable domain

  • sudo systemctl start domain

It will add the service file to Systemd and make your project run as system service if you first run it.

Then you could manage it by:

  • sudo systemctl stop domain

  • sudo systemctl restart domain

Attention

Ubuntu 18.x

  • docker-ce install

sudo apt install apt-transport-https ca-certificates curl software-properties-common curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable" sudo apt install docker-ce

Options

Anaconda environment

Suppose location : /opt/anaconda3

Anaconda setup

  • conda create -n deploy python=3.6
  • conda activate deploy
  • conda install -c conda-forge gevent
  • conda install -c conda-forge uwsgi

Update

  • Version 0.3 Feb 17,2019

    • add new dns ssl generation: aliyun
    • add separate test folder
    • add number validation
    • change logic -> <domain,dns_options,docker> <OP1,OP2>
  • Version 0.4 March 18,2019

    • keep environment variable use sudo -E
    • keep python global variable use duplicate code

MIT License

Copyright (c) 2018 Monius

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

flask-deploy's People

Contributors

mon-ius avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.