Leave these fields empty (spam trap):
Name
You can leave this blank to post anonymously, or you can create a Tripcode by using the format Name#Password
Comment
[i]Italic Text[/i]
[b]Bold Text[/b]
[spoiler]Spoiler Text[/spoiler]
>Highlight/Quote Text
[pre]Preformatted & Monospace Text[/pre]
[super]Superset Text[/super]
[sub]Subset Text[/sub]
1. Numbered lists become ordered lists
* Bulleted lists become unordered lists
File

Sandwich


How do you deploy your python flask/django/whatever apps?

Reply
- Tue, 06 Dec 2016 11:57:07 EST gEtE4wNA No.36353
File: 1481043427275.png -(19604B / 19.14KB, 570x360) Thumbnail displayed, click image for full size. How do you deploy your python flask/django/whatever apps?
Right now, I spin up an EC2 instance, create a new user, install pip and virtualenvwrapper on it, make a virtualenv for my app, put environment variables in postactive, make an ssh key for the user, git push the code, pip install dependencies, create supervisord config file to run gunicorn in virtualenv (and celery or whatever if needed), configure nginx to forward gunicorn, then pray that I didn't forget a step.
I've been playing around with scripts and git hooks to automate some of the process, but I'm also looking around for existing deployment solutions.

Ideally I would just like to spin up a server from a template and be able to push the code up and get it up and running.

Heroku does this beautifully, but too expensive if you need more than a single hobby dyno.

How do you do it?
>>
Oliver Cirringwot - Tue, 06 Dec 2016 16:53:24 EST xZVBmzCD No.36354 Reply
I don't, but there's Ansible, Chef, Puppet, a bunch of things to choose from. I think Salt is the pythonic solution du jour.
>>
David Favingstone - Wed, 07 Dec 2016 10:55:38 EST gEtE4wNA No.36355 Reply
>>36354
Definitely lots of options out there. I'm reading up on Salt right now, also Fabric.
I found this tutorial which is very similar to my deployment method, and the author links to a fab script to automate the process. https://github.com/realpython/flask-deploy

Looks like it gives you a lot of control over the process, since you're just writing a python script rather than filling out a config file. I've started using cookiecutter-flask for my latest project, so I might be able to include template supervisor/nginx/etc config files and a fab file in my project template.

I've been working from the mindset that I'm gonna need ssh access to the application user, so I was wondering how I would automatically generate a key-pair for it and copy the private key to my machine, since I won't have ssh access to it until I have the key.
But maybe I don't even need it, I'll always have a key for the admin user so I might just keep the git repo under admin's home and use the post-receive to set the work tree to app user's folder.

eh
>>
Jenny Honeycocke - Wed, 07 Dec 2016 18:02:26 EST uXHlOpBk No.36356 Reply
>>36355
Configuration is one of those things where the short path to the best practice is finding the right thing to copy/paste from.
>>
Edward Fubberlock - Fri, 09 Dec 2016 13:24:32 EST 9QSfnS0r No.36357 Reply
learn to use docker-compose, there probably is a ready made yaml file for flask,nginx,mysql, etc..
Has the advantage of being able to use the same tools in production and development, no need for virtualenv.
The only issue are unattended updates/updates in general but you can migrate that if you choose base images which are regulary updated and write your dockerfiles in a way that you can rebuild you images in production.

Report Post
Reason
Note
Please be descriptive with report notes,
this helps staff resolve issues quicker.