Commit 5933dd60 authored by James Allen's avatar James Allen
Browse files

Create Vagrant + Chef config for setting up ShareLaTeX

parent 55b9ac7d
......@@ -14,3 +14,5 @@ user_files
template_files
db.sqlite
.vagrant
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu-12.04"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.network :forwarded_port, guest: 3000, host: 3000
config.ssh.forward_agent = true
config.vm.provider "virtualbox" do |v|
v.memory = 1024
end
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = "chef/cookbooks"
chef.add_recipe 'redis-server'
chef.add_recipe 'mongodb'
chef.add_recipe 'nodejs'
chef.add_recipe 'sharelatex'
# You may also specify custom JSON attributes:
chef.json = {}
end
# Enable provisioning with chef server, specifying the chef server URL,
# and the path to the validation key (relative to this Vagrantfile).
#
# The Opscode Platform uses HTTPS. Substitute your organization for
# ORGNAME in the URL and validation key.
#
# If you have your own Chef Server, use the appropriate URL, which may be
# HTTP instead of HTTPS depending on your configuration. Also change the
# validation key to validation.pem.
#
# config.vm.provision :chef_client do |chef|
# chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
# chef.validation_key_path = "ORGNAME-validator.pem"
# end
#
# If you're using the Opscode platform, your validator client is
# ORGNAME-validator, replacing ORGNAME with your organization name.
#
# If you have your own Chef Server, the default validation client name is
# chef-validator, unless you changed the configuration.
#
# chef.validation_client_name = "ORGNAME-validator"
end
current_dir = File.dirname(__FILE__)
cookbook_path ["#{current_dir}/../cookbooks"]
# CHANGELOG for mongodb
This file is used to list changes made in each version of mongodb.
## 0.1.0:
* Initial release of mongodb
- - -
Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown.
The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown.
mongodb Cookbook
================
TODO: Enter the cookbook description here.
e.g.
This cookbook makes your favorite breakfast sandwhich.
Requirements
------------
TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc.
e.g.
#### packages
- `toaster` - mongodb needs toaster to brown your bagel.
Attributes
----------
TODO: List you cookbook attributes here.
e.g.
#### mongodb::default
<table>
<tr>
<th>Key</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
<tr>
<td><tt>['mongodb']['bacon']</tt></td>
<td>Boolean</td>
<td>whether to include bacon</td>
<td><tt>true</tt></td>
</tr>
</table>
Usage
-----
#### mongodb::default
TODO: Write usage instructions for each cookbook.
e.g.
Just include `mongodb` in your node's `run_list`:
```json
{
"name":"my_node",
"run_list": [
"recipe[mongodb]"
]
}
```
Contributing
------------
TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section.
e.g.
1. Fork the repository on Github
2. Create a named feature branch (like `add_component_x`)
3. Write you change
4. Write tests for your change (if applicable)
5. Run the tests, ensuring they all pass
6. Submit a Pull Request using Github
License and Authors
-------------------
Authors: TODO: List authors
name 'mongodb'
maintainer 'ShareLaTeX'
maintainer_email 'team@sharelatex.com'
license 'AGPLv3'
description 'Installs/Configures mongodb'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.1.0'
depends 'apt'
#
# Cookbook Name:: mongodb
# Recipe:: default
#
# Copyright 2014, ShareLaTeX
#
# See http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/
apt_repository 'mongodb-10gen' do
uri 'http://downloads-distro.mongodb.org/repo/ubuntu-upstart'
distribution 'dist'
components ['10gen']
keyserver 'keyserver.ubuntu.com'
key '7F0CEB10'
end
package 'mongodb-10gen' do
action :install
end
\ No newline at end of file
# CHANGELOG for nodejs
This file is used to list changes made in each version of nodejs.
## 0.1.0:
* Initial release of nodejs
- - -
Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown.
The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown.
nodejs Cookbook
===============
TODO: Enter the cookbook description here.
e.g.
This cookbook makes your favorite breakfast sandwhich.
Requirements
------------
TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc.
e.g.
#### packages
- `toaster` - nodejs needs toaster to brown your bagel.
Attributes
----------
TODO: List you cookbook attributes here.
e.g.
#### nodejs::default
<table>
<tr>
<th>Key</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
<tr>
<td><tt>['nodejs']['bacon']</tt></td>
<td>Boolean</td>
<td>whether to include bacon</td>
<td><tt>true</tt></td>
</tr>
</table>
Usage
-----
#### nodejs::default
TODO: Write usage instructions for each cookbook.
e.g.
Just include `nodejs` in your node's `run_list`:
```json
{
"name":"my_node",
"run_list": [
"recipe[nodejs]"
]
}
```
Contributing
------------
TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section.
e.g.
1. Fork the repository on Github
2. Create a named feature branch (like `add_component_x`)
3. Write you change
4. Write tests for your change (if applicable)
5. Run the tests, ensuring they all pass
6. Submit a Pull Request using Github
License and Authors
-------------------
Authors: TODO: List authors
name 'nodejs'
maintainer 'YOUR_COMPANY_NAME'
maintainer_email 'YOUR_EMAIL'
license 'AGPLv3'
description 'Installs/Configures nodejs'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.1.0'
depends 'apt'
#
# Cookbook Name:: nodejs
# Recipe:: default
#
# Copyright 2014, ShareLaTeX
#
# See https://launchpad.net/~chris-lea/+archive/nodejs
apt_repository 'node.js' do
uri 'http://ppa.launchpad.net/chris-lea/node.js/ubuntu'
distribution node['lsb']['codename']
components ['main']
keyserver 'keyserver.ubuntu.com'
key 'C7917B12'
end
package 'nodejs' do
action :install
end
execute 'install grunt' do
command "npm install -g grunt-cli"
not_if "npm --no-color -g ls 'grunt-cli' 2> /dev/null | grep 'grunt-cli'"
end
\ No newline at end of file
# CHANGELOG for redis
This file is used to list changes made in each version of redis.
## 0.1.0:
* Initial release of redis
- - -
Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown.
The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown.
redis Cookbook
==============
TODO: Enter the cookbook description here.
e.g.
This cookbook makes your favorite breakfast sandwhich.
Requirements
------------
TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc.
e.g.
#### packages
- `toaster` - redis needs toaster to brown your bagel.
Attributes
----------
TODO: List you cookbook attributes here.
e.g.
#### redis::default
<table>
<tr>
<th>Key</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
<tr>
<td><tt>['redis']['bacon']</tt></td>
<td>Boolean</td>
<td>whether to include bacon</td>
<td><tt>true</tt></td>
</tr>
</table>
Usage
-----
#### redis::default
TODO: Write usage instructions for each cookbook.
e.g.
Just include `redis` in your node's `run_list`:
```json
{
"name":"my_node",
"run_list": [
"recipe[redis]"
]
}
```
Contributing
------------
TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section.
e.g.
1. Fork the repository on Github
2. Create a named feature branch (like `add_component_x`)
3. Write you change
4. Write tests for your change (if applicable)
5. Run the tests, ensuring they all pass
6. Submit a Pull Request using Github
License and Authors
-------------------
Authors: TODO: List authors
name 'redis-server'
maintainer 'ShareLaTeX'
maintainer_email 'team@sharelatex.com'
license 'AGPLv3'
description 'Installs/Configures redis-server'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.1.0'
depends 'apt'
#
# Cookbook Name:: redis
# Recipe:: default
#
# Copyright 2014, ShareLaTeX
#
# See https://launchpad.net/~chris-lea/+archive/redis-server
apt_repository 'redis-server' do
uri 'http://ppa.launchpad.net/chris-lea/redis-server/ubuntu'
distribution node['lsb']['codename']
components ['main']
keyserver 'keyserver.ubuntu.com'
key 'C7917B12'
end
package 'redis-server' do
action :upgrade
options "--force-yes"
end
\ No newline at end of file
# CHANGELOG for sharelatex
This file is used to list changes made in each version of sharelatex.
## 0.1.0:
* Initial release of sharelatex
- - -
Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown.
The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown.
sharelatex Cookbook
===================
TODO: Enter the cookbook description here.
e.g.
This cookbook makes your favorite breakfast sandwhich.
Requirements
------------
TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc.
e.g.
#### packages
- `toaster` - sharelatex needs toaster to brown your bagel.
Attributes
----------
TODO: List you cookbook attributes here.
e.g.
#### sharelatex::default
<table>
<tr>
<th>Key</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
<tr>
<td><tt>['sharelatex']['bacon']</tt></td>
<td>Boolean</td>
<td>whether to include bacon</td>
<td><tt>true</tt></td>
</tr>
</table>
Usage
-----
#### sharelatex::default
TODO: Write usage instructions for each cookbook.
e.g.
Just include `sharelatex` in your node's `run_list`:
```json
{
"name":"my_node",
"run_list": [
"recipe[sharelatex]"
]
}
```
Contributing
------------
TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section.
e.g.
1. Fork the repository on Github
2. Create a named feature branch (like `add_component_x`)
3. Write you change
4. Write tests for your change (if applicable)
5. Run the tests, ensuring they all pass
6. Submit a Pull Request using Github
License and Authors
-------------------
Authors: TODO: List authors
name 'sharelatex'
maintainer 'YOUR_COMPANY_NAME'
maintainer_email 'YOUR_EMAIL'
license 'All rights reserved'
description 'Installs/Configures sharelatex'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.1.0'
action :start do
package "git"
package "build-essential"
r = new_resource
deploy_to = "/var/www/" + r.name
node_environment = "production"
directory deploy_to do
user r.user if r.user
recursive true
end
env = {
"HOME" => deploy_to
}
directory "#{deploy_to}/releases" do
user r.user if r.user
recursive true
end
shared_dir = "#{deploy_to}/shared"
directory shared_dir do
user r.user if r.user
recursive true
end
directory "#{shared_dir}/config" do
user r.user if r.user
recursive true
end
directory "#{shared_dir}/log" do
user r.user if r.user
recursive true
end
deploy_revision deploy_to do
repository r.repository
revision r.revision
user r.user if r.user
purge_before_symlink [
"log", "config", "node_modules"
]
create_dirs_before_symlink []
symlinks({
"log" => "log",
"config" => "config"
})
symlink_before_migrate({
"node_modules" => "node_modules"
})
environment env
migrate true
migration_command "npm install; grunt install"
before_migrate do
directory "#{deploy_to}/shared/node_modules" do
user r.user if r.user
recursive true
end
end
#notifies :restart, "service[#{r.name}]"
end
file "/etc/init/#{r.name}.conf" do
content <<-EOS
description "#{r.name}"
author "ShareLaTeX <team@sharelatex.com>"
start on started mountall
stop on shutdown
respawn
limit nofile 8192 8192
script
echo $$ > /var/run/#{r.name}.pid
chdir #{deploy_to}/current
exec sudo -u #{r.user} env NODE_ENV=#{node_environment} SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee node app.js >> log/production.log
end script
EOS
end
service "#{r.name}" do
provider Chef::Provider::Service::Upstart
action :start
end
file "/etc/logrotate.d/#{r.name}" do
content <<-EOS
#{deploy_to}/shared/log/*.log {
rotate 7
size 5M
missingok
compress
copytruncate
}
EOS
end
end
\ No newline at end of file
#
# Cookbook Name:: sharelatex
# Recipe:: default
#
# Copyright 2014, ShareLaTeX
#
directory "/etc/sharelatex"
template "/etc/sharelatex/settings.coffee" do
mode 0400
user "www-data"
end
sharelatex_app "web-sharelatex" do