This project is a Ruby on Rails application containerized with Docker. Follow the steps below to set up and run the application on your local machine.
- Docker: Install Docker
- Docker Compose: Install Docker Compose
- Ipstack Access Key: Register on Ipstack and get access key to use
git clone https://github.com/FrancoRodriguez/geolocation-api.git
cd geolocation-api- Environment Variables: Configuration can be managed via environment variables. Ensure you have a .env file in the root directory with the necessary environment variables. Example .env file:
IPSTACK_ACCESS_KEY=<ipstack_access_key>
API_KEY=1298ndsi912n319hd9w1092sn912
RAILS_ENV=production
POSTGRES_USER=franco.rodriguez
DATABASE_HOST=geolocation-api-db
DATABASE_PORT=5432
POSTGRES_PASSWORD=password
RAILS_SECRET=ed8b2812aa947301e4e40a408e7b42122eea2e7b1415f7f0ee6712a8f6a44fc45bc9034519761e1f439f7784a2e93b273dfa5afba52eddd55fd2fec3581fe6e3- Database Configuration: The database configuration is located in config/database.yml. Make sure it aligns with the environment variables in your .env file.
- Ipstack access key: copy and paste the access key from ipstack website
- API KEY: This key is needed to authenticate endpoints with this app
Build the Docker images for the application and its dependencies using:
docker-compose buildStart the application and its service with:
docker-compose upYou can then access the application at http://localhost:3000.
To run tests, use the following command:
docker-compose run api rspecTo run rubocop, use the following command:
docker-compose run api rubocopTo stop the running application and services, use:
docker-compose down- Database Issues: Ensure the database container is running properly. Verify your config/database.yml and .env file for correct configuration.
- Port Conflicts: If port 3000 is already in use, you may need to change the port mapping in the docker-compose.yml file. For example:
ports:
- "3001:3000"- Permission Errors: If you encounter permission errors, make sure the files and directories in your project have the correct permissions and ownership.
The Postman collection for testing the API is stored in the docs/postman directory.
- Open Postman.
- Click on Import in the top-left corner.
- Select the
docs/postman/Geolocations_API.postman_collection.jsonfile from this repository. - The collection will now be available in Postman for testing.