Vagrantfile and provision scripts for development

This commit is contained in:
Kyle Drake 2015-01-31 15:50:12 -08:00
parent 46883b2bdd
commit 9038141e28
16 changed files with 128 additions and 50 deletions

1
.gitignore vendored
View file

@ -31,3 +31,4 @@ files/map.txt
files/sslsites.zip files/sslsites.zip
.tm_properties .tm_properties
./black_box.rb ./black_box.rb
.vagrant

View file

@ -1,4 +1,3 @@
source 'https://code.stripe.com'
source 'https://rubygems.org' source 'https://rubygems.org'
gem 'sinatra' gem 'sinatra'
@ -16,7 +15,7 @@ gem 'mail'
gem 'google-api-client', require: 'google/api_client' gem 'google-api-client', require: 'google/api_client'
gem 'tilt' gem 'tilt'
gem 'erubis' gem 'erubis'
gem 'stripe' gem 'stripe', source: 'https://code.stripe.com/'
gem 'screencap' gem 'screencap'
gem 'cocaine' gem 'cocaine'
gem 'zipruby' gem 'zipruby'
@ -63,7 +62,6 @@ group :test do
gem 'mocha', require: nil gem 'mocha', require: nil
gem 'rake', require: nil gem 'rake', require: nil
gem 'poltergeist' gem 'poltergeist'
gem 'phantomjs', require: 'phantomjs/poltergeist'
gem 'capybara_minitest_spec' gem 'capybara_minitest_spec'
gem 'rack_session_access', require: nil gem 'rack_session_access', require: nil
gem 'webmock', require: nil gem 'webmock', require: nil

View file

@ -1,6 +1,6 @@
GEM GEM
remote: https://code.stripe.com/
remote: https://rubygems.org/ remote: https://rubygems.org/
remote: https://code.stripe.com/
specs: specs:
activesupport (4.1.4) activesupport (4.1.4)
i18n (~> 0.6, >= 0.6.9) i18n (~> 0.6, >= 0.6.9)
@ -246,7 +246,6 @@ DEPENDENCIES
minitest-reporters minitest-reporters
mocha mocha
pg pg
phantomjs
poltergeist poltergeist
pry pry
pry-byebug pry-byebug
@ -271,7 +270,7 @@ DEPENDENCIES
sinatra sinatra
sinatra-flash sinatra-flash
sinatra-xsendfile sinatra-xsendfile
stripe stripe!
stripe-ruby-mock (~> 2.0.1) stripe-ruby-mock (~> 2.0.1)
thread thread
tilt tilt

View file

@ -4,42 +4,23 @@
The web site for NeoCities! It's open source. Want a feature on the site? Send a pull request! The web site for NeoCities! It's open source. Want a feature on the site? Send a pull request!
## Installation (OSX) ## Getting Started
Install homebrew: Neocities can be quickly launched in development mode with (Vagrant)[https://www.vagrantup.com]. Vagrant builds a virtual machine that automatically installs everything you need to run Neocities as a developer. Install Vagrant, then from the command line:
```
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
```
Install deps:
```
$ brew install redis postgresql phantomjs libmagic imagemagick
```
Fork the repository on Github.
Clone the forked repo to your local machine: git clone git@github.com:YOURUSERNAME/neocities.git
Install deps:
``` ```
$ cd neocities vagrant up --provision
$ gem install bundler
$ bundle install
``` ```
Create postgres databases: ![Vagrant takes a while, make a pizza while waiting](http://i.imgur.com/vfIJPXP.png)
``` ```
createdb neocities_test vagrant ssh
createdb neocities_dev cd /vagrant
bundle exec rackup
``` ```
Copy config.yml.template to config.yml. Now you can access the running site from your browser: http://127.0.0.1:9292
Run the tests to see if they work:
```
bundle exec rake test
```
## Want to contribute? ## Want to contribute?

12
Vagrantfile vendored Normal file
View file

@ -0,0 +1,12 @@
VAGRANTFILE_API_VERSION = '2'
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = 'ubuntu/trusty64'
config.vm.provision :shell, path: './vagrant/development.sh'
config.vm.network :forwarded_port, guest: 9292, host: 9292
config.vm.provider :virtualbox do |vb|
vb.customize ['modifyvm', :id, '--memory', '1536']
vb.name = 'neocities'
end
end

View file

@ -1,24 +1,24 @@
development: development:
database: 'postgres://neocities@127.0.0.1/neocities' database: 'postgres://neocities@localhost/neocities'
database_pool: 1 database_pool: 1
session_secret: SECRET GOES HERE session_secret: "SECRET GOES HERE"
recaptcha_public_key: ENTER PUBLIC KEY HERE recaptcha_public_key: "ENTER PUBLIC KEY HERE"
recaptcha_private_key: ENTER PRIVATE KEY HERE recaptcha_private_key: "ENTER PRIVATE KEY HERE"
sidekiq_user: ENTER USER HERE sidekiq_user: "ENTER USER HERE"
sidekiq_pass: ENTER PASS HERE sidekiq_pass: "ENTER PASS HERE"
stripe_publishable_key: fillout stripe_publishable_key: "ENTER KEY HERE"
stripe_api_key: fillout stripe_api_key: "ENTER KEY HERE"
ip_hash_salt: "400$8$1$fc21863da5d531c1" ip_hash_salt: "400$8$1$fc21863da5d531c1"
proxy_pass: 'somethinglongandrandom' proxy_pass: 'somethinglongandrandom'
test: test:
database: 'postgres://neocities@127.0.0.1/neocities_test' database: 'postgres://neocities@localhost/neocities_test'
database_pool: 1 database_pool: 1
session_secret: SECRET GOES HERE session_secret: "SECRET GOES HERE"
recaptcha_public_key: ENTER PUBLIC KEY HERE recaptcha_public_key: "ENTER PUBLIC KEY HERE"
recaptcha_private_key: ENTER PRIVATE KEY HERE recaptcha_private_key: "ENTER PRIVATE KEY HERE"
sidekiq_user: ENTER USER HERE sidekiq_user: "ENTER USER HERE"
sidekiq_pass: ENTER PASS HERE sidekiq_pass: "ENTER PASS HERE"
stripe_publishable_key: fillout stripe_publishable_key: "ENTER KEY HERE"
stripe_api_key: fillout stripe_api_key: "ENTER KEY HERE"
ip_hash_salt: "400$8$1$fc21863da5d531c1" ip_hash_salt: "400$8$1$fc21863da5d531c1"
proxy_pass: 'somethinglongandrandom' proxy_pass: 'somethinglongandrandom'

6
ext/phantomjs.rb Normal file
View file

@ -0,0 +1,6 @@
module Phantomjs
# Workaround for vagrant bug.
def self.path
'/usr/local/bin/phantomjs'
end
end

View file

@ -509,7 +509,7 @@ class Site < Sequel::Model
# clamdscan doesn't work on travis for testing # clamdscan doesn't work on travis for testing
return true if ENV['TRAVIS'] == 'true' return true if ENV['TRAVIS'] == 'true'
File.chmod 0640, uploaded_file[:tempfile].path File.chmod 0666, uploaded_file[:tempfile].path
line = Cocaine::CommandLine.new( line = Cocaine::CommandLine.new(
"clamdscan", "-i --remove=no --no-summary --stdout :path", "clamdscan", "-i --remove=no --no-summary --stdout :path",
expected_outcodes: [0, 1] expected_outcodes: [0, 1]

View file

@ -170,6 +170,7 @@ describe 'api upload' do
post '/api/upload', { post '/api/upload', {
'' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg') '' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
} }
res[:error_type].must_equal 'missing_files' res[:error_type].must_equal 'missing_files'
end end

23
vagrant/common.sh Normal file
View file

@ -0,0 +1,23 @@
# Quiets the TTY error message
#sed -i 's/^mesg n$/tty -s \&\& mesg n/g' /root/.profile
DEBIAN_FRONTEND=noninteractive
apt-get -y update
apt-get -y upgrade
apt-get install -y openntpd htop autossh sshfs vim
echo 'UTC' | tee /etc/timezone
dpkg-reconfigure -f noninteractive tzdata
update-alternatives --set editor /usr/bin/vim.basic
ufw allow ssh
ufw --force enable
ufw logging off
sed -i 's|[#]*PasswordAuthentication yes|PasswordAuthentication no|g' /etc/ssh/sshd_config
sed -i 's|UsePAM yes|UsePAM no|g' /etc/ssh/sshd_config
#sed -i 's|[#]*PermitRootLogin yes|PermitRootLogin no|g' /etc/ssh/sshd_config
service ssh restart

5
vagrant/database.sh Normal file
View file

@ -0,0 +1,5 @@
#!/bin/bash
DEBIAN_FRONTEND=noninteractive
apt-get -y install postgresql postgresql-contrib libpq-dev

13
vagrant/development.sh Normal file
View file

@ -0,0 +1,13 @@
#!/bin/bash
DEBIAN_FRONTEND=noninteractive
. /vagrant/vagrant/common.sh
. /vagrant/vagrant/database.sh
. /vagrant/vagrant/ruby.sh
. /vagrant/vagrant/webapp.sh
ufw allow 9292
sudo su postgres -c "createuser -d vagrant"
sudo su vagrant -c "createdb neocities"
sudo su vagrant -c "createdb neocities_test"

7
vagrant/phantomjs.sh Normal file
View file

@ -0,0 +1,7 @@
#!/bin/bash
DEBIAN_FRONTEND=noninteractive
wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-x86_64.tar.bz2
bzip2 -dc phantomjs-1.9.8-linux-x86_64.tar.bz2 | tar xf -
cp phantomjs-1.9.8-linux-x86_64/bin/phantomjs /usr/local/bin/

6
vagrant/redis.sh Normal file
View file

@ -0,0 +1,6 @@
apt-get install -y redis-server
#sed -i 's|[#]*appendfsync everysec|appendfsync always|g' /etc/redis/redis.conf
sed -i 's|[#]*appendonly no|appendonly yes|g' /etc/redis/redis.conf
service redis-server restart

7
vagrant/ruby.sh Normal file
View file

@ -0,0 +1,7 @@
#!/bin/bash
apt-get -y install python-software-properties
apt-add-repository -y ppa:brightbox/ruby-ng
apt-get -y update
apt-get -y install ruby2.2 ruby2.2-dev
gem install bundler --no-rdoc --no-ri

19
vagrant/webapp.sh Normal file
View file

@ -0,0 +1,19 @@
#!/bin/bash
DEBIAN_FRONTEND=noninteractive
. /vagrant/vagrant/phantomjs.sh
. /vagrant/vagrant/redis.sh
apt-get install -y git curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev libffi-dev libpq-dev libmagickwand-dev imagemagick libmagickwand-dev libmagic-dev file clamav-daemon
sed -i 's|[#]*DetectPUA false|DetectPUA true|g' /etc/clamav/clamd.conf
freshclam
service clamav-freshclam start
service clamav-daemon start
usermod -G vagrant clamav
cd /vagrant
bundle install