Build an rails-API to query zipcode by given gps, and encapsulate the system into docker.
- Install docker
- Run
docker-compose up
, this process takes about 10 minutes to build the index.
It will display the process of data import and indexing like
db-seed_1 | 2017-12-15T23:23:37.907+0000 [##......................] zipcode_finder_development.zipcodes 73.4MB/588MB (12.5%)
And when it finishes, it will show a message
database initialization finished...
- Aceess api via
http://localhost:3000/zipcode?lat=40.6402399&lng=-74.44
and it should return json response
{
zipcode: "07069"
}
if there's no result or there's an error, it should return
{
zipcode: "No result"
}
- After
docker-compose up
and finishing index, you can useCrtl C
to stop it. - Run
docker-compose start
to restart the api. - Stop by running
docker-compose stop
.
US zipcode boundary shape files from Census Bureau
Download the shape files and convert them to json files.
- This project can be easily deployed in some computers that don't have rails and mongodb.
- The json data of zipcode boundary can be stored into the container and automatically imported into mongodb.