Skip to content

Commit

Permalink
[docker] Adding docker support
Browse files Browse the repository at this point in the history
  • Loading branch information
MojoJosh committed Jul 27, 2018
1 parent 6027df2 commit f8041b8
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 2 deletions.
51 changes: 51 additions & 0 deletions .dockerignore
@@ -0,0 +1,51 @@
.git
.gitignore
README.md

#
# OS X
#
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear on external disk
.Spotlight-V100
.Trashes
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

#
# Rails
#
.env
.env.sample
*.rbc
capybara-*.html
log
tmp
db/*.sqlite3
db/*.sqlite3-journal
public/system
coverage/
spec/tmp
**.orig

.bundle

.ruby-version
.ruby-gemset

.rvmrc

# if using bower-rails ignore default bower_components path bower.json files
vendor/assets/bower_components
*.bowerrc
bower.json
19 changes: 19 additions & 0 deletions Dockerfile
@@ -0,0 +1,19 @@
FROM ruby:2.5.1
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash
RUN apt-get update -qq && apt-get install -yq build-essential nodejs unzip
RUN gem install foreman
# upgrade bundler to avoid https://github.com/bundler/bundler/issues/4576
RUN gem install bundler -v 1.16
RUN npm install -g yarn
RUN useradd -ms /bin/bash -d /app app
RUN mkdir /app/secure && chown app:app /app/secure
RUN mkdir /app/tmp && chown app:app /app/tmp
WORKDIR /app
USER app
RUN bundle config git.allow_insecure true
COPY --chown=app vendor /app/vendor
COPY --chown=app Gemfile /app/Gemfile
COPY --chown=app Gemfile.lock /app/Gemfile.lock
RUN bundle install --jobs=4 --path vendor/bundle
RUN yarn install
COPY --chown=app . /app
2 changes: 1 addition & 1 deletion Procfile.development
@@ -1,2 +1,2 @@
rails: bin/rails s
rails: bin/rails s -b 0.0.0.0 -p 5000
webpack: bin/webpack-dev-server
20 changes: 20 additions & 0 deletions README.md
Expand Up @@ -6,6 +6,13 @@ This project is a Rails 5.2 app using webpacker and React.

MRI 2.5.1

### Installation options

You can either install the deps directly on your box or you can use the Docker support.


## Native

### Getting ready

- `bundle install`
Expand All @@ -17,6 +24,19 @@ MRI 2.5.1
- `foreman start -f Procfile.development`
- http://localhost:5000

## Docker

### Getting Ready

- Install Docker and docker-compose
- `cp .env.local.sample .env` -- fill in env vars where applicable

### Start it up

- `docker-compose build`
- `docker-compose up`
- http://localhost:5000

### Designs

https://app.zeplin.io/project/5ad8bfb98c928b070d6e1589
Expand Down
3 changes: 3 additions & 0 deletions config/environments/development.rb
Expand Up @@ -61,4 +61,7 @@
config.file_watcher = ActiveSupport::EventedFileUpdateChecker

config.action_controller.forgery_protection_origin_check = false

# allow LAN IPs access to the console
config.web_console.whitelisted_ips = %w(127.0.0.1 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16)
end
2 changes: 1 addition & 1 deletion config/webpacker.yml
Expand Up @@ -40,7 +40,7 @@ development:
# Reference: https://webpack.js.org/configuration/dev-server/
dev_server:
https: false
host: localhost
host: 0.0.0.0
port: 3035
public: localhost:3035
hmr: false
Expand Down
23 changes: 23 additions & 0 deletions docker-compose.yml
@@ -0,0 +1,23 @@
version: '3'
services:
web:
build: .
command: bash -lc "(rm -rf tmp/pids/ || true) && yarn install && bundle install --path vendor/bundle && bin/rails db:migrate db:seed RAILS_ENV=development && bundle exec foreman start -f Procfile.development"
hostname: helios2-dev
tty: true
stdin_open: true
volumes:
- .:/app:delegated
- /app/secure
- /app/tmp
ports:
- "5000:5000"
- "3035:3035"
depends_on:
- redis
environment:
- RAILS_ENV=development
- RACK_ENV=development
- REDIS_URL=redis://redis:6379/1
redis:
image: redis:4.0

0 comments on commit f8041b8

Please sign in to comment.