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

Add docker configuration #212

Merged
merged 2 commits into from
Feb 14, 2019
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
30 changes: 30 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,21 @@ jobs:
path: tmp/screenshots
destination: screenshots

docker:
machine: true
working_directory: ~/panlexicon
steps:
- checkout
- run:
name: Install Docker Compose
command: |
curl -L https://github.com/docker/compose/releases/download/1.23.2/docker-compose-`uname -s`-`uname -m` > ~/docker-compose
chmod +x ~/docker-compose
sudo mv ~/docker-compose /usr/local/bin/docker-compose
- run: docker-compose build
- run: docker-compose run web bin/setup
- run: docker-compose run web bin/rspec

deploy:
machine:
enabled: true
Expand Down Expand Up @@ -91,3 +106,18 @@ workflows:
filters:
branches:
only: master
- docker:
filters:
branches:
only: /^docker*/

docker_nightly:
jobs:
- docker
triggers:
- schedule:
cron: "0 0 * * *"
filters:
branches:
only:
- master
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.env
/tmp
.git
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM ruby:2.6.0

ENV CHROMIUM_DRIVER_VERSION 2.46

RUN apt-get update -qq && apt-get install -y nodejs postgresql-client

# Install Chrome
RUN wget -q -O /tmp/linux_signing_key.pub https://dl-ssl.google.com/linux/linux_signing_key.pub \
&& apt-key add /tmp/linux_signing_key.pub \
&& echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list \
&& apt-get update && apt-get install google-chrome-stable -y

# Install Chromedriver
RUN wget -O /tmp/chromedriver.zip http://chromedriver.storage.googleapis.com/$CHROMIUM_DRIVER_VERSION/chromedriver_linux64.zip \
&& unzip /tmp/chromedriver.zip chromedriver -d /usr/local/bin/ \
&& rm /tmp/chromedriver.zip \
&& chmod ugo+rx /usr/local/bin/chromedriver

RUN mkdir /project
WORKDIR /project
COPY .ruby-version Gemfile Gemfile.lock /project/
RUN bundle install --jobs=4 --retry=3 --full-index

ENV PATH /opt/bin/:$PATH
COPY . /project
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,22 @@ Start Server | Test / Watch
Installation and Setup
----------------------

### Local Setup:
Dependencies:
- Ruby 2.6.0
- bundler gem (`$ gem install bundler`)
- postgres (on OSX, use [Postgres.app](http://postgresapp.com/))
- [System dependencies](Brewfile), assuming you are using Homebrew on OSX: `brew bundle`

Setup:
1. Run `$ bin/setup`
2. Start the server: `$ bin/rails s`
3. Visit it in your web browser: `http://localhost:3000`

### Docker setup
1. Run `$ docker-compose run web bin/setup`
2. Run `$ docker-compose up`
3. Visit it in your web browser: `http://localhost:3000`

Running Tests
-------------

Expand Down
29 changes: 29 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: '3.6'
volumes:
postgres-data:
services:
db:
image: postgres
volumes:
- postgres-data:/var/lib/postgresql/data
ports:
- '5432:5432'
web: &rails_base
build:
context: .
dockerfile: Dockerfile
working_dir: /project
command: bin/rails s -p 3000 -b '0.0.0.0'
volumes:
- .:/project
ports:
- "3000:3000"
depends_on:
- db
environment:
- PGHOST=db
- PGUSER=postgres
- RAILS_ENV=development
tmpfs:
- /project/tmp/pids

2 changes: 1 addition & 1 deletion lib/tasks/moby.rake
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace :moby do
else
system "
pg_restore --verbose --data-only --no-acl --no-owner \
-h localhost -U $(whoami) -d panlexicon_#{ENV.fetch('RAILS_ENV', 'development')} \
-U ${PGUSER:-$(whoami)} -d panlexicon_#{ENV.fetch('RAILS_ENV', 'development')} \
data.sql.tar
"
end
Expand Down
3 changes: 2 additions & 1 deletion spec/support/system_specs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
end

config.before(:each, type: :system, js: true) do
driven_by :selenium, using: (ENV['SHOW_BROWSER'] ? :chrome : :headless_chrome), screen_size: [1024, 800]
# Chrome's no-sandbox option is required for running in Docker
driven_by :selenium, using: (ENV['SHOW_BROWSER'] ? :chrome : :headless_chrome), screen_size: [1024, 800], options: { args: ["no-sandbox", "disable-dev-shm-usage"] }
end
end