Skip to content

Commit 38621cf

Browse files
committed
initial commit
0 parents  commit 38621cf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+1490
-0
lines changed

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.git

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

Dockerfile

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM ruby:2.5-slim
2+
3+
COPY Gemfile Gemfile.lock /usr/src/app/
4+
WORKDIR /usr/src/app
5+
6+
RUN apt-get update && apt-get -y install libgmp3-dev ruby-dev build-essential libsqlite3-dev && \
7+
bundle install && \
8+
apt-get autoremove -y --purge && \
9+
apt-get remove -y --auto-remove --purge ruby-dev libgmp3-dev build-essential libsqlite3-dev && \
10+
apt-get clean && \
11+
rm -rvf /root/* /root/.gem* /var/cache/*
12+
13+
COPY . /usr/src/app
14+
RUN chmod +x /usr/src/app/startup.sh
15+
16+
# helpful when trying to update gems -> bundle update, remove the Gemfile.lock, start ruby
17+
# RUN bundle update
18+
# RUN rm -vf /usr/src/app/Gemfile.lock
19+
20+
EXPOSE 3000
21+
ENTRYPOINT ["bash","/usr/src/app/startup.sh"]

Gemfile

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
source 'https://rubygems.org'
2+
3+
4+
gem 'thin'
5+
6+
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
7+
gem 'rails', '4.2.10'
8+
# Use sqlite3 as the database for Active Record
9+
gem 'sqlite3'
10+
# Use SCSS for stylesheets
11+
gem 'sass-rails', '~> 5.0'
12+
# Use Uglifier as compressor for JavaScript assets
13+
gem 'uglifier', '>= 1.3.0'
14+
# Use CoffeeScript for .coffee assets and views
15+
gem 'coffee-rails', '~> 4.1.0'
16+
# See https://github.com/rails/execjs#readme for more supported runtimes
17+
gem 'therubyracer', platforms: :ruby
18+
19+
gem 'activesupport'
20+
21+
# Use jquery as the JavaScript library
22+
gem 'jquery-rails'
23+
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
24+
gem 'turbolinks'
25+
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
26+
gem 'jbuilder', '~> 2.0'
27+
# bundle exec rake doc:rails generates the API under doc/api.
28+
gem 'sdoc', '~> 0.4.0', group: :doc
29+
30+
# Use ActiveModel has_secure_password
31+
# gem 'bcrypt', '~> 3.1.7'
32+
33+
# Use Unicorn as the app server
34+
# gem 'unicorn'
35+
36+
# Use Capistrano for deployment
37+
# gem 'capistrano-rails', group: :development
38+
39+
group :development, :test do
40+
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
41+
gem 'byebug'
42+
end
43+
44+
group :development do
45+
# Access an IRB console on exception pages or by using <%= console %> in views
46+
gem 'web-console', '~> 2.0'
47+
48+
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
49+
gem 'spring'
50+
end
51+

Gemfile.lock

+176
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
actionmailer (4.2.10)
5+
actionpack (= 4.2.10)
6+
actionview (= 4.2.10)
7+
activejob (= 4.2.10)
8+
mail (~> 2.5, >= 2.5.4)
9+
rails-dom-testing (~> 1.0, >= 1.0.5)
10+
actionpack (4.2.10)
11+
actionview (= 4.2.10)
12+
activesupport (= 4.2.10)
13+
rack (~> 1.6)
14+
rack-test (~> 0.6.2)
15+
rails-dom-testing (~> 1.0, >= 1.0.5)
16+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
17+
actionview (4.2.10)
18+
activesupport (= 4.2.10)
19+
builder (~> 3.1)
20+
erubis (~> 2.7.0)
21+
rails-dom-testing (~> 1.0, >= 1.0.5)
22+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
23+
activejob (4.2.10)
24+
activesupport (= 4.2.10)
25+
globalid (>= 0.3.0)
26+
activemodel (4.2.10)
27+
activesupport (= 4.2.10)
28+
builder (~> 3.1)
29+
activerecord (4.2.10)
30+
activemodel (= 4.2.10)
31+
activesupport (= 4.2.10)
32+
arel (~> 6.0)
33+
activesupport (4.2.10)
34+
i18n (~> 0.7)
35+
minitest (~> 5.1)
36+
thread_safe (~> 0.3, >= 0.3.4)
37+
tzinfo (~> 1.1)
38+
arel (6.0.4)
39+
binding_of_caller (0.7.3)
40+
debug_inspector (>= 0.0.1)
41+
builder (3.2.3)
42+
byebug (9.1.0)
43+
coffee-rails (4.1.1)
44+
coffee-script (>= 2.2.0)
45+
railties (>= 4.0.0, < 5.1.x)
46+
coffee-script (2.4.1)
47+
coffee-script-source
48+
execjs
49+
coffee-script-source (1.12.2)
50+
concurrent-ruby (1.0.5)
51+
crass (1.0.3)
52+
debug_inspector (0.0.3)
53+
erubis (2.7.0)
54+
execjs (2.7.0)
55+
ffi (1.9.18)
56+
globalid (0.4.1)
57+
activesupport (>= 4.2.0)
58+
i18n (0.9.1)
59+
concurrent-ruby (~> 1.0)
60+
jbuilder (2.7.0)
61+
activesupport (>= 4.2.0)
62+
multi_json (>= 1.2)
63+
jquery-rails (4.3.1)
64+
rails-dom-testing (>= 1, < 3)
65+
railties (>= 4.2.0)
66+
thor (>= 0.14, < 2.0)
67+
json (1.8.6)
68+
libv8 (3.16.14.19-x86_64-linux)
69+
loofah (2.1.1)
70+
crass (~> 1.0.2)
71+
nokogiri (>= 1.5.9)
72+
mail (2.7.0)
73+
mini_mime (>= 0.1.1)
74+
mini_mime (1.0.0)
75+
mini_portile2 (2.3.0)
76+
minitest (5.10.3)
77+
multi_json (1.12.2)
78+
nokogiri (1.8.1)
79+
mini_portile2 (~> 2.3.0)
80+
rack (1.6.8)
81+
rack-test (0.6.3)
82+
rack (>= 1.0)
83+
rails (4.2.10)
84+
actionmailer (= 4.2.10)
85+
actionpack (= 4.2.10)
86+
actionview (= 4.2.10)
87+
activejob (= 4.2.10)
88+
activemodel (= 4.2.10)
89+
activerecord (= 4.2.10)
90+
activesupport (= 4.2.10)
91+
bundler (>= 1.3.0, < 2.0)
92+
railties (= 4.2.10)
93+
sprockets-rails
94+
rails-deprecated_sanitizer (1.0.3)
95+
activesupport (>= 4.2.0.alpha)
96+
rails-dom-testing (1.0.9)
97+
activesupport (>= 4.2.0, < 5.0)
98+
nokogiri (~> 1.6)
99+
rails-deprecated_sanitizer (>= 1.0.1)
100+
rails-html-sanitizer (1.0.3)
101+
loofah (~> 2.0)
102+
railties (4.2.10)
103+
actionpack (= 4.2.10)
104+
activesupport (= 4.2.10)
105+
rake (>= 0.8.7)
106+
thor (>= 0.18.1, < 2.0)
107+
rake (12.3.0)
108+
rb-fsevent (0.10.2)
109+
rb-inotify (0.9.10)
110+
ffi (>= 0.5.0, < 2)
111+
rdoc (4.3.0)
112+
ref (2.0.0)
113+
sass (3.5.4)
114+
sass-listen (~> 4.0.0)
115+
sass-listen (4.0.0)
116+
rb-fsevent (~> 0.9, >= 0.9.4)
117+
rb-inotify (~> 0.9, >= 0.9.7)
118+
sass-rails (5.0.7)
119+
railties (>= 4.0.0, < 6)
120+
sass (~> 3.1)
121+
sprockets (>= 2.8, < 4.0)
122+
sprockets-rails (>= 2.0, < 4.0)
123+
tilt (>= 1.1, < 3)
124+
sdoc (0.4.2)
125+
json (~> 1.7, >= 1.7.7)
126+
rdoc (~> 4.0)
127+
spring (2.0.2)
128+
activesupport (>= 4.2)
129+
sprockets (3.7.1)
130+
concurrent-ruby (~> 1.0)
131+
rack (> 1, < 3)
132+
sprockets-rails (3.2.1)
133+
actionpack (>= 4.0)
134+
activesupport (>= 4.0)
135+
sprockets (>= 3.0.0)
136+
sqlite3 (1.3.13)
137+
therubyracer (0.12.3)
138+
libv8 (~> 3.16.14.15)
139+
ref
140+
thor (0.20.0)
141+
thread_safe (0.3.6)
142+
tilt (2.0.8)
143+
turbolinks (5.0.1)
144+
turbolinks-source (~> 5)
145+
turbolinks-source (5.0.3)
146+
tzinfo (1.2.4)
147+
thread_safe (~> 0.1)
148+
uglifier (4.0.2)
149+
execjs (>= 0.3.0, < 3)
150+
web-console (2.3.0)
151+
activemodel (>= 4.0)
152+
binding_of_caller (>= 0.7.2)
153+
railties (>= 4.0)
154+
sprockets-rails (>= 2.0, < 4.0)
155+
156+
PLATFORMS
157+
ruby
158+
159+
DEPENDENCIES
160+
activesupport
161+
byebug
162+
coffee-rails (~> 4.1.0)
163+
jbuilder (~> 2.0)
164+
jquery-rails
165+
rails (= 4.2.10)
166+
sass-rails (~> 5.0)
167+
sdoc (~> 0.4.0)
168+
spring
169+
sqlite3
170+
therubyracer
171+
turbolinks
172+
uglifier (>= 1.3.0)
173+
web-console (~> 2.0)
174+
175+
BUNDLED WITH
176+
1.16.1

README.md

+3

Rakefile

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Add your own tasks in files placed in lib/tasks ending in .rake,
2+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3+
4+
require File.expand_path('../config/application', __FILE__)
5+
6+
Rails.application.load_tasks

app/assets/images/.keep

Whitespace-only changes.

app/assets/images/a-N-N.svg

+4

app/assets/images/a-N-a.svg

+4

app/assets/images/a-N-b.svg

+4

app/assets/images/a-N-c.svg

+4

app/assets/images/a-a-N.svg

+4

app/assets/images/a-a-a.svg

+4

app/assets/images/a-a-b.svg

+4

app/assets/images/a-a-c.svg

+4

app/assets/images/a-b-N.svg

+4

app/assets/images/a-b-a.svg

+4

app/assets/images/a-b-b.svg

+4

app/assets/images/a-b-c.svg

+4

app/assets/images/a-c-N.svg

+4

app/assets/images/a-c-a.svg

+4

app/assets/images/a-c-b.svg

+4

app/assets/images/a-c-c.svg

+4

app/assets/images/aza-none.svg

+4

app/assets/images/azb-none.svg

+4

app/assets/images/azc-none.svg

+4

app/assets/images/b-N-N.svg

+4

app/assets/images/b-N-a.svg

+4

app/assets/images/b-N-b.svg

+4

app/assets/images/b-N-c.svg

+4

app/assets/images/b-a-N.svg

+4

app/assets/images/b-a-a.svg

+4

app/assets/images/b-a-b.svg

+4

app/assets/images/b-a-c.svg

+4

app/assets/images/b-b-N.svg

+4

app/assets/images/b-b-a.svg

+4

app/assets/images/b-b-b.svg

+4

app/assets/images/b-b-c.svg

+4

app/assets/images/b-c-N.svg

+4

app/assets/images/b-c-a.svg

+4

app/assets/images/b-c-b.svg

+4

app/assets/images/b-c-c.svg

+4

app/assets/images/c-N-N.svg

+4

app/assets/images/c-N-a.svg

+4

app/assets/images/c-N-b.svg

+4

app/assets/images/c-N-c.svg

+4

app/assets/images/c-a-N.svg

+4

app/assets/images/c-a-a.svg

+4

app/assets/images/c-a-b.svg

+4

app/assets/images/c-a-c.svg

+4

app/assets/images/c-b-N.svg

+4

app/assets/images/c-b-a.svg

+4

app/assets/images/c-b-b.svg

+4

app/assets/images/c-b-c.svg

+4

app/assets/images/c-c-N.svg

+4

app/assets/images/c-c-a.svg

+4

app/assets/images/c-c-b.svg

+4

app/assets/images/c-c-c.svg

+4

app/assets/javascripts/application.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// This is a manifest file that'll be compiled into application.js, which will include all the files
2+
// listed below.
3+
//
4+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6+
//
7+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8+
// compiled file.
9+
//
10+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11+
// about supported directives.
12+
//
13+
//= require jquery
14+
//= require jquery_ujs
15+
//= require turbolinks
16+
//= require_tree .
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* This is a manifest file that'll be compiled into application.css, which will include all the files
3+
* listed below.
4+
*
5+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7+
*
8+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
9+
* compiled file so the styles you add here take precedence over styles defined in any styles
10+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11+
* file per style scope.
12+
*
13+
*= require_tree .
14+
*= require_self
15+
*/
+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
require 'net/http'
2+
3+
class ApplicationController < ActionController::Base
4+
# Prevent CSRF attacks by raising an exception.
5+
# For APIs, you may want to use :null_session instead.
6+
protect_from_forgery with: :exception
7+
8+
# Example endpoint that calls the backend nodejs api
9+
def index
10+
begin
11+
url = URI.parse(backend_addr)
12+
req = Net::HTTP::Get.new(url.to_s)
13+
res = Net::HTTP.start(url.host, url.port) {|http|
14+
http.request(req)
15+
}
16+
17+
if res.code == '200'
18+
@text = res.body
19+
else
20+
@text = "no backend found"
21+
end
22+
23+
crystalurl = URI.parse(crystal_addr)
24+
crystalreq = Net::HTTP::Get.new(crystalurl.to_s)
25+
crystalres = Net::HTTP.start(crystalurl.host, crystalurl.port) {|http|
26+
http.request(crystalreq)
27+
}
28+
29+
if crystalres.code == '200'
30+
@crystal = crystalres.body
31+
else
32+
@crystal = "no backend found"
33+
end
34+
35+
rescue
36+
@text = "no backend found"
37+
@crystal = "no backend found"
38+
end
39+
end
40+
41+
# This endpoint is used for health checks. It should return a 200 OK when the app is up and ready to serve requests.
42+
def health
43+
render plain: "OK"
44+
end
45+
46+
def crystal_addr
47+
crystal_addr = ENV["BACKEND_API"]
48+
# The address will be of the form, http://172.17.0.5:5432, so we add a trailing slash
49+
crystal_addr.sub(/^http:/, 'http:') + "/crystal"
50+
end
51+
52+
def backend_addr
53+
backend_addr = ENV["BACKEND_API"]
54+
# The address will be of the form, http://172.17.0.5:5432, so we add a trailing slash
55+
backend_addr.sub(/^http:/, 'http:') + "/"
56+
end
57+
58+
before_action :discover_availability_zone
59+
before_action :code_hash
60+
61+
def discover_availability_zone
62+
@az = ENV["AZ"]
63+
end
64+
65+
def code_hash
66+
@code_hash = ENV["CODE_HASH"]
67+
end
68+
69+
def custom_header
70+
response.headers['Cache-Control'] = 'max-age=86400, public'
71+
end
72+
end

app/controllers/concerns/.keep

Whitespace-only changes.

app/helpers/application_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module ApplicationHelper
2+
end

app/mailers/.keep

Whitespace-only changes.

app/models/.keep

Whitespace-only changes.

app/models/concerns/.keep

Whitespace-only changes.

0 commit comments

Comments
 (0)