forked from columbusrb/columbusrb.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request columbusrb#21 from tvon/docker
Docker updates
- Loading branch information
Showing
7 changed files
with
104 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
FROM ruby:2.2.0 | ||
RUN apt-get update -qq | ||
RUN apt-get install -y build-essential nodejs npm nodejs-legacy libpq-dev vim curl patch gawk g++ gcc make libc6-dev patch libreadline6-dev zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 autoconf libgdbm-dev libncurses5-dev automake libtool bison pkg-config libffi-dev | ||
FROM ruby:2.2.1 | ||
|
||
RUN npm install -g phantomjs | ||
RUN mkdir /myapp | ||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
postgresql-client libssl-dev \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
WORKDIR /tmp | ||
COPY Gemfile Gemfile | ||
COPY Gemfile.lock Gemfile.lock | ||
WORKDIR /app | ||
COPY Gemfile* ./ | ||
RUN bundle install | ||
COPY . /app/ | ||
|
||
EXPOSE 3000 | ||
CMD ["rails", "server", "-b", "0.0.0.0"] | ||
|
||
ADD . /myapp | ||
WORKDIR /myapp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,48 @@ | ||
## Columbus Ruby Brigade Website | ||
|
||
### About | ||
|
||
TODO: Add some information about CRB | ||
|
||
### How to Join | ||
|
||
TODO: Add steps on how to join | ||
|
||
### Contributing | ||
TODO: Add contributing information. | ||
|
||
To start the app and database, you can use the helper script: | ||
|
||
``` | ||
script/docker-start | ||
``` | ||
|
||
Once that is up and running, you can execute `rake` and `rails` commands (or anything else) via `script/docker-run`, e.g.: | ||
|
||
``` | ||
script/docker-run rails console | ||
``` | ||
|
||
or | ||
|
||
``` | ||
script/docker-run rake -T | ||
``` | ||
|
||
View in your browser at [http://localhost:3000/](http://localhost:3000/) | ||
|
||
You can also use docker-compose directly: | ||
|
||
``` | ||
docker-compose build | ||
docker-compose up -d postgres | ||
docker-compose run --rm app rake db:setup | ||
docker-compose up -d app | ||
docker-compose logs -f | ||
``` | ||
|
||
To run commands in the context of the container, e.g., `rails console`: | ||
|
||
``` | ||
docker-compose run --rm app rails console | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,24 @@ | ||
db: | ||
image: postgres | ||
ports: | ||
- 5432 | ||
web: | ||
build: . | ||
command: bundle exec thin start | ||
volumes: | ||
- .:/myapp | ||
ports: | ||
- "3000:3000" | ||
links: | ||
- db | ||
version: '2' | ||
|
||
services: | ||
app: | ||
build: . | ||
container_name: columbusrb.com-app | ||
volumes: | ||
- ".:/app" | ||
ports: | ||
- "3000:3000" | ||
links: | ||
- postgres | ||
environment: | ||
DB_NAME: crb_dev_duex | ||
DB_USERNAME: postgres | ||
DB_PASSWORD: password | ||
DB_HOST: postgres | ||
|
||
postgres: | ||
image: postgres:9.6 | ||
container_name: columbusrb.com-postgres | ||
environment: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: password |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
docker-compose run --rm app $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
docker-compose build && \ | ||
docker-compose create postgres && \ | ||
docker-compose up -d postgres && \ | ||
# Sometimes postgres isn't ready by the time the app starts, so take a cat nap. | ||
sleep 2 && \ | ||
docker-compose run --rm app bundle exec rake db:create db:setup && \ | ||
docker-compose up -d app && \ | ||
docker-compose logs -f || \ | ||
docker-compose down # If something fails, make sure the containers are stopped. | ||
|
||
function trap_exit() { | ||
# Allow ctrl-c to stop the script, and also stop the containers. | ||
docker-compose down | ||
exit 2 | ||
} | ||
|
||
trap "trap_exit" 2 |