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

Issue 78 dockerizacion #122

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.git*
log/*
tmp/*
Dockerfile
README.md
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@
/config/deploy-secrets.yml

/coverage

# Ignore folder contents (cached gems) but not the folder
/.bundle/*
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM ruby:2.2.2

ENV DEBIAN_FRONTEND noninteractive

ENV APP_PATH /app

# this allows to cache installed gems and have faster bundler
ENV BUNDLE_PATH /bundle

# Install nodejs for execjs and postgres-client for 'rails dbconsole'
RUN apt-get update && apt-get install -y nodejs postgresql-client \
--no-install-recommends && rm -rf /var/lib/apt/lists/*

# Phantomjs
ENV PHANTOM_JS_VERSION 1.9.8-linux-x86_64
RUN apt-get install -y curl bzip2 libfreetype6 libfontconfig \
--no-install-recommends && rm -rf /var/lib/apt/lists/*
RUN curl -sSL https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-$PHANTOM_JS_VERSION.tar.bz2 | tar xjC /
RUN ln -s /phantomjs-$PHANTOM_JS_VERSION/bin/phantomjs /usr/bin/phantomjs

RUN mkdir -p $APP_PATH

WORKDIR $APP_PATH

COPY . $APP_PATH

CMD ./start
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,32 @@ Para ejecutar los tests:
bundle exec bin/rspec
```

## Configuración para desarrollo y tests con Docker
Install docker from the [docker web](http://docs.docker.com/)
Install docker-compose from the [docker-compose instruction page](http://docs.docker.com/compose/install/)

```
docker-compose build
docker-compose run app bash -c 'bundle install && rake db:setup'

```
Para ejecutar la aplicación:
```
docker-compose up -d
```

Para examinar los logs:
```
docker-compose logs
```

Para ejecutar los tests:
```
docker-compose run app bundle exec rspec
```

Se puede ver el correo saliente del contenedor en http://localhost:1080

## Licencia

El código de este proyecto está publicado bajo la licencia MIT (ver MIT-license.md)
Expand Down
27 changes: 27 additions & 0 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,33 @@ Run the tests with:
bundle exec bin/rspec
```

## Configuration for development and test environments with Docker
Install docker from the [docker web](http://docs.docker.com/)
Install docker-compose from the [docker-compose instruction page](http://docs.docker.com/compose/install/)

```
docker-compose build
docker-compose run app bash -c 'bundle install && rake db:setup'

```
Run the app locally:
```
docker-compose up -d
```

Examine logs live:
```
docker-compose logs
```

Run the tests with:
los tests:
```
docker-compose run app bundle exec rspec
```

You can check transactional mail on http://localhost:1080

## Licence

Code published under MIT license (see [MIT-license.md](MIT-license.md))
Expand Down
15 changes: 15 additions & 0 deletions config/database.yml.docker-example
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
default: &default
adapter: postgresql
encoding: unicode
host: db
pool: 5
username: postgres
password:

development:
<<: *default
database: participacion_development

test:
<<: *default
database: participacion_test
2 changes: 1 addition & 1 deletion config/database.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ development:

test:
<<: *default
database: participacion_test
database: participacion_test
10 changes: 8 additions & 2 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@
config.action_mailer.raise_delivery_errors = false
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }

# Deliver emails to a development mailbox at /letter_opener
config.action_mailer.delivery_method = :letter_opener
if ENV['MAILCATCHER_PORT_1025_TCP_ADDR']
# Deliver emails to the mailcatcher container
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = { :address => ENV['MAILCATCHER_PORT_1025_TCP_ADDR'], :port => 1025 }
else
# Deliver emails to a development mailbox at mailcatcher/letter_opener
config.action_mailer.delivery_method = :letter_opener
end

# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
# resources :products
# end

if Rails.env.development?
if Rails.env.development? && ENV['MAILCATCHER_PORT_1025_TCP_ADDR'].blank?
mount LetterOpenerWeb::Engine, at: "/letter_opener"
end
end
21 changes: 21 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
app:
build: .
command: "./start"
volumes:
- .:/app
- .bundle:/bundle
ports:
- "3000:3000"
links:
- db
- mail
environment:
BUNDLE_JOBS: 4
db:
image: postgres
ports:
- "5432"
mail:
image: schickling/mailcatcher
ports:
- "1080:1080"
12 changes: 12 additions & 0 deletions start
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

if [ -f tmp/pids/server.pid ]; then
echo "Removing old pid's, please stop containers with 'docker-compose stop'"
rm -f tmp/pids/server.pid
fi

echo "Checking bundle dependencies..."
bundle check || bundle install

echo "Booting up..."
exec bundle exec rails s -p 3000 -b 0.0.0