Code Monkey home page Code Monkey logo

pypaas's Introduction

Code Issues

Installation

pyPaaS has a few dependencies we need to install first:

root@host$ apt-get install build-essential python3.4-dev python3-pip virtualenv libyaml-dev daemontools daemontools-run git rsync

pyPaaS needs a normal user to work. This will be the user you use to git push to. Let's create one:

root@host:~$ adduser --disabled-password deploy
Adding user `deploy' ...
Adding new group `deploy' (1002) ...
Adding new user `deploy' (1002) with group `deploy' ...
The home directory `/home/deploy' already exists.  Not copying from `/etc/skel'.
Changing the user information for deploy
Enter the new value, or press ENTER for the default
    Full Name []: pyPaaS
    Room Number []:
    Work Phone []:
    Home Phone []:
    Other []:
Is the information correct? [Y/n] Y

We can now grab the code and configure a virtualenv!

root@host:~$ su deploy
deploy@host:/root$ cd ~
deploy@host:~$ # For production usage:
deploy@host:~$ git clone https://github.com/fintura/pyPaaS.git
deploy@host:~$ # For development:
deploy@host:~$ ln -s <WHEREEVER YOUR CHECKOUT IS> pyPaaS
deploy@host:~$ virtualenv --python=python3.4 venv
Running virtualenv with interpreter /usr/bin/python3.4
Using base prefix '/usr'
New python executable in venv/bin/python3.4
Also creating executable in venv/bin/python
Installing setuptools, pip...done.
deploy@host:~$ venv/bin/pip install -e pyPaaS/

Create configuration and .ssh directories

deploy@host:~$ mkdir -p ~/config/domains ~/config/repos ~/.ssh/authorized_keys.d
deploy@host:~$ chmod 700 ~/.ssh

To run stuff we need to configure daemontools

root@host:~$ mkdir /etc/service/pyPaaS
root@host:~$ cp ~deploy/pyPaaS/daemontools-run /etc/service/pyPaaS/run.new
root@host:~$ chmod 755 /etc/service/pyPaaS/run.new
root@host:~$ mv /etc/service/pyPaaS/run.new /etc/service/pyPaaS/run

Now add your configuration in ~deploy/config, your SSH public keys in ~deploy/.ssh/authorized_keys.d and run /home/deploy/venv/bin/pypaas rebuild_authorized_keys as deploy to assemble the actual authorized_keys file.

That's it :).

Configuration

See example-configuration for a heavily commented configuration example. You can put your configuration either in ~deploy/config or /etc/pypaas. pyPaas uses the first directory of the ones listed above with a pypaas.yml file as it's configuration directory. Like all pyPaaS configuration it uses YAML syntax.

Quickstart

We'll use the example configuration in example-configuration to deploy the heroku node.js sample application. Just copy the contents of example-configuration into either ~deploy/config or /etc/pypaas and make it (at least) readable to the deploy user.

The configuration has a simple structure:

  • all global configuration goes into pypaas.yml
  • configuration for a repo goes into repos/<repo_name>.yml
  • configuration for a domain goes into domains/<domain_name>.yml

You can have one repository serve any number of domains and vice versa.

Now all that's left to do before your first deploy is adding ssh public keys. pyPaaS expects them in ~deploy/.ssh/authorized_keys.d/. The ~deploy/.ssh/authorized_keys is generated by running ~deploy/venv/bin/pypaas rebuild_authorized_keys as deploy.

Let's deploy the node.js sample app:

you@your-machine:~$ git clone https://github.com/heroku/node-js-sample
you@your-machine:~$ cd node-js-sample
you@your-machine:~$ cat > .build.sh <<EOF
#!/bin/bash
npm install
EOF
you@your-machine:~$ chmod +x .build.sh
you@your-machine:~$ git add .build.sh && git commit -m "add build script"
you@your-machine:~$ git push deploy@your-server:node-js-sample

Now watch it build and start this application and that's it :).

pypaas's People

Contributors

autoit4you avatar jensgutermuth avatar mortzu avatar

Watchers

 avatar  avatar

Forkers

autoit4you

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.