Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.DS_Store
*.log
/tmp
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM ruby:2.5.3

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

WORKDIR /app
COPY Gemfile ./
# COPY Gemfile.lock ./

RUN bundle install
COPY ./ ./

COPY entrypoint.sh /usr/bin
RUN chmod +x /usr/bin/entrypoint.sh

ENTRYPOINT ["entrypoint.sh"]
EXPOSE 3000

CMD ["puma -t 1:2 -p ${PORT:-3000} -e ${RACK_ENV:-development}"]
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ruby '2.5.3'
gem 'rake'
gem 'rack'
gem 'cuba'
gem 'activerecord'
gem 'activerecord', '5.1'
gem 'pg', '~> 0.18'
gem 'puma'
gem 'rack-cache'
Expand Down
40 changes: 21 additions & 19 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,38 +1,40 @@
GEM
remote: https://rubygems.org/
specs:
activemodel (5.2.2)
activesupport (= 5.2.2)
activerecord (5.2.2)
activemodel (= 5.2.2)
activesupport (= 5.2.2)
arel (>= 9.0)
activesupport (5.2.2)
activemodel (5.1.0)
activesupport (= 5.1.0)
activerecord (5.1.0)
activemodel (= 5.1.0)
activesupport (= 5.1.0)
arel (~> 8.0)
activesupport (5.1.0)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
i18n (~> 0.7)
minitest (~> 5.1)
tzinfo (~> 1.1)
arel (9.0.0)
concurrent-ruby (1.1.4)
arel (8.0.0)
concurrent-ruby (1.1.5)
cuba (3.9.2)
rack (>= 1.6.0)
dalli (2.7.9)
dalli (2.7.10)
foreman (0.85.0)
thor (~> 0.19.1)
i18n (1.5.3)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
minitest (5.11.3)
oj (3.7.9)
nio4r (2.4.0)
oj (3.8.1)
oj_mimic_json (1.0.1)
pg (0.21.0)
puma (3.12.0)
rack (2.0.6)
puma (4.1.0)
nio4r (~> 2.0)
rack (2.0.7)
rack-cache (1.9.0)
rack (>= 0.4)
rack-ssl (1.4.1)
rack
rake (12.3.2)
rubyzip (1.2.2)
rake (12.3.3)
rubyzip (1.2.3)
thor (0.19.4)
thread_safe (0.3.6)
tzinfo (1.2.5)
Expand All @@ -42,7 +44,7 @@ PLATFORMS
ruby

DEPENDENCIES
activerecord
activerecord (= 5.1)
cuba
dalli
foreman
Expand All @@ -60,4 +62,4 @@ RUBY VERSION
ruby 2.5.3p105

BUNDLED WITH
1.16.6
1.17.3
10 changes: 10 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ https://api-codigos-postales.herokuapp.com/v2/buscar?codigo_postal=6641

___


### Instalación

Para instalar con Docker y Docker Compose:

```sh
$ docker-compose up
# Aplicación en: http://localhost:3000
```

### Rake task
Ejecuta el rake task `rake sepomex:update` para descargar todos los códigos postales de méxico y actualizar tu base de datos.

Expand Down
36 changes: 36 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: '3'
services:
db:
image: postgres
environment:
POSTGRES_PASSWORD: secret

memcached:
image: memcached

app:
build: .
environment:
DATABASE_URL: postgresql://postgres:secret@db:5432/postgres
MEMCACHEDCLOUD_SERVERS: memcached://memcached:11211
volumes:
- .:/app
ports:
- "3000:3000"
depends_on:
- db
- memcached

initdata:
build: .
environment:
DATABASE_URL: postgresql://postgres:secret@db:5432/postgres
MEMCACHEDCLOUD_SERVERS: memcached://memcached:11211
depends_on:
- app
- db
entrypoint: >
/bin/sh -c "
rake sepomex:update
exit 0;
"
11 changes: 11 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
# https://stackoverflow.com/a/38732187/1935918
set -e

if [ -f /app/tmp/pids/server.pid ]; then
rm /app/tmp/pids/server.pid
fi

rake db:migrate

exec bundle exec "$@"