Skip to content

Commit e6a537f

Browse files
author
Parinda Darden
committed
Add docker instructions to installfest
1 parent b7db20a commit e6a537f

File tree

7 files changed

+199
-24
lines changed

7 files changed

+199
-24
lines changed

public/img/docker.png

6.05 KB
Loading

sites/en/installfest/choose_your_operating_system.step

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,12 @@ div(class: "os-button") do
1818
h3 "Linux"
1919
end
2020
end
21+
22+
h2 "Or install Docker"
23+
24+
div(class: "os-button") do
25+
simple_link "docker" do
26+
img src: "/img/docker.png"
27+
h3 "Docker"
28+
end
29+
end

sites/en/installfest/clean_up.step

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ step "Delete the test_app from your computer" do
2020
console "rm -rf ~/railsbridge/test_app"
2121
end
2222
end
23+
24+
step "Delete the test_app Docker image from your computer" do
25+
console "docker rmi testapp_web"
26+
end

sites/en/installfest/create_a_rails_app.step

Lines changed: 121 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
tip do
2+
message "Ignore this if you installed Docker"
23
console_with_message "From here on, this guide assumes you have Rails 5.0.x. To check your Rails version, type this in the terminal:", "rails -v"
34
fuzzy_result "Rails 5.0{FUZZY}.x{/FUZZY}"
45
message "If your computer reports a Rails version less than 5.0, ask a TA help get you back on track."
@@ -19,13 +20,101 @@ step "Change to your new railsbridge directory" do
1920
end
2021

2122
step "Create a new Rails app" do
23+
option_half "Without Docker" do
24+
console "rails new test_app"
2225

23-
console "rails new test_app"
26+
message "The command's output is voluminous, and will take some time to complete, with a long pause in the middle, after all the 'create...' statements ending in 'bundle install'. When it fully completes, it will return you to your home prompt. Look for the 'Bundle complete!' message just above."
2427

25-
message "The command's output is voluminous, and will take some time to complete, with a long pause in the middle, after all the 'create...' statements ending in 'bundle install'. When it fully completes, it will return you to your home prompt. Look for the 'Bundle complete!' message just above."
28+
console "cd test_app"
29+
console "rails server"
30+
end
31+
32+
option_half "With Docker" do
33+
console "mkdir test_app"
34+
console "cd test_app"
2635

27-
console "cd test_app"
28-
console "rails server"
36+
message "In your editor, create a new file called `Gemfile`"
37+
message "Copy the following into `Gemfile`:"
38+
source_code :ruby, <<-CONTENTS
39+
source "https://rubygems.org"
40+
gem "rails", "5.2.0"
41+
CONTENTS
42+
console "touch Gemfile.lock"
43+
44+
message "In your editor, create a new file called `Dockerfile`:"
45+
message "Copy the following into `Dockerfile`:"
46+
source_code :text, <<-CONTENTS
47+
FROM ruby:2.5.1-slim
48+
49+
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev git vim nodejs postgresql-client build-essential
50+
51+
ENV APP_HOME /test_app
52+
RUN mkdir -p $APP_HOME
53+
WORKDIR $APP_HOME
54+
COPY Gemfile* $APP_HOME/
55+
RUN bundle install --binstubs
56+
COPY . $APP_HOME
57+
CONTENTS
58+
59+
message "In your editor, create a new file called `docker-compose.yml`:"
60+
message "Copy the following into `docker-compose.yml`:"
61+
source_code :text, <<-CONTENTS
62+
version: '3'
63+
services:
64+
db:
65+
image: postgres:10.3
66+
volumes:
67+
- db_data:/var/lib/postgresql/data
68+
web:
69+
build: .
70+
environment:
71+
DB_HOST: db
72+
tty: true
73+
stdin_open: true
74+
volumes:
75+
- .:/test_app
76+
command: bin/rails s -p 3000 -b '0.0.0.0'
77+
ports:
78+
- "3000:3000"
79+
depends_on:
80+
- db
81+
volumes:
82+
db_data:
83+
driver: local
84+
CONTENTS
85+
86+
message "Build your rails app:"
87+
console "docker-compose run web rails new . --force --database=postgresql"
88+
console "docker-compose build"
89+
90+
message "Setup the database:"
91+
message "In your editor, open up `config/database.yml` and change it to the following:"
92+
source_code :ruby, <<-CONTENTS
93+
default: &default
94+
adapter: postgresql
95+
encoding: unicode
96+
username: postgres
97+
password:
98+
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
99+
host: <%= ENV.fetch("DB_HOST") %>
100+
development:
101+
<<: *default
102+
database: test_app_development
103+
test:
104+
<<: *default
105+
database: test_app_test
106+
production:
107+
<<: *default
108+
database: test_app_production
109+
password: <%= ENV['APP_DATABASE_PASSWORD'] %>
110+
CONTENTS
111+
console "docker-compose run web bin/rails db:create"
112+
console "docker-compose run web bin/rails db:migrate"
113+
114+
message "Spin up the rails server:"
115+
console "docker-compose up"
116+
tip "`docker-compose up` will execute the command, `bin/rails s -p 3000 -b '0.0.0.0'`, in `docker-compose.yml`"
117+
end
29118

30119
tip "In OS X, you may need to let Ruby accept incoming network connections through your firewall. Select 'allow' in the pop up."
31120

@@ -60,10 +149,16 @@ step "Create a new Rails app" do
60149
tip "If it doesn't work, ask a TA for help."
61150
message "* In your browser, go to <http://localhost:3000>"
62151
img src: "img/successful_rails_install.png", alt: "Screenshot of the browser on localhost 3000 showing the rails intro page"
63-
message <<-MARKDOWN
64-
65-
* Back in the Terminal window where you ran <code>rails server</code>, type **Control-C** (don't type this into the console, but hold the Control and C keys at the same time) to kill(stop) the server. Windows will ask "Terminate batch job (Y/N)?". Type "Y".
66-
MARKDOWN
152+
option_half "Without Docker" do
153+
message <<-MARKDOWN
154+
* Back in the Terminal window where you ran <code>rails server</code>, type **Control-C** (don't type this into the console, but hold the Control and C keys at the same time) to kill(stop) the server. Windows will ask "Terminate batch job (Y/N)?". Type "Y".
155+
MARKDOWN
156+
end
157+
option_half "With Docker" do
158+
message <<-MARKDOWN
159+
* Open a new Terminal tab, type **docker-compose down** to stop the server.
160+
MARKDOWN
161+
end
67162

68163
important "On Windows, sometimes Control-C doesn't work. In that case, look for the key called 'Break' or 'Pause' and press Control-Break, then answer Y at the prompt. If there is no Pause/Break key on your keyboard, you can run `ruby script/rails server` instead of `rails server` which should allow Control-C to stop the server."
69164
end
@@ -73,15 +168,29 @@ step "Generate a database model" do
73168
console "cd test_app"
74169
end
75170

171+
tip "If you're using Docker, execute the following commands in the web service container" do
172+
message "run bash to interact with the directory inside the web service container:"
173+
console "docker-compose run web bash"
174+
end
175+
76176
console <<-BASH
77177
rails generate scaffold drink name:string temperature:integer
78178
BASH
79179
console <<-BASH
80180
rails db:migrate
81181
BASH
82-
console <<-BASH
83-
rails server
84-
BASH
182+
183+
option_half "Without Docker" do
184+
console <<-BASH
185+
rails server
186+
BASH
187+
end
188+
189+
option_half "With Docker" do
190+
console <<-BASH
191+
docker-compose up
192+
BASH
193+
end
85194

86195
message <<-MARKDOWN
87196
**Note:** the above are three separate commands. Type each line into the terminal separately, not as one single command.
@@ -98,6 +207,7 @@ step "Generate a database model" do
98207
You should see: ![Screenshot of the drink detail page](img/get_a_sticker_you_should_see.png)
99208

100209
In your terminal, Hold Control and hit C (or on Windows, Control-Break, Y) to stop the rails server.
210+
**For Docker**, in a new terminal tab, type **docker-compose down** to stop the server.
101211
MARKDOWN
102212
end
103213

sites/en/installfest/deploy_a_rails_app.step

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ step "Deploy your app to Heroku" do
5555
end
5656

5757
step "Prepare your rails app for deploying to Heroku" do
58+
message <<-MARKDOWN
59+
**SKIP THIS STEP IF YOU'RE USING DOCKER**
60+
MARKDOWN
61+
5862
message <<-MARKDOWN
5963
Launch your text editor and open the "Gemfile" file located inside of your test_app folder. (On Windows, this should be in `C:\\Sites\\railsbridge\\test_app` and on Linux/OS X, it should be under `~/railsbridge/test_app`.)
6064

sites/en/installfest/docker.step

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
step "Install Docker" do
2+
option "Docker for Mac" do
3+
message "Visit [Docker for Mac download page](https://store.docker.com/editions/community/docker-ce-desktop-mac)
4+
message "Download and install the **Stable** verion"
5+
end
6+
7+
option "Docker for Windows" do
8+
message "Visit [Docker for Windows download page](https://store.docker.com/editions/community/docker-ce-desktop-windows)
9+
message "Download and install the **Stable** verion"
10+
end
11+
12+
option "Docker for Ubuntu" do
13+
message "Visit [Docker for Ubuntu download page](https://store.docker.com/editions/community/docker-ce-server-ubuntu)
14+
message "Download and install the **Stable** verion"
15+
end
16+
17+
option "Docker for other platforms" do
18+
message "Visit the [Docker Community Edition Downloads Page](https://www.docker.com/community-edition)"
19+
end
20+
end
21+
22+
step "Install Git" do
23+
option "Macintosh" do
24+
message "Follow Step 1 through Step 4 in OSX Rvm"
25+
link "osx_rvm"
26+
end
27+
28+
option "Windows" do
29+
message "Go to <http://git-scm.com> and download and run the installer."
30+
end
31+
32+
option "Ubuntu" do
33+
message "Open a terminal (Applications > Accessories > Terminal)."
34+
console "sudo apt-get install git"
35+
end
36+
end
37+
38+
next_step "configure_git"

sites/en/installfest/get_a_sticker.step

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,37 @@ step "Have a volunteer check your tool versions" do
44

55
verify "tool installation" do
66

7-
tip "Most of the time, the version numbers don't have to match exactly. In general, if the *first two* numbers match, or if the full number you have is *greater* than the one below, then you're cool."
7+
option_half "Without Docker" do
8+
tip "Most of the time, the version numbers don't have to match exactly. In general, if the *first two* numbers match, or if the full number you have is *greater* than the one below, then you're cool."
89

9-
h3 "If you're on OSX or Linux:"
10+
h3 "If you're on OSX or Linux:"
1011

11-
console "rvm -v"
12-
fuzzy_result "rvm 1{FUZZY}.x.x by Wayne E. Seguin ([email protected]) [https://rvm.io/]{/FUZZY}"
12+
console "rvm -v"
13+
fuzzy_result "rvm 1{FUZZY}.x.x by Wayne E. Seguin ([email protected]) [https://rvm.io/]{/FUZZY}"
1314

14-
h3 "On all operating systems:"
15+
h3 "On all operating systems:"
1516

16-
console "ruby -v"
17-
fuzzy_result "ruby 2.3{FUZZY}.3p222 (2015-12-16 revision 53155) [x86_64-darwin13]{/FUZZY}"
17+
console "ruby -v"
18+
fuzzy_result "ruby 2.3{FUZZY}.3p222 (2015-12-16 revision 53155) [x86_64-darwin13]{/FUZZY}"
1819

19-
tip "As long as your Ruby version is #{version_string(:ruby_short)} or above, you're good to go."
20+
tip "As long as your Ruby version is #{version_string(:ruby_short)} or above, you're good to go."
2021

21-
console "bundle -v"
22-
fuzzy_result "Bundler version 1{FUZZY}.x.x{/FUZZY}"
22+
console "bundle -v"
23+
fuzzy_result "Bundler version 1{FUZZY}.x.x{/FUZZY}"
2324

24-
console "rails -v"
25-
fuzzy_result "Rails 5.0{FUZZY}.x{/FUZZY}"
25+
console "rails -v"
26+
fuzzy_result "Rails 5.0{FUZZY}.x{/FUZZY}"
2627

27-
tip 'The RailsBridge curriculum is written for Rails 5, so if you still have Rails 4.x or earlier, you need to install Rails 5 with `gem install rails`.'
28+
tip 'The RailsBridge curriculum is written for Rails 5, so if you still have Rails 4.x or earlier, you need to install Rails 5 with `gem install rails`.'
29+
end
30+
31+
option_half "With Docker" do
32+
message "The following should output `ruby` version `2.5.1-slim` and `postgres` version `10.3`:"
33+
console "docker images"
34+
35+
console "docker-compose run web rails -v"
36+
fuzzy_result "Rails 5.2.0"
37+
end
2838
end
2939
end
3040

0 commit comments

Comments
 (0)