Skip to content

Commit 594d30a

Browse files
author
Ubuntu
committed
first commit
1 parent 3eb3fbd commit 594d30a

File tree

11 files changed

+211
-85
lines changed

11 files changed

+211
-85
lines changed

Dockerfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
FROM ruby:2.6.0
2+
MAINTAINER marko@codeship.com
3+
4+
# Install apt based dependencies required to run Rails as
5+
# well as RubyGems. As the Ruby image itself is based on a
6+
# Debian image, we use apt-get to install those.
7+
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - && \
8+
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
9+
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
10+
apt-get update && \
11+
apt-get install -qq -y build-essential libpq-dev nodejs yarn
12+
13+
# Configure the main working directory. This is the base
14+
# directory used in any further RUN, COPY, and ENTRYPOINT
15+
# commands.
16+
RUN mkdir -p /app
17+
WORKDIR /app
18+
19+
# Copy the Gemfile as well as the Gemfile.lock and install
20+
# the RubyGems. This is a separate step so the dependencies
21+
# will be cached unless changes to one of those two files
22+
# are made.
23+
COPY Gemfile Gemfile.lock ./
24+
RUN gem install bundler && bundle install --jobs 20 --retry 5
25+
26+
# Copy the main application.
27+
COPY . ./
28+
RUN yarn install
29+
# Expose port 3000 to the Docker host, so we can access it
30+
# from the outside.
31+
EXPOSE 3000
32+
33+
# The main command to run when the container starts. Also
34+
# tell the Rails dev server to bind to all interfaces by
35+
# default.
36+
#CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"]
37+
CMD ["rails", "server", "-b", "0.0.0.0"]

Dockerfile_1

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
FROM ruby:2.6.0
2+
3+
# throw errors if Gemfile has been modified since Gemfile.lock
4+
# RUN bundle config --global frozen 1
5+
6+
RUN mkdir -p /usr/src/app
7+
WORKDIR /usr/src/app
8+
9+
EXPOSE 3000
10+
CMD ["rails", "server", "-b", "0.0.0.0"]
11+
12+
RUN apt-get update && apt-get install -y nodejs --no-install-recommends && rm -rf /var/lib/apt/lists/*
13+
RUN apt-get update && apt-get install -y mysql-client postgresql-client sqlite3 --no-install-recommends && rm -rf /var/lib/apt/lists/*
14+
15+
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - && \
16+
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
17+
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
18+
apt-get update && \
19+
apt-get install -qq -y build-essential libpq-dev yarn
20+
21+
COPY Gemfile /usr/src/app/
22+
23+
# Uncomment the line below if Gemfile.lock is maintained outside of build process
24+
COPY Gemfile.lock /usr/src/app/
25+
26+
27+
RUN bundle install
28+
29+
COPY . /usr/src/app
30+
31+
RUN yarn install

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ gem 'jbuilder', '~> 2.7'
2727

2828
# Reduces boot times through caching; required in config/boot.rb
2929
gem 'bootsnap', '>= 1.4.2', require: false
30-
30+
gem 'mysql2', '>=0.2.0'
3131
group :development, :test do
3232
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
3333
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ DEPENDENCIES
218218
web-console (>= 3.3.0)
219219
webdrivers
220220
webpacker (~> 4.0)
221-
221+
mysql2
222222
RUBY VERSION
223223
ruby 2.6.0p0
224224

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class DashboardsController < ApplicationController
2+
def index
3+
end
4+
end

app/views/dashboards/index.html.erb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
Welcome to Ruby

app/views/layouts/application.html.erb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
<title>Spritle DevOps - SampleRails6App</title>
55
<%= csrf_meta_tags %>
66
<%= csp_meta_tag %>
7-
8-
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
9-
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
107
</head>
118

129
<body>

config/database.yml

Lines changed: 14 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,19 @@
1-
# PostgreSQL. Versions 9.3 and up are supported.
2-
#
3-
# Install the pg driver:
4-
# gem install pg
5-
# On macOS with Homebrew:
6-
# gem install pg -- --with-pg-config=/usr/local/bin/pg_config
7-
# On macOS with MacPorts:
8-
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
9-
# On Windows:
10-
# gem install pg
11-
# Choose the win32 build.
12-
# Install PostgreSQL and put its /bin directory on your path.
13-
#
14-
# Configure Using Gemfile
15-
# gem 'pg'
16-
#
171
default: &default
18-
adapter: postgresql
19-
encoding: unicode
20-
# For details on connection pooling, see Rails configuration guide
21-
# https://guides.rubyonrails.org/configuring.html#database-pooling
22-
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
2+
adapter: mysql2
3+
encoding: utf8mb4
4+
collation: utf8mb4_bin
5+
reconnect: false
6+
pool: 50
7+
username: <%= ENV['DB_USERNAME'] %>
8+
password: <%= ENV['DB_PASSWORD'] %>
9+
port: <%= ENV['DB_PORT'] %>
10+
host: <%= ENV['DB_HOST'] %>
11+
socket: /var/run/mysqld/mysqlx.sock
2312

2413
development:
25-
<<: *default
26-
database: sample_rails6_app_development
14+
<<: *default
15+
database: <%= ENV['DB_DATABASE'] %>_development
2716

28-
# The specified database role being used to connect to postgres.
29-
# To create additional roles in postgres see `$ createuser --help`.
30-
# When left blank, postgres will use the default role. This is
31-
# the same name as the operating system user that initialized the database.
32-
#username: sample_rails6_app
33-
34-
# The password associated with the postgres role (username).
35-
#password:
36-
37-
# Connect on a TCP socket. Omitted by default since the client uses a
38-
# domain socket that doesn't need configuration. Windows does not have
39-
# domain sockets, so uncomment these lines.
40-
#host: localhost
41-
42-
# The TCP port the server listens on. Defaults to 5432.
43-
# If your server runs on a different port number, change accordingly.
44-
#port: 5432
45-
46-
# Schema search path. The server defaults to $user,public
47-
#schema_search_path: myapp,sharedapp,public
48-
49-
# Minimum log levels, in increasing order:
50-
# debug5, debug4, debug3, debug2, debug1,
51-
# log, notice, warning, error, fatal, and panic
52-
# Defaults to warning.
53-
#min_messages: notice
54-
55-
# Warning: The database defined as "test" will be erased and
56-
# re-generated from your development database when you run "rake".
57-
# Do not set this db to the same as development or production.
58-
test:
59-
<<: *default
60-
database: sample_rails6_app_test
61-
62-
# As with config/credentials.yml, you never want to store sensitive information,
63-
# like your database password, in your source code. If your source code is
64-
# ever seen by anyone, they now have access to your database.
65-
#
66-
# Instead, provide the password as a unix environment variable when you boot
67-
# the app. Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
68-
# for a full rundown on how to provide these environment variables in a
69-
# production deployment.
70-
#
71-
# On Heroku and other platform providers, you may have a full connection URL
72-
# available as an environment variable. For example:
73-
#
74-
# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
75-
#
76-
# You can use this database configuration with:
77-
#
78-
# production:
79-
# url: <%= ENV['DATABASE_URL'] %>
80-
#
8117
production:
82-
<<: *default
83-
database: sample_rails6_app_production
84-
username: sample_rails6_app
85-
password: <%= ENV['SAMPLE_RAILS6_APP_DATABASE_PASSWORD'] %>
18+
<<: *default
19+
database: <%= ENV['DB_DATABASE'] %>

config/database.yml.bkp

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# PostgreSQL. Versions 9.3 and up are supported.
2+
#
3+
# Install the pg driver:
4+
# gem install pg
5+
# On macOS with Homebrew:
6+
# gem install pg -- --with-pg-config=/usr/local/bin/pg_config
7+
# On macOS with MacPorts:
8+
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
9+
# On Windows:
10+
# gem install pg
11+
# Choose the win32 build.
12+
# Install PostgreSQL and put its /bin directory on your path.
13+
#
14+
# Configure Using Gemfile
15+
# gem 'pg'
16+
#
17+
default: &default
18+
adapter: postgresql
19+
encoding: unicode
20+
# For details on connection pooling, see Rails configuration guide
21+
# https://guides.rubyonrails.org/configuring.html#database-pooling
22+
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
23+
24+
development:
25+
<<: *default
26+
database: sample_rails6_app_development
27+
28+
# The specified database role being used to connect to postgres.
29+
# To create additional roles in postgres see `$ createuser --help`.
30+
# When left blank, postgres will use the default role. This is
31+
# the same name as the operating system user that initialized the database.
32+
#username: sample_rails6_app
33+
34+
# The password associated with the postgres role (username).
35+
#password:
36+
37+
# Connect on a TCP socket. Omitted by default since the client uses a
38+
# domain socket that doesn't need configuration. Windows does not have
39+
# domain sockets, so uncomment these lines.
40+
#host: localhost
41+
42+
# The TCP port the server listens on. Defaults to 5432.
43+
# If your server runs on a different port number, change accordingly.
44+
#port: 5432
45+
46+
# Schema search path. The server defaults to $user,public
47+
#schema_search_path: myapp,sharedapp,public
48+
49+
# Minimum log levels, in increasing order:
50+
# debug5, debug4, debug3, debug2, debug1,
51+
# log, notice, warning, error, fatal, and panic
52+
# Defaults to warning.
53+
#min_messages: notice
54+
55+
# Warning: The database defined as "test" will be erased and
56+
# re-generated from your development database when you run "rake".
57+
# Do not set this db to the same as development or production.
58+
test:
59+
<<: *default
60+
database: sample_rails6_app_test
61+
62+
# As with config/credentials.yml, you never want to store sensitive information,
63+
# like your database password, in your source code. If your source code is
64+
# ever seen by anyone, they now have access to your database.
65+
#
66+
# Instead, provide the password as a unix environment variable when you boot
67+
# the app. Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
68+
# for a full rundown on how to provide these environment variables in a
69+
# production deployment.
70+
#
71+
# On Heroku and other platform providers, you may have a full connection URL
72+
# available as an environment variable. For example:
73+
#
74+
# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
75+
#
76+
# You can use this database configuration with:
77+
#
78+
# production:
79+
# url: <%= ENV['DATABASE_URL'] %>
80+
#
81+
production:
82+
<<: *default
83+
database: sample_rails6_app_production
84+
username: sample_rails6_app
85+
password: <%= ENV['SAMPLE_RAILS6_APP_DATABASE_PASSWORD'] %>

config/routes.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
Rails.application.routes.draw do
22
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
3+
4+
resources :dashboards
5+
36
end

0 commit comments

Comments
 (0)