Skip to content

Commit

Permalink
Add support for Docker (#839)
Browse files Browse the repository at this point in the history
**Why**: It's much easier than Vagrant, especially with the new Docker
for Mac and Docker for Windows
  • Loading branch information
monfresh authored Jun 26, 2016
1 parent 08665e6 commit 347b6da
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 20 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Dockerfile
tmp
log
*.md
.git*
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM ruby:2.3.1

RUN apt-get update && apt-get install -y nodejs --no-install-recommends && rm -rf /var/lib/apt/lists/*

# PhantomJS is required for running tests
ENV PHANTOMJS_SHA256 86dd9a4bf4aee45f1a84c9f61cf1947c1d6dce9b9e8d2a907105da7852460d2f

RUN mkdir /usr/local/phantomjs \
&& curl -o phantomjs.tar.bz2 -L https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 \
&& echo "$PHANTOMJS_SHA256 *phantomjs.tar.bz2" | sha256sum -c - \
&& tar -xjf phantomjs.tar.bz2 -C /usr/local/phantomjs --strip-components=1 \
&& rm phantomjs.tar.bz2

RUN ln -s ../phantomjs/bin/phantomjs /usr/local/bin/

WORKDIR /ohana-web-search

COPY Gemfile /ohana-web-search
COPY Gemfile.lock /ohana-web-search

RUN bundle install

COPY . /ohana-web-search

EXPOSE 3000
CMD ["rails", "server", "-b", "0.0.0.0"]
66 changes: 46 additions & 20 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,59 @@

# Running Ohana Web Search on your computer

## Install Prerequisites
## Clone the repo to your local machine

Before you can run Ohana Web Search, you'll need to have the following software
packages installed on your computer: Git, Ruby 2.2+, RVM, and PhantomJS.
If you're on a Linux machine, you'll also need Node.js.
git clone [email protected]:codeforamerica/ohana-web-search.git && cd ohana-web-search

If you already have all of the prerequisites installed, you can go straight
to the [Installation](#install-ohana-web-search). Otherwise, you'll need to
install the following tools manually:

- [Build tools][build-tools]
- [Ruby with RVM][ruby]
- [PhantomJS][phantomjs] (only used for running the tests)
- [Node.js][node] (Linux only)
## Docker Setup (recommended, especially for Windows users)

[build-tools]: https://github.com/codeforamerica/howto/blob/master/Build-Tools.md
[ruby]: https://github.com/codeforamerica/howto/blob/master/Ruby.md
[phantomjs]: https://github.com/jonleighton/poltergeist#installing-phantomjs
[node]: https://github.com/codeforamerica/howto/blob/master/Node.js.md
1. Download, install, and launch [Docker]

1. Copy the sample configuration files:

$ bin/setup --docker

1. Build/download the container images:

$ docker-compose build

1. Start the app:

$ docker-compose up

Once the docker images are up and running, the app will be accessible at
[http://localhost:3000](http://localhost:3000).

More useful Docker commands:

## Install Ohana Web Search
* Stop this running container: `docker-compose stop`
* Stop and delete the containers: `docker-compose down`
* Open a shell in the web container: `docker-compose run --rm web bash`

Clone the `codeforamerica/ohana-web-search` repository and navigate to the project's directory:
[Docker]: https://docs.docker.com/engine/installation/

git clone [email protected]:codeforamerica/ohana-web-search.git
cd ohana-web-search

## Local Setup

Before you can run Ohana Web Search, you'll need to have the following software
packages installed on your computer: Git, Ruby 2.3+, RVM, and PhantomJS.
If you're on a Linux machine, you'll also need Node.js.

If you already have all of the prerequisites installed, you can skip to the
next step. Otherwise, there are two ways you can install the tools:

- If you're on a Mac, the easiest way to install all the tools is to use
@monfresh's [laptop] script.

- Install everything manually: [Build tools], [Ruby with RVM], [phantomjs], and
[Node.js][node] (Linux only).

[laptop]: https://github.com/monfresh/laptop
[Build tools]: https://github.com/codeforamerica/howto/blob/master/Build-Tools.md
[Ruby with RVM]: https://github.com/codeforamerica/howto/blob/master/Ruby.md
[phantomjs]: https://github.com/jonleighton/poltergeist#installing-phantomjs
[node]: https://github.com/codeforamerica/howto/blob/master/Node.js.md

### Install the dependencies and set the default environment variables:

Expand All @@ -42,7 +68,7 @@ Ohana Web Search should now be running at [http://localhost:4000](http://localho

The `-p` option allows you to specify which port you want to run the server on. This is useful when running other apps at the same time.

### Customize the app
## Customize the app
Once you have the app up and running, you will want to [customize](https://github.com/codeforamerica/ohana-web-search/blob/master/CUSTOMIZE.md) it to point
to your own instance of [Ohana API](https://github.com/codeforamerica/ohana-api),
add your own branding, and much more.
4 changes: 4 additions & 0 deletions bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ Dir.chdir APP_ROOT do
system 'cp config/application.example.yml config/application.yml'
end

if ARGV.shift == '--docker' then
exit
end

puts '== Installing dependencies =='
system 'gem install bundler --conservative'
system 'bundle check || bundle install'
Expand Down
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: '2'
services:
web:
build: .
volumes:
- .:/ohana-web-search
ports:
- "3000:3000"

0 comments on commit 347b6da

Please sign in to comment.