diff --git a/README.md b/README.md index 27b5526..9991380 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,33 @@ -# reso-web-api-reference-server -RESO Web API and Data Dictionary compliant reference server +# RESO Web API and Data Dictionary compliant reference server + +## Building the server + +In order to run your own local server you need a linux / Unix environment with the following dependencies: + +* Maven +* docker-compose +* wget or curl + +Run the `build.sh` + +This will create everything to run the test server. + +## Running the server + +Run the `run.sh` + +## Access the Server + +Assuming you're running the server locally, go to [http://localhost:8080/RESOservice-1.0/Lookup](http://localhost:8080/RESOservice-1.0/Lookup)\ +Otherwise, you will have to replace `localhost` with the IP of your Docker machine. + +## Running with a different database + +If you set the `SQL_HOST` Environment Variable, then the build script will not build the test database. +It will only build the reference server. + +You will need to configure the following environment variables, so the server can connect to your custom database. + +* SQL_HOST +* SQL_USER +* SQL_PASSWORD diff --git a/build.sh b/build.sh index 5fa2e9d..0536536 100644 --- a/build.sh +++ b/build.sh @@ -1,9 +1,42 @@ #!/bin/bash -wget https://github.com/RESOStandards/web-api-commander/releases/download/current-version/web-api-commander.jar -O temp/web-api-commander.jar -java -jar temp/web-api-commander.jar --generateReferenceDDL --useKeyNumeric > sql/reso-reference-ddl-dd-1.7.numeric-keys.sql +REAL_VAR0=`readlink -f $0` +HOME_DIR=`dirname ${REAL_VAR0}` +TEMP_DIR="${HOME_DIR}/temp" +SQL_DIR="${HOME_DIR}/sql" -mvn compile -mvn package +# Ensure we have directories set up +[ -d "${TEMP_DIR}" ] && echo "temp directory found." || mkdir ${TEMP_DIR} +[ -d "${SQL_DIR}" ] && echo "sql directory found." || mkdir ${SQL_DIR} -docker-compose build +if [ -z "${SQL_HOST}" ] +then + # Get the Web API Commander, needed to generate the test database + if ! wget https://github.com/RESOStandards/web-api-commander/releases/download/current-version/web-api-commander.jar -O temp/web-api-commander.jar + then + echo "WGET not installed. trying CURL." + if ! curl -L https://github.com/RESOStandards/web-api-commander/releases/download/current-version/web-api-commander.jar --output temp/web-api-commander.jar + then + echo "CURL not installed. Exiting build." + exit + fi + fi + + java -jar temp/web-api-commander.jar --generateReferenceDDL --useKeyNumeric > sql/reso-reference-ddl-dd-1.7.numeric-keys.sql +else + COMPOSE_FILE="docker-compose.yml" +fi + +if ! mvn compile +then + echo "Maven could not be found." + exit +else + mvn package +fi + +if ! docker-compose build +then + echo "docker-compose could not be found. You may need to install with pip." + exit +fi diff --git a/optional/docker-db-compose.yml b/optional/docker-db-compose.yml index d6b727f..7a16054 100644 --- a/optional/docker-db-compose.yml +++ b/optional/docker-db-compose.yml @@ -3,7 +3,7 @@ services: docker-mysql: restart: always container_name: docker-mysql - image: mysql + image: mysql/mysql-server command: --default-authentication-plugin=mysql_native_password environment: MYSQL_DATABASE: reso_data_dictionary_1_7 diff --git a/pom.xml b/pom.xml index 8a1b1a8..d483a3e 100644 --- a/pom.xml +++ b/pom.xml @@ -90,7 +90,7 @@ ${junit.version} test - + com.fasterxml.jackson.core jackson-annotations