Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[refs #28500babc311]
- Loading branch information
Showing
5 changed files
with
67 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
FROM ruby:2.4.3 | ||
|
||
RUN apt-get update && apt-get install -y postgresql-client | ||
|
||
WORKDIR /tmp | ||
COPY Gemfile* ./ | ||
RUN bundle install | ||
|
||
WORKDIR /app | ||
COPY . . | ||
|
||
ARG WAIT_FOR_POSTGRES=false | ||
ARG PREPARE_DATABASE=false | ||
|
||
ENV WAIT_FOR_POSTGRES=$WAIT_FOR_POSTGRES PREPARE_DATABASE=$PREPARE_DATABASE | ||
ENV POSTGRES_HOST=localhost POSTGRES_USER=web_app POSTGRES_PASSWORD= | ||
|
||
EXPOSE 9292 | ||
|
||
ENTRYPOINT ["/app/bin/docker-entrypoint.sh"] | ||
CMD ["bundle", "exec", "rackup", "-o", "0.0.0.0"] |
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,11 @@ | ||
#!/usr/bin/env bash | ||
if [ "$WAIT_FOR_POSTGRES" == "true" ]; then | ||
echo Waiting for postgres to start... | ||
while ! pg_isready -h $POSTGRES_HOST > /dev/null; do | ||
sleep 0.5; done | ||
echo ..done | ||
fi | ||
if [ "$PREPARE_DATABASE" == "true" ]; then | ||
bundle exec rake db:create db:migrate | ||
fi | ||
exec "$@" |
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,10 @@ | ||
version: '3.3' | ||
|
||
services: | ||
app: | ||
build: | ||
context: . | ||
volumes: | ||
- ./:/app | ||
ports: | ||
- 9292:9292 |
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,15 @@ | ||
version: '3.3' | ||
|
||
services: | ||
app: | ||
image: jfahrer/demo_web_app:latest | ||
environment: | ||
- POSTGRES_HOST=pg | ||
- POSTGRES_USER=web_app | ||
- POSTGRES_PASSWORD=secret | ||
|
||
pg: | ||
image: postgres:9.6.6-alpine | ||
environment: | ||
- POSTGRES_USER=web_app | ||
- POSTGRES_PASSWORD=secret |
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,10 @@ | ||
#!/bin/bash | ||
docker-compose down | ||
|
||
docker-compose up -d pg | ||
|
||
echo "Setting up the development database" | ||
docker-compose run --rm -e WAIT_FOR_POSTGRES=true app bundle exec rake db:create db:migrate | ||
|
||
echo "Setting up the test database" | ||
docker-compose run --rm -e RACK_ENV=test app bundle exec rake db:create db:migrate |