Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker integration #30

Merged
merged 3 commits into from
Mar 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
POSTGRES_USER=coffee_shop_db
POSTGRES_PASSWORD=X1U8S8R0
POSTGRES_HOST=db
SECRET_KEY_BASE=256b756c98666c1b2feba93e324fc1bbb90ece8ac47d6563ffdd49e880bdcc702416d49d84ee9be53a22357454658b2def901d74857fabef74564b3430f16821
VK_KEY=0HyWGg4cM6PDIF165Q4I
VK_ID=5868688
RAILS_SERVE_STATIC_FILES=true
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM ruby:2.3

RUN apt-get update -yqq \
&& apt-get install -yqq --no-install-recommends \
postgresql-client \
&& rm -rf /var/lib/apt/lists

WORKDIR /usr/src/app
COPY Gemfile* ./
RUN bundle install
COPY . .

EXPOSE 3001
CMD rm -rf tmp/pids/server.pid \
&& rails server -b 0.0.0.0 -p 3001
16 changes: 16 additions & 0 deletions Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM ruby:2.3

RUN apt-get update -yqq \
&& apt-get install -yqq --no-install-recommends \
postgresql-client \
&& rm -rf /var/lib/apt/lists

WORKDIR /usr/src/app
COPY Gemfile* ./
RUN bundle install
COPY . .
RUN rake assets:precompile

EXPOSE 3001
CMD rm -rf tmp/pids/server.pid \
&& rails server -b 0.0.0.0 -p 3001
46 changes: 12 additions & 34 deletions config/database.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,21 @@
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
default: &default
adapter: sqlite3
pool: 5
timeout: 5000
adapter: postgresql
encoding: unicode
host: db
username: <%= ENV["POSTGRES_USER"] %>
password: <%= ENV["POSTGRES_PASSWORD"] %>
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>

development:
<<: *default
database: db/development.sqlite3
database: coffee_shop_dev

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: db/test.sqlite3
database: coffee_shop_test

production:
adapter: postgresql
encoding: unicode
database: coffee_shop_production
username: coffee_shop_production
password: Hh83LnxJ
host: localhost
port: 5432
pool: 1
timeout: 5000

staging:
adapter: postgresql
encoding: unicode
database: coffee_shop_staging
username: coffee_shop_staging
password: iHtn6K1N
host: localhost
port: 5432
pool: 1
timeout: 5000
<<: *default
database: db/production.sqlite3
host: <%= ENV["POSTGRES_HOST"] %>
database: coffee_shop_prod
12 changes: 8 additions & 4 deletions config/secrets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@
# Make sure the secrets in this file are kept private
# if you're sharing your code publicly.

default: &default
vk_key: <%= ENV["VK_KEY"] %>
vk_id: <%= ENV["VK_ID"] %>

development:
<<: *default
secret_key_base: 5a53bcba06a18290fe6cae79bd29ef6430dd6a3fe85113e3bd420bcb8fb0f42e036122179d9c9523a4a559f75cffdb8d9e89dc08d19bf0b2a71e0833def8b27f

test:
<<: *default
secret_key_base: 11e8d8f5b66c909d7aa348621ecf110d64c5044d8b458876cfabb21adf21004d5304585821d454bb9ef3b9d07a269d7e66e70eb08e3fdf4eaa868341b5cfc13f

# Do not keep production secrets in the repository,
# instead read values from the environment.
production:
secret_key_base: 417974fdfa16eeb7c3299768ebeda2cfc60b22d287694f522e45b277810f0ae22cd6ac9274c0d6032e741304dae5f4d17f41269d88137d2819fe3ac5649fb052

staging:
secret_key_base: 8445c094393c1489b1ca522e4a9c12cf9e6268eec4aeb06ca167382d81763ab75ebf9694a5c980c2223195801a90a4cd5ac92d476b93aadcd19b8f278cd8a500
<<: *default
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
13 changes: 8 additions & 5 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

ActiveRecord::Schema.define(version: 20161008193029) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

create_table "barman_invites", force: :cascade do |t|
t.integer "point_id"
t.string "code"
Expand Down Expand Up @@ -76,8 +79,8 @@
t.integer "resource_id"
t.datetime "created_at"
t.datetime "updated_at"
t.index ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id"
t.index ["name"], name: "index_roles_on_name"
t.index ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id", using: :btree
t.index ["name"], name: "index_roles_on_name", using: :btree
end

create_table "users", force: :cascade do |t|
Expand All @@ -97,14 +100,14 @@
t.string "provider"
t.string "first_name"
t.string "last_name"
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
t.index ["email"], name: "index_users_on_email", unique: true, using: :btree
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
end

create_table "users_roles", id: false, force: :cascade do |t|
t.integer "user_id"
t.integer "role_id"
t.index ["user_id", "role_id"], name: "index_users_roles_on_user_id_and_role_id"
t.index ["user_id", "role_id"], name: "index_users_roles_on_user_id_and_role_id", using: :btree
end

end
24 changes: 24 additions & 0 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: "2"

volumes:
db-data:
external: false

services:
db:
image: postgres
env_file: .env
volumes:
- db-data:/var/lib/postgresql/db-data

app:
build:
context: .
dockerfile: Dockerfile.prod
env_file: .env
environment:
RAILS_ENV: production
ports:
- "3001:3001"
depends_on:
- db
22 changes: 22 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: "2"

volumes:
db-data:
external: false

services:
db:
image: postgres
env_file: .env
volumes:
- db-data:/var/lib/postgresql/db-data

app:
build: .
env_file: .env
volumes:
- .:/usr/src/app
ports:
- "3001:3001"
depends_on:
- db