Skip to content
This repository has been archived by the owner on May 25, 2021. It is now read-only.

Commit

Permalink
Merge pull request #196 from YACS-RCOS/staging
Browse files Browse the repository at this point in the history
Merge Yacs on Docker into Master for release.
  • Loading branch information
Bad-Science committed Jan 7, 2017
2 parents a547a0d + 7c3b5d4 commit 667601d
Show file tree
Hide file tree
Showing 30 changed files with 365 additions and 40 deletions.
5 changes: 5 additions & 0 deletions .env
@@ -0,0 +1,5 @@
RAILS_ENV=development
WEB_CONCURRENCY=1
MAX_THREADS=4
SECRET_TOKEN=temp
SECRET_KEY_BASE=temp
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -33,4 +33,5 @@
# Ignore tern files
\.tern-port

/coverage/
/coverage/
/data/**/
26 changes: 16 additions & 10 deletions .travis.yml
@@ -1,10 +1,16 @@
language: ruby
rvm:
- 2.2.3
before_install:
- wget https://s3.amazonaws.com/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2
- tar -xjf phantomjs-2.0.0-ubuntu-12.04.tar.bz2
- sudo rm -rf /usr/local/phantomjs/bin/phantomjs
- sudo mv phantomjs /usr/local/phantomjs/bin/phantomjs
before_script:
- psql -c 'create database "yacs-test";' -U postgres
sudo: required

services:
- docker

env:
- RAILS_ENV=test

install:
- bin/yacs-build
- bin/yacs-startd && docker ps
- sleep 10
- bin/yacs-dbsetup

script:
- bin/yacs-test
26 changes: 26 additions & 0 deletions Dockerfile
@@ -0,0 +1,26 @@
FROM ruby:2.2.3

MAINTAINER Richie Young <richiejoeyoung@gmail.com>

RUN apt-get update && apt-get install -qq -y build-essential nodejs wget --fix-missing --no-install-recommends

ENV PHANTOMJS_VERSION 2.1.1
RUN \
apt-get install -y vim git wget libfreetype6 libfontconfig bzip2 && \
wget -q --no-check-certificate -O /tmp/phantomjs-$PHANTOMJS_VERSION-linux-x86_64.tar.bz2 https://github.com/paladox/phantomjs/releases/download/2.1.7/phantomjs-2.1.1-linux-x86_64.tar.bz2 && \
tar -xjf /tmp/phantomjs-$PHANTOMJS_VERSION-linux-x86_64.tar.bz2 -C /tmp && \
rm -f /tmp/phantomjs-$PHANTOMJS_VERSION-linux-x86_64.tar.bz2 && \
mv /tmp/phantomjs-$PHANTOMJS_VERSION-linux-x86_64/bin/phantomjs /usr/bin/phantomjs

ENV INSTALL_PATH /usr/src/app/
RUN mkdir -p $INSTALL_PATH
RUN mkdir -p /var/run/puma

WORKDIR $INSTALL_PATH
COPY Gemfile Gemfile.lock $INSTALL_PATH

RUN bundle install
COPY . $INSTALL_PATH

RUN mkdir -p /etc/puma/ssl
COPY nginx/ssl/ /etc/puma/ssl/
36 changes: 19 additions & 17 deletions Gemfile.lock
Expand Up @@ -40,15 +40,16 @@ GEM
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
addressable (2.4.0)
addressable (2.5.0)
public_suffix (~> 2.0, >= 2.0.2)
arel (6.0.3)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
builder (3.2.2)
byebug (2.7.0)
columnize (~> 0.3)
debugger-linecache (~> 1.2)
capybara (2.10.1)
capybara (2.10.2)
addressable
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
Expand All @@ -61,13 +62,13 @@ GEM
coderay (1.1.1)
columnize (0.9.0)
concurrent-ruby (1.0.2)
coveralls (0.8.15)
coveralls (0.8.16)
json (>= 1.8, < 3)
simplecov (~> 0.12.0)
term-ansicolor (~> 1.3)
term-ansicolor (~> 1.3.0)
thor (~> 0.19.1)
tins (>= 1.6.0, < 2)
crono (1.0.3)
crono (1.1.2)
activerecord (>= 4.0)
activesupport (>= 4.0)
cucumber (2.4.0)
Expand Down Expand Up @@ -110,11 +111,11 @@ GEM
sprockets (>= 2.0.0)
tilt (>= 1.2)
i18n (0.7.0)
jbuilder (2.6.0)
jbuilder (2.6.1)
activesupport (>= 3.0.0, < 5.1)
multi_json (~> 1.2)
json (1.8.3)
libv8 (3.16.14.15)
libv8 (3.16.14.17)
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.4)
Expand All @@ -124,17 +125,17 @@ GEM
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
minitest (5.9.1)
minitest (5.10.1)
multi_json (1.12.1)
multi_test (0.1.2)
newrelic_rpm (3.16.3.323)
newrelic_rpm (3.17.1.326)
nokogiri (1.6.8.1)
mini_portile2 (~> 2.1.0)
pg (0.19.0)
pickle (0.5.1)
cucumber (>= 0.8)
rake
poltergeist (1.10.0)
poltergeist (1.11.0)
capybara (~> 2.1)
cliver (~> 0.3.1)
websocket-driver (>= 0.2.0)
Expand All @@ -151,8 +152,9 @@ GEM
pry-stack_explorer (0.4.9.2)
binding_of_caller (>= 0.7)
pry (>= 0.9.11)
public_suffix (2.0.4)
puma (2.16.0)
rack (1.6.4)
rack (1.6.5)
rack-test (0.6.3)
rack (>= 1.0)
railroady (1.5.2)
Expand Down Expand Up @@ -211,7 +213,7 @@ GEM
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
selenium-webdriver (2.53.4)
selenium-webdriver (3.0.3)
childprocess (~> 0.5)
rubyzip (~> 1.0)
websocket (~> 1.0)
Expand All @@ -230,18 +232,18 @@ GEM
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
term-ansicolor (1.4.0)
term-ansicolor (1.3.2)
tins (~> 1.0)
therubyracer (0.12.2)
libv8 (~> 3.16.14.0)
ref
thor (0.19.1)
thor (0.19.4)
thread_safe (0.3.5)
tilt (2.0.5)
tins (1.12.0)
tins (1.13.0)
tzinfo (1.2.2)
thread_safe (~> 0.1)
uglifier (3.0.2)
uglifier (3.0.4)
execjs (>= 0.3.0, < 3)
web-console (2.3.0)
activemodel (>= 4.0)
Expand Down Expand Up @@ -293,4 +295,4 @@ DEPENDENCIES
web-console (~> 2.0)

BUNDLED WITH
1.11.2
1.10.6
5 changes: 4 additions & 1 deletion app/views/api/v5/sections/_sections.json.jbuilder
Expand Up @@ -11,5 +11,8 @@ json.sections sections do |section|
i += 1
end
end
json.course_name section.course.name
json.course_number section.course.number
json.department_code section.course.department.code
end
end
end
2 changes: 1 addition & 1 deletion app/views/static/index.html.erb
Expand Up @@ -29,7 +29,7 @@
<div>Inspired by Jeff Hui's YACS.</div>
</div>
<div class="footer-column">
<div>Yacs v0.8 - The Places You'll Go</div>
<div>Yacs v0.9 - One Box Life</div>
<div>
We love feedback!
<a href="https://github.com/YACS-RCOS/yacs/">Github</a>
Expand Down
5 changes: 5 additions & 0 deletions bin/yacs-assets
@@ -0,0 +1,5 @@
#!/bin/bash
cd $(dirname `readlink -f "$0"`)/../

docker-compose run web rake assets:precompile && rm -f public/index.html
chmod -f a+r public/* || :
4 changes: 4 additions & 0 deletions bin/yacs-bash
@@ -0,0 +1,4 @@
#!/bin/bash
cd $(dirname `readlink -f "$0"`)/../

docker-compose run web bash
4 changes: 4 additions & 0 deletions bin/yacs-build
@@ -0,0 +1,4 @@
#!/bin/bash
cd $(dirname `readlink -f "$0"`)/../

docker-compose build
5 changes: 5 additions & 0 deletions bin/yacs-dbsetup
@@ -0,0 +1,5 @@
#!/bin/bash
cd $(dirname `readlink -f "$0"`)/../

mkdir -p data/potsgres
docker-compose run web bundle exec rake db:create db:migrate
4 changes: 4 additions & 0 deletions bin/yacs-generate-cert
@@ -0,0 +1,4 @@
#!/bin/bash
cd $(dirname `readlink -f "$0"`)/../

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout nginx/ssl/yacs.key -out nginx/ssl/yacs.cer -subj "/C=US/ST=New York/L=Troy/O=RPI/OU=RCOS/CN=yacs.cs.rpi.edu"
4 changes: 4 additions & 0 deletions bin/yacs-run
@@ -0,0 +1,4 @@
#!/bin/bash
cd $(dirname `readlink -f "$0"`)/../

docker-compose run web $@
4 changes: 4 additions & 0 deletions bin/yacs-start
@@ -0,0 +1,4 @@
#!/bin/bash
cd $(dirname `readlink -f "$0"`)/../

docker-compose up
4 changes: 4 additions & 0 deletions bin/yacs-startd
@@ -0,0 +1,4 @@
#!/bin/bash
cd $(dirname `readlink -f "$0"`)/../

docker-compose up -d
4 changes: 4 additions & 0 deletions bin/yacs-stop
@@ -0,0 +1,4 @@
#!/bin/bash
cd $(dirname `readlink -f "$0"`)/../

docker-compose stop
4 changes: 4 additions & 0 deletions bin/yacs-test
@@ -0,0 +1,4 @@
#!/bin/bash
cd $(dirname `readlink -f "$0"`)/../

RAILS_ENV=test docker-compose run web bundle exec rake
4 changes: 4 additions & 0 deletions bin/yacs-update
@@ -0,0 +1,4 @@
#!/bin/bash
cd $(dirname `readlink -f "$0"`)/../

git pull origin
9 changes: 9 additions & 0 deletions bin/yacs-update-deploy
@@ -0,0 +1,9 @@
#!/bin/bash
cd $(dirname `readlink -f "$0"`)/../

bin/yacs-update
bin/yacs-build
bin/yacs-dbsetup
bin/yacs-stop
bin/yacs-assets
bin/yacs-startd
2 changes: 2 additions & 0 deletions config/database.yml
Expand Up @@ -8,6 +8,8 @@ default: &default
adapter: postgresql
pool: 5
timeout: 5000
host: postgres
username: postgres

development:
<<: *default
Expand Down
1 change: 1 addition & 0 deletions config/environments/development.rb
Expand Up @@ -38,4 +38,5 @@

# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true

end
1 change: 0 additions & 1 deletion config/environments/production.rb
Expand Up @@ -28,7 +28,6 @@

# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
config.assets.css_compressor = :sass

# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
Expand Down
19 changes: 10 additions & 9 deletions config/puma.rb
@@ -1,23 +1,24 @@
# https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server

workers Integer(ENV['WEB_CONCURRENCY'] || 2)
workers Integer(ENV['WEB_CONCURRENCY'] || 4)
threads_count = Integer(ENV['MAX_THREADS'] || 5)
threads threads_count, threads_count

preload_app!

rackup DefaultRackup
port ENV['PORT'] || 3000
environment ENV['RACK_ENV'] || 'development'
environment ENV['RAILS_ENV'] || 'development'

if ENV['DSTATEDIR']
pidfile "#{ENV['DSTATEDIR']}puma.pid"
state_path "#{ENV['DSTATEDIR']}puma.state"
daemonize true
end
ssl_bind '0.0.0.0', '3000', {
key: "/etc/puma/ssl/yacs.key",
cert: "/etc/puma/ssl/yacs.cer"
}

pidfile "/var/run/puma/puma.pid"
state_path "/var/run/puma/puma.state"

on_worker_boot do
# Worker specific setup for Rails 4.1+
# See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
ActiveRecord::Base.establish_connection
end
end
1 change: 1 addition & 0 deletions config/secrets.yml
Expand Up @@ -20,3 +20,4 @@ test:
# instead read values from the environment.
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
secret_token: <%= ENV["SECRET_TOKEN"] %>
File renamed without changes.
12 changes: 12 additions & 0 deletions deploy.sh
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

mkdir -p ./data/postgres
mkdir -p ./data/redis
mkdir -p ./tmp/pids/puma

docker-compose down
docker-compose build
docker-compose run web rm public/index.html
docker-compose run web bundle exec rake db:create db:migrate
docker-compose run web bundle exec rake assets:precompile
docker-compose up -d

0 comments on commit 667601d

Please sign in to comment.