Skip to content
This repository was archived by the owner on Feb 1, 2023. It is now read-only.

Commit be4a51d

Browse files
author
Alexey Simakov
committed
Rails rubyc build example
1 parent af98137 commit be4a51d

Some content is hidden

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

86 files changed

+1345
-6
lines changed

.gitignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
2+
#
3+
# If you find yourself ignoring temporary files generated by your text editor
4+
# or operating system, you probably want to add a global ignore instead:
5+
# git config --global core.excludesfile '~/.gitignore_global'
6+
7+
# Ignore bundler config.
8+
examples/rails_app/.bundle
9+
10+
# Ignore the default SQLite database.
11+
examples/rails_app/db/*.sqlite3
12+
examples/rails_app/db/*.sqlite3-journal
13+
14+
# Ignore all logfiles and tempfiles.
15+
examples/rails_app/log/*
16+
examples/rails_app/tmp/*
17+
examples/rails_app!/log/.keep
18+
examples/rails_app!/tmp/.keep
19+
20+
# Ignore uploaded files in development
21+
examples/rails_app/storage/*
22+
23+
examples/rails_app/node_modules
24+
examples/rails_app/yarn-error.log
25+
26+
examples/rails_app/public/assets
27+
examples/rails_app.byebug_history
28+
29+
# Ignore master key for decrypting credentials and more.
30+
examples/rails_app/config/master.key

README.md

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ https://docs.docker.com/v17.12/install/linux/docker-ce/ubuntu/
1717

1818
### Build
1919

20-
`cd rubyc-usage-example && docker build ./`
20+
`cd rubyc-usage-example/examples`
21+
22+
Select what example you want to build and:
23+
24+
`docker build ./`
2125

2226
... will take ~10 mins and near 10GB memory usage
2327

@@ -37,6 +41,8 @@ Successfully built 200de23ba865
3741

3842
### Run app
3943

44+
1) Script:
45+
4046
`docker run -it 200de23ba865 bash`
4147
`./a.out`
4248
or
@@ -49,14 +55,31 @@ Sample output:
4955
### Or mix and match.
5056
</pre>
5157

52-
# Recomendations for Rails Apps
58+
2) Rails app
5359

54-
Modify Dockerfile as you want to build yor app.
55-
For example, to build rails change last line to
60+
`docker run -it 200de23ba865 bash`
61+
`./a.out server -e production`
62+
or
63+
`docker run -p 3001:3000 -it 200de23ba865 ./a.out server -e production -p 3000`
5664

57-
`RUN rubyc bin/rails`
65+
And from you host machine: http://localhost:3001/
66+
67+
This example rails app generate from rails v5.2 template.
68+
With applying next changes:
69+
1) add to Gemfile `gem 'nokogiri', '~> 1.10', '>= 1.10.1'` to test building app with native extensions
70+
2) add to Gemfile `gem 'therubyracer'` to working assets compiling(node runtime)
71+
3) add to Gemfile `gem 'tzinfo-data'` to internal work with data
72+
4) comment Gemfile `gem 'bootsnap', '>= 1.1.0', require: false`
73+
5) `config/boot.rb` comment `require 'bootsnap/setup'`
74+
6) `config/environments/production.rb` change cache store config `config.cache_store = :memory_store, { size: 64.megabytes }`
75+
76+
! Note: `rubyc` build readonly file system that's why you can not:
77+
1) run app in development env with watching files, but you can config development env without watching files - so run app with `production` env
78+
2) use rails cache with file_store in local Rails.root folder - you must use another folder such as `/tmp/my_cache/` or memory cache
79+
3) compile assets on the fly - you must compile assets before packing app
80+
81+
# Recomendations
5882

5983
More info read: https://github.com/pmq20/ruby-packer
6084

6185
Based on: https://github.com/pmq20/ruby-packer/issues/39#issuecomment-415494119
62-

examples/rails_app/.gitignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
2+
#
3+
# If you find yourself ignoring temporary files generated by your text editor
4+
# or operating system, you probably want to add a global ignore instead:
5+
# git config --global core.excludesfile '~/.gitignore_global'
6+
7+
# Ignore bundler config.
8+
/.bundle
9+
10+
# Ignore the default SQLite database.
11+
/db/*.sqlite3
12+
/db/*.sqlite3-journal
13+
14+
# Ignore all logfiles and tempfiles.
15+
/log/*
16+
/tmp/*
17+
!/log/.keep
18+
!/tmp/.keep
19+
20+
# Ignore uploaded files in development
21+
/storage/*
22+
23+
/node_modules
24+
/yarn-error.log
25+
26+
/public/assets
27+
.byebug_history
28+
29+
# Ignore master key for decrypting credentials and more.
30+
/config/master.key

examples/rails_app/.ruby-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.4.1

examples/rails_app/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM ruby:2.4.0
2+
3+
RUN apt-get update
4+
RUN apt-get install -y squashfs-tools bison
5+
6+
RUN curl -L http://enclose.io/rubyc/rubyc-linux-x64.gz | gunzip > rubyc
7+
RUN chmod +x rubyc && cp rubyc /usr/local/bin/
8+
9+
RUN mkdir -p /usr/src/app
10+
WORKDIR /usr/src/app
11+
12+
# Copy application files
13+
COPY ./ ./
14+
15+
RUN rubyc bin/rails

examples/rails_app/Gemfile

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
source 'https://rubygems.org'
2+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3+
4+
ruby '2.4.1'
5+
6+
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
7+
gem 'rails', '~> 5.2.0'
8+
# Use sqlite3 as the database for Active Record
9+
gem 'sqlite3', '~> 1.3.6'
10+
# Use Puma as the app server
11+
gem 'puma', '~> 3.11'
12+
# Use SCSS for stylesheets
13+
gem 'sass-rails', '~> 5.0'
14+
# Use Uglifier as compressor for JavaScript assets
15+
gem 'uglifier', '>= 1.3.0'
16+
# See https://github.com/rails/execjs#readme for more supported runtimes
17+
# gem 'mini_racer', platforms: :ruby
18+
19+
# Use CoffeeScript for .coffee assets and views
20+
gem 'coffee-rails', '~> 4.2'
21+
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
22+
gem 'turbolinks', '~> 5'
23+
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
24+
gem 'jbuilder', '~> 2.5'
25+
# Use Redis adapter to run Action Cable in production
26+
# gem 'redis', '~> 4.0'
27+
# Use ActiveModel has_secure_password
28+
# gem 'bcrypt', '~> 3.1.7'
29+
30+
# Use ActiveStorage variant
31+
# gem 'mini_magick', '~> 4.8'
32+
33+
# Use Capistrano for deployment
34+
# gem 'capistrano-rails', group: :development
35+
36+
# Reduces boot times through caching; required in config/boot.rb
37+
# gem 'bootsnap', '>= 1.1.0', require: false
38+
39+
gem 'nokogiri', '~> 1.10', '>= 1.10.1'
40+
gem 'therubyracer'
41+
gem 'tzinfo-data'
42+
43+
group :development, :test do
44+
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
45+
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
46+
end
47+
48+
group :development do
49+
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
50+
gem 'web-console', '>= 3.3.0'
51+
gem 'listen', '>= 3.0.5', '< 3.2'
52+
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
53+
gem 'spring'
54+
gem 'spring-watcher-listen', '~> 2.0.0'
55+
end
56+
57+
group :test do
58+
# Adds support for Capybara system testing and selenium driver
59+
gem 'capybara', '>= 2.15', '< 4.0'
60+
gem 'selenium-webdriver'
61+
# Easy installation and use of chromedriver to run system tests with Chrome
62+
gem 'chromedriver-helper'
63+
end
64+
65+
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
66+
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

0 commit comments

Comments
 (0)