Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
powellc committed Apr 16, 2016
0 parents commit e555170
Show file tree
Hide file tree
Showing 96 changed files with 17,285 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Created by http://www.gitignore.io

### Django ###
*.log
*.pot
*.pyc
local_settings.py

### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

# C extensions
*.so

# Distribution / packaging
.Python
env/
bin/
build/
develop-eggs/
dist/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml

# Translations
*.mo

# Mr Developer
.mr.developer.cfg
.project
.pydevproject

# Rope
.ropeproject

# Django stuff:
*.log
*.pot

# Sphinx documentation
docs/_build/

venv
*.sqlite3
.vagrant
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

language: python
python:
- "2.7"
sudo: false

install:
- "python setup.py install"

script: "python manage.py test"
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Changelog
=========

v2.0.1
------

* Fix Travis build testing

v2.0.0
------

* Upgrade to Django 1.8
* Add django rest framework to default kit
* Change out the base templates to use materialize and no framework by default

v1.0.2
------

* Adding a placeholder file so we create a static directory
* Fixing makefile so renaming works on Macs

v1.0.1
------

* Adding a license file
* Adding a default custom user model
* Including travis badge in project by default
* Cleaning up requirements file

v1.0.0
------

* Initial release
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM ubuntu:14.04
MAINTAINER Colin Powell "[email protected]"
RUN apt-get -qq update
RUN apt-get install -y python-dev python-setuptools git
RUN easy_install pip
RUN pip install virtualenv
RUN pip install uwsgi
RUN virtualenv --no-site-packages /opt/ve/wheresyourtrash
ADD . /opt/apps/wheresyourtrash
ADD etc/gunicorn.conf /opt/gunicorn_wheresyourtrash.conf
ADD etc/run.sh /usr/local/bin/run_wheresyourtrash
RUN (cd /opt/apps/wheresyourtrash && git remote rm origin)
RUN (cd /opt/apps/wheresyourtrash && git remote add origin https://github.com/powellc/wheresyourtrash.git)
RUN (cd /opt/apps/wheresyourtrash && python setup.py install)
EXPOSE 30321
CMD ["/bin/sh", "-e", "/usr/local/bin/run_wheresyourtrash"]
25 changes: 25 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Copyright (c) 2014, One Cardinal dba
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the copyright owner nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include README.md
recursive-include wheresyourtrash/static *
recursive-include wheresyourtrash/templates *
recursive-include wheresyourtrash/apps *
31 changes: 31 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
install:
virtualenv venv
venv/bin/python setup.py install
venv/bin/python manage.py syncdb --noinput


deps:
sudo apt-get install libtiff5-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python-tk
npm install bower


deps_mac:
brew install libtiff libjpeg webp little-cms2


test:
rm -rf .tox
detox

clean:
rm -rf venv

run:
venv/bin/python manage.py runserver_plus 0.0.0.0:45000

rename:
find . -maxdepth 1 -type f \( ! -iname "Makefile" \) -print0 | xargs -0 sed -i 's/outline/$(name)/g'
find outline -maxdepth 1 -type f -print0 | xargs -0 sed -i 's/outline/$(name)/g'
mv outline/manage_outline.py outline/manage_$(name).py
mv outline $(name)
echo "Great, you're all set! Well, you'll probably want to adjust the setup file by hand a bit."
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
Django Outline
==============
[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/powellc/wheresyourtrash?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

[![Build
Status](https://travis-ci.org/powellc/wheresyourtrash.svg?branch=master)](https://travis-ci.org/powellc/wheresyourtrash)

In the spirit of [playdoh](https://github.com/mozilla/playdoh), this project
aims to provide a base Django app full of best-practices and pre-installed
applications.

It also includes a rudimentary makefile that helps get things started and
also plays nice with setuptools. That means you can actually use the
standard python setup method of installation, giving you a command line
tool to run the server.

All production settings should be handled via the environment, which
means you can leave the app installed in your python library and just
use the cli tool. More exmaples of this to follow.

Start your engines, err projects!
---------------------------------

Your first order of business is to rename some things. Unless your project
is also called wheresyourtrash, you'll likely want to rename things. The easiest way
to get started is:

make name="<myproject_name>" rename

That should do all the important replacements. The final step will be removing
the .git folder and initializing your own repository and lastly tweaking the
setup.py file, else you're likely to give me credit for your project and to
provide a pretty terribly confusing description to PyPI if your project ever
lands there.

Easy bootstrapping!
-------------------

Powered by the ubiquitous Makefile ... this should be pretty easy:

1. make install
2. make run
3. open your browser to: http://127.0.0.1:45000


Libraries, libraries, libraries!
-----------------------------

Of course, we could provide a vagrant file and a provisoner and all
that jazz. But I'd rather provide a make file for installing everything
into a venv and let you muck about with libraries. Those of you on
Linux shouldn't have too much trouble installing the requisite development
libraries below. The names are for debian-based distros, but they
exist for all major distros.

On Mac it may be a little tricker. Homebrew will get you quite far, but
first you have to install the bloated XCode and the CLI tools.

The libraries are:

* libmemcached-dev
* libfreetype6-dev
* libjpeg-dev

17 changes: 17 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant::Config.run do |config|
config.vm.box = "ubuntu/trusty64"

config.vm.customize ["modifyvm", :id, "--memory", 512]
config.vm.forward_port 80, 8000
config.vm.network :hostonly, '11.0.0.8' # Update the fabfile.py if you update this

config.vm.share_folder("vagrant-root", "/vagrant", ".", :nfs => true)
config.vm.provision :ansible do |ansible|
ansible.playbook = "ansible/vagrant.yml"
ansible.inventory_path = "ansible/hosts"
ansible.verbose = "v"
end
end
14 changes: 14 additions & 0 deletions ansible/all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
- hosts: all
gather_facts: True
user: root
sudo: True
roles:
- role: common
- role: postgresql
- role: nodejs
- role: nginx
- role: django

tasks:
- include: roles/django/tasks/deploy.yml
15 changes: 15 additions & 0 deletions ansible/host_vars/11.0.0.8
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
server: outline.com
domainname: outline.com
mode: Dev
deployment_name: outline
locale: en_US.UTF-8
timezone: America/New_York
project_repo: [email protected]:powellc/outline.git
branch: master
dbpass: password
port_number: 30000
postgis: False
bower: True
sentry_key: None
secret_key: ThisIsNotASecret
13 changes: 13 additions & 0 deletions ansible/host_vars/staging.example.com
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
server: staging.example.com
domainname: example.com
mode: Stage
deployment_name: outline
locale: en_US.UTF-8
timezone: America/New_York
port_number: 45001
project_repo: http://github.com/powellc/ouline.git
branch: master
dbpass: lkjxz;vkjsdaijlaksjdl;kj3
postgis: False
secret_key: LKJSDAELKJELFJKSOIJLPJPWEFLJSDFJEFKJE-EFKJDFXFJJ
14 changes: 14 additions & 0 deletions ansible/host_vars/www.example.com
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
server: www.example.com
domainname: example.me
mode: Prod
deployment_name: outline
locale: en_US.UTF-8
timezone: America/New_York
port_number: 45000
project_repo: [email protected]:powellc/outline.git
branch: master
dbpassword: jzxovijlsakdfj0ojookfjl32k3jrl
postgis: False
bower: False
secret_key: ALKJSDFLKXJCOVIJSELKJFEWLKJSLDFKJLEKJ-KLEJWLFEKJ
8 changes: 8 additions & 0 deletions ansible/hosts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[production]
www.example.com

[staging]
staging.example.com

[default]
11.0.0.8
17 changes: 17 additions & 0 deletions ansible/roles/celery/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
- name: Install celery supervisor configuration file.
template: src=celeryd.conf.j2 dest=/etc/supervisor/conf.d/celeryd_${deployment_name}.conf
register: supervisor_conf
tags:
- celery

- name: Install celerybeat supervisor configuration file.
template: src=celerybeat.conf.j2 dest=/etc/supervisor/conf.d/celerybeat_${deployment_name}.conf
register: supervisor_conf
tags:
- celery

- name: restart supervisor
service: name=supervisor state=restarted
sudo_user: root
when: supervisor_conf.changed
10 changes: 10 additions & 0 deletions ansible/roles/celery/templates/celerybeat.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[program:celerybeat_{{ deployment_name }}]
command=/var/www/vhosts/{{ deployment_name }}/venv/bin/python /var/www/vhosts/{{ deployment_name }}/code/manage.py celerybeat --loglevel=INFO
directory=/var/www/vhosts/{{ deployment_name }}/code
user={{ deployment_name }}
numprocs=1
stdout_logfile=/var/www/vhosts/{{ deployment_name }}/logs/celerybeat.log
stderr_logfile=/var/www/vhosts/{{ deployment_name }}/logs/celerybeat.log
autostart=true
autorestart=true
startsecs=10
14 changes: 14 additions & 0 deletions ansible/roles/celery/templates/supervisor.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[program:celery_{{ deployment_name }}]
command=/var/www/vhosts/{{ deployment_name }}/venv/bin/python /var/www/vhosts/{{ deployment_name }}/code/manage.py celeryd --loglevel=INFO
directory=/var/www/vhosts/{{ deployment_name }}/code
user={{ deployment_name }}
numprocs=1
stdout_logfile=/var/www/vhosts/{{ deployment_name }}/logs/celeryd.log
stderr_logfile=/var/www/vhosts/{{ deployment_name }}/logs/celeryd.log
autostart=true
autorestart=true
startsecs=10

; Need to wait for currently executing tasks to finish at shutdown.
; Increase this if you have very long running tasks.
stopwaitsecs = 600
Empty file.
5 changes: 5 additions & 0 deletions ansible/roles/common/tasks/info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- name: Gather our facts
template: src=info.html dest=/tmp/info.${deployment_name}.html
tags:
- info
Loading

0 comments on commit e555170

Please sign in to comment.