Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jay.dave authored and jay.dave committed Aug 22, 2018
1 parent cc68f53 commit f28edd5
Show file tree
Hide file tree
Showing 170 changed files with 1,883 additions and 76 deletions.
Binary file added .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.5.1
18 changes: 14 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
FROM alpine:3.5
FROM ruby:2.5.1

COPY cat-etc-hosts.sh .
# install build-tools
RUN apt-get update -qq \
&& apt-get install -y \
build-essential \
libpq-dev \
nodejs

RUN chmod u+x cat-etc-hosts.sh
# install application dependencies
RUN mkdir /app
WORKDIR /app
ADD Gemfile /app
ADD Gemfile.lock /app
RUN bundle install

CMD ["./cat-etc-hosts.sh"]
CMD ["bundle", "exec", "unicorn", "-c", "config/unicorn.rb", "-l", "3000"]
38 changes: 38 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
source 'https://rubygems.org'
ruby "2.5.1"

# tracing
gem 'ddtrace'

# rails
gem 'rails'
gem 'grape'
gem 'redis-rails'

# database
gem 'mysql2'

# queues
gem 'delayed_job_active_record'
gem 'daemons'

# testing
gem 'rails-controller-testing'
gem 'rails-perftest'
gem 'ruby-prof'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails'
gem 'coffee-rails'
gem 'uglifier'
end

gem 'jquery-rails'

# Use unicorn as the app server
gem 'unicorn'

# Use passenger as app server
# gem 'passenger', require: "phusion_passenger/rack_handler"
231 changes: 231 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
GEM
remote: https://rubygems.org/
specs:
actioncable (5.2.1)
actionpack (= 5.2.1)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailer (5.2.1)
actionpack (= 5.2.1)
actionview (= 5.2.1)
activejob (= 5.2.1)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.2.1)
actionview (= 5.2.1)
activesupport (= 5.2.1)
rack (~> 2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.2.1)
activesupport (= 5.2.1)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.2.1)
activesupport (= 5.2.1)
globalid (>= 0.3.6)
activemodel (5.2.1)
activesupport (= 5.2.1)
activerecord (5.2.1)
activemodel (= 5.2.1)
activesupport (= 5.2.1)
arel (>= 9.0)
activestorage (5.2.1)
actionpack (= 5.2.1)
activerecord (= 5.2.1)
marcel (~> 0.3.1)
activesupport (5.2.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
arel (9.0.0)
axiom-types (0.1.1)
descendants_tracker (~> 0.0.4)
ice_nine (~> 0.11.0)
thread_safe (~> 0.3, >= 0.3.1)
builder (3.2.3)
coercible (1.0.0)
descendants_tracker (~> 0.0.1)
coffee-rails (4.2.2)
coffee-script (>= 2.2.0)
railties (>= 4.0.0)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.0.5)
crass (1.0.4)
daemons (1.2.6)
ddtrace (0.14.0)
msgpack
delayed_job (4.1.5)
activesupport (>= 3.0, < 5.3)
delayed_job_active_record (4.1.3)
activerecord (>= 3.0, < 5.3)
delayed_job (>= 3.0, < 5)
descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1)
equalizer (0.0.11)
erubi (1.7.1)
execjs (2.7.0)
ffi (1.9.25)
globalid (0.4.1)
activesupport (>= 4.2.0)
grape (1.1.0)
activesupport
builder
mustermann-grape (~> 1.0.0)
rack (>= 1.3.0)
rack-accept
virtus (>= 1.0.0)
i18n (1.1.0)
concurrent-ruby (~> 1.0)
ice_nine (0.11.2)
jquery-rails (4.3.3)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
kgio (2.11.2)
loofah (2.2.2)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.0)
mini_mime (>= 0.1.1)
marcel (0.3.2)
mimemagic (~> 0.3.2)
method_source (0.9.0)
mimemagic (0.3.2)
mini_mime (1.0.1)
mini_portile2 (2.3.0)
minitest (5.11.3)
msgpack (1.2.4)
mustermann (1.0.2)
mustermann-grape (1.0.0)
mustermann (~> 1.0.0)
mysql2 (0.5.2)
nio4r (2.3.1)
nokogiri (1.8.4)
mini_portile2 (~> 2.3.0)
rack (2.0.5)
rack-accept (0.4.5)
rack (>= 0.4)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (5.2.1)
actioncable (= 5.2.1)
actionmailer (= 5.2.1)
actionpack (= 5.2.1)
actionview (= 5.2.1)
activejob (= 5.2.1)
activemodel (= 5.2.1)
activerecord (= 5.2.1)
activestorage (= 5.2.1)
activesupport (= 5.2.1)
bundler (>= 1.3.0)
railties (= 5.2.1)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.2)
actionpack (~> 5.x, >= 5.0.1)
actionview (~> 5.x, >= 5.0.1)
activesupport (~> 5.x)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2)
rails-perftest (0.0.7)
railties (5.2.1)
actionpack (= 5.2.1)
activesupport (= 5.2.1)
method_source
rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0)
raindrops (0.19.0)
rake (12.3.1)
rb-fsevent (0.10.3)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
redis (4.0.2)
redis-actionpack (5.0.2)
actionpack (>= 4.0, < 6)
redis-rack (>= 1, < 3)
redis-store (>= 1.1.0, < 2)
redis-activesupport (5.0.7)
activesupport (>= 3, < 6)
redis-store (>= 1.3, < 2)
redis-rack (2.0.4)
rack (>= 1.5, < 3)
redis-store (>= 1.2, < 2)
redis-rails (5.0.2)
redis-actionpack (>= 5.0, < 6)
redis-activesupport (>= 5.0, < 6)
redis-store (>= 1.2, < 2)
redis-store (1.5.0)
redis (>= 2.2, < 5)
ruby-prof (0.17.0)
sass (3.5.7)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
sass-rails (5.0.7)
railties (>= 4.0.0, < 6)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
thor (0.20.0)
thread_safe (0.3.6)
tilt (2.0.8)
tzinfo (1.2.5)
thread_safe (~> 0.1)
uglifier (4.1.18)
execjs (>= 0.3.0, < 3)
unicorn (5.4.1)
kgio (~> 2.6)
raindrops (~> 0.7)
virtus (1.0.5)
axiom-types (~> 0.1)
coercible (~> 1.0)
descendants_tracker (~> 0.0, >= 0.0.3)
equalizer (~> 0.0, >= 0.0.9)
websocket-driver (0.7.0)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)

PLATFORMS
ruby

DEPENDENCIES
coffee-rails
daemons
ddtrace
delayed_job_active_record
grape
jquery-rails
mysql2
rails
rails-controller-testing
rails-perftest
redis-rails
ruby-prof
sass-rails
uglifier
unicorn

RUBY VERSION
ruby 2.5.1p57

BUNDLED WITH
1.16.2
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: bundle exec unicorn -c config/unicorn.rb
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Rails 5.2 example

Blog application built using the [official Rails tutorial][1]. This version is meant to test
tracing compatibility issues with Rails.

[1]: http://guides.rubyonrails.org/getting_started.html

## Compatibility stack

* Ruby 2.5.1
* Rails 5.2.1
* MySQL adapter (mysql2)
* Redis 4.0.1
* Unicorn 5.4.1
* Passenger 5.3.4

## Backing services

* MySQL 8.0
* Redis 4.0.11

## Getting started

Launch all services (it will trigger a Docker build):

docker-compose up

When the MySQL service is up and running, launch in another console the following
command to create the application database:

docker-compose run --rm web rake db:create
docker-compose run --rm web rake db:migrate

Back in the first console, stop docker with CTRL-C, then:

docker-compose stop
DD_API_KEY=<your Datadog key> docker-compose up

The above sends data to your Datadog account if the ``DD_API_KEY`` is valid.

Alternatively, if you use Direnv, you can copy the `.envrc.sample` file to `.envrc`, insert your API key, then run `direnv allow .` to load the API key into your environment. In which case you can run to start the application:

docker-compose up

### Note about the build

Dependencies listed in the ``Gemfile`` are installed at build time, so if you need to change
them for any reason, remember to remove then re-build the image via:

docker-compose build

### Using the example application

Access the blog at http://localhost:3000/ and login using the default user/password `me`/`123456`.
7 changes: 7 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)

Blog::Application.load_tasks
30 changes: 30 additions & 0 deletions app/api/api.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module FastAPI
class Ping < Grape::API
namespace :example_namespace
desc 'Returns a pong'
get :ping do
{ ping: params[:pong] || 'pong' }
end
end
end


module FastAPI
class Cache < Grape::API
desc 'Returns a value from the Rails cache'
before do
sleep 0.001
end

get :cache do
{ value: Rails.cache.fetch('custom_cache_key') }
end
end
end

class API < Grape::API
prefix 'api'
format :json
mount FastAPI::Ping
mount FastAPI::Cache
end
Binary file added app/assets/images/rails.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f28edd5

Please sign in to comment.