Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
krak3n committed Oct 8, 2013
0 parents commit 036fe44
Show file tree
Hide file tree
Showing 17 changed files with 309 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.vagrant
.pyc
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM ubuntu:12.04
MAINTAINER Chris Reeves

ADD . /foo

WORKDIR /foo
RUN cd /foo

RUN apt-get install -y python python-dev python-software-properties
RUN apt-get install -y make
RUN apt-get install -y wget
RUN apt-get install -y tar
RUN wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py --no-check-certificate -O - | python
RUN wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py --no-check-certificate -O - | python
RUN make develop

EXPOSE 8080
41 changes: 41 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#
# Generic functions
#

clean_pyc:
find . -name \*.pyc -delete

documentation:
make -C docs clean
make -C docs html

#
# Install for development
#

# Install Development Requirements
install_develop:
./install.sh develop

develop: install_develop

#
# Install for test running
#

# Install Test Requirements
install_test:
./install.sh test

# Test Command
run_tests:
python setup.py test

test: install_test run_tests

#
# Application Related Commands
#

runserver:
python src/foo/run.py
45 changes: 45 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/ruby

#
# Vagrant File for Docker - Requires Vagrant 1.1+
# Provisioner: Salt
# OS: Ubuntu 12.04 LTS 64Bit
#

Vagrant.configure("2") do |config|

# Base Box - http://www.vagrantbox.es/ - Ubuntu 12.04 LTS 64bit
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.ssh.forward_agent = true

# Port Forwarding
config.vm.network :forwarded_port, guest: 4243, host: 4243
(49000..49900).each do |port|
config.vm.network :forwarded_port, :host => port, :guest => port
end

# Virutalbox Settings
config.vm.provider :virtualbox do |v|
# Enables symlinks
v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
end

#
# Mounts
#

config.vm.synced_folder ".", "/foo"
config.vm.synced_folder "./provisioner", "/srv/salt"

#
# Provisioner - Salt
#

config.vm.provision :salt do |salt|
salt.run_highstate = true
salt.minion_config = "provisioner/config/minion.conf"
salt.install_type = "stable"
end

end
8 changes: 8 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

if [ $1 ]
then
pip install -e .[$1]
else
pip install -e .
fi
14 changes: 14 additions & 0 deletions provisioner/config/minion.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#
# Salt Minion Config
#

# Masterless Mode
file_client: local

# File Roots
file_roots:
base:
- /srv/salt/states/

# Renderer
renderer: stateconf yaml . jinja
16 changes: 16 additions & 0 deletions provisioner/states/docker/config.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# docker.config
#
# Docker configuration
#

.docker_service_config:
file:
- managed
- name: /etc/init/docker.conf
- source: salt://docker/files/docker.service.conf
- user: root
- group: root
- mode: 644
- require:
- stateconf: docker.install::goal
9 changes: 9 additions & 0 deletions provisioner/states/docker/dependencies.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# docker.dependencies
#
# Dependencies for installing Docker
#

.python-software-properties:
pkg:
- installed
10 changes: 10 additions & 0 deletions provisioner/states/docker/files/docker.service.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
description "Run docker"

start on filesystem or runlevel [2345]
stop on runlevel [!2345]

respawn

script
/usr/bin/docker -d -H tcp://0.0.0.0:4243
end script
9 changes: 9 additions & 0 deletions provisioner/states/docker/init.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# Docker Salt Module
#

include:
- ..dependencies
- ..install
- ..config
- ..service
32 changes: 32 additions & 0 deletions provisioner/states/docker/install.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#
# docker.install
#
# Installs Docker
#

.docker_repo:
pkgrepo:
- managed
- name: 'deb http://get.docker.io/ubuntu docker main'
- key_url: 'https://get.docker.io/gpg'
- require:
- pkg: .dependencies::python-software-properties

.linux-image-generic-lts-raring:
pkg:
- installed
- require:
- pkgrepo: .docker_repo

.linux-headers-generic-lts-raring:
pkg:
- installed
- require:
- pkgrepo: .docker_repo

.lxc-docker:
pkg:
- installed
- require:
- pkg: .linux-image-generic-lts-raring
- pkg: .linux-headers-generic-lts-raring
17 changes: 17 additions & 0 deletions provisioner/states/docker/service.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# docker.service
#
# Docker Service Management
#

.docker_service:
service:
- running
- name: docker
- enable: True
- reload: True
- watch:
- pkg: .install::lxc-docker
- file: .config::docker_service_config
- require:
- stateconf: docker.config::goal
8 changes: 8 additions & 0 deletions provisioner/states/top.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
# Top SLS File
#

base:

'*':
- docker
65 changes: 65 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/env python

import os
import sys
import multiprocessing # NOQA

from setuptools import setup, find_packages

sys.path.append(
os.path.abspath(os.path.join(os.path.dirname(__file__), 'src')))


def read(fname):
return open(fname).read()


install_requires = [
'flask==0.10.1',
]

test_requires = [
'mock==1.0.1',
'tox==1.4.3',
'nose==1.3',
'coverage==3.6',
'coveralls==0.2',
]

dev_requires = test_requires + [
'pytest==2.3.5',
'pdbpp==0.7',
'ipython==0.13.2',
'flake8==2.0',
]

setup(
name='foo',
version='0.0.1',
author='Christopher John Reeves',
author_email='[email protected]',
url='https://github.com/krak3n/foo.git',
description='Fooythings',
long_description='foo',
package_dir={'': 'src'},
packages=find_packages('src'),
include_package_data=True,
zip_safe=False,
install_requires=install_requires,
test_suite='runtests.runtests',
extras_require={
'test': test_requires,
'develop': dev_requires,
},
classifiers=[
'Environment :: Console',
'Development Status :: 5 - Production/Stable',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Operating System :: Unix',
'License :: OSI Approved :: BSD License',
'Topic :: Software Development',
'Topic :: Software Development :: Libraries :: Python Modules',
],
license='BSD'
)
Empty file added src/foo/__init__.py
Empty file.
Binary file added src/foo/__init__.pyc
Binary file not shown.
16 changes: 16 additions & 0 deletions src/foo/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from flask import Flask
app = Flask(__name__)


@app.route('/')
def hello_world():
return 'Foo All The Things!'


if __name__ == '__main__':
kwargs = {}
kwargs.update({
'host': '0.0.0.0',
'port': 8080
})
app.run(**kwargs)

0 comments on commit 036fe44

Please sign in to comment.