- Docker
- Postman (for easy api querying)
- Type
cd restaurantscores-server
at the root of this project. - To build, tag, and push the restaurantscores-server docker image, run
gradlew buildAndTagImage --console=plain --stacktrace -PdockerImageVersion=YOUR_VERSION -PpathToRepos=/path/to/empty.json
. ThepathToRepos
property should be .json file containing a map of key:value pairs where the value is the remote repository name. You can create an empty json file containing an empty map i.e.{}
to skip the remote tagging/pushing steps - To just build the restaurantscores-server image, run
gradlew docker --console=plain --stacktrace -PdockerImageVersion=YOUR_VERSION
- Note: the --console and --stacktrace flags are for troubleshooting purposes
- To manually build this image i.e. with the docker commands, this application takes in two build args.
- Here's a sample working command:
gradlew clean bootJar && docker build --build-arg JAR_FILE=build/libs/restaurantscores-server-0.0.1-SNAPSHOT.jar --build-arg PORT=8080 -t restaurantscores-server:YOUR_VERSION -f docker/Dockerfile .
- Be mindful of the path depending on your OS
- Here's a sample working command:
- This application relies on environment variables for the app and the database to start.
- You will need to provide the .env file paths in the docker-compose.yml file or modify the yaml file directly. For an overview of what environment variables are required, review Requirements.txt as a sample .env file.
- postgres:latest db environment variable requirements:
- POSTGRES_DB=healthinspections
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=YOUR_PASSWORD
- restaurant-scores:latest environment variable requirements:
- JDBC_DATABASE_URL -> the url to your postgres db. To use the dockerized postgresql container, update this environment var to look like
JDBC_DATABASE_URL=jdbc:postgresql://restaurantscores-db:5432/healthinspections
. - JDBC_DATABASE_USERNAME and JDBC_DATABASE_PASSWORD should be db username and password. Note: POSTGRES_PASSWORD needs to match JDBC_DATABASE_PASSWORD.
- RELATIVE_PATH_TO_PAGE_STORAGE needs to be a relative path that ends in a slash
- APP_DATA_FOLDER needs to be a fully qualified path that does not end in a slash. The two are concatenated in firebase data
- JDBC_DATABASE_URL -> the url to your postgres db. To use the dockerized postgresql container, update this environment var to look like
- In the restaurantscores-server/docker/docker-compose.yml file, update the restaurantscores-server.image setting to point to your local or remote image e.g.
restaurantscores-server:YOUR_VERSION
. - At the root of the project, open a Terminal tab and type
cd docker
. Then, typedocker-compose up
to start the containers. To gracefully shut down, typedocker-compose down
- Type
docker ps
at your terminal and you should see the restaurantscores-server app is UP. - Alternately, ping
http://localhost:8080/restaurantscores/actuator/health
and you should get a 200 http status code response back and status with a value of 'UP'
- This is a web service that can perform the following actions
- fetches 10 webpages from http://publichealthathens.com/wp/programs/restaurantinspections/
- processes the downloaded files and stores the data into the postgresql database. The database model is referenced below:
- offers apis to query the processed data (review the exposed endpoints in the *Controller.java classes and select *ControllerTest.java classes
- Optionally, there are endpoints to push the data in the postgresql datastore to Firebase and Heroku Bonsai. These rely on your own Google|Heroku api keys/secrets.
- The data is transformed for storage into Firebase. Sample of the generated data: firebase data. This data powers a separate project of mine (shameless plug - NorthEast Georgia Health Inspection Records Android app )
- The Heroku push requires the Bonsai addon and the creation of a
restaurants
index. This is used to power searching for the aforementioned Android app.
- The postgresql database is accessible at port 5433 (configured in the docker-compose yaml file). If using pgAdmin to connect to the database, you'll get a series of alarming alerts because the admin pack extension is not installed. You can still browse the database once you get past the alerts.
- This application runs on post 8080 (see docker-compose.yml to change this setting.
- The context of this application is
/restaurantscores
and the active spring profile ispostgresql
- Please create a github issue with detailed logs and steps to reproduce.