Development set up on Mac



Install the tools you will need with the mac package manager homebrew

Install homebrew:

  • /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Install java8 ( the second command is required since java8 is no longer the default on macos  ): 

brew update
brew tap caskroom/versions
brew cask install java8

- install maven

- install git

  • brew install git

install yarn

  • brew install yarn

- install node + packages

  •  

    • brew install node

  • npm -v

  • npm install -g grunt

  • npm install -g grunt-cli

  • npm install -g bower

  • npm install -g karma-cli

  • npm install -g gulp

- install mysql

- install docker

If you have docker installed via homebrew, uninstall it: brew uninstall docker
download and install docker toolbox: https://www.docker.com/products/docker-toolbox


- install nginx

  • brew install nginx

  •  nginx -v

Setup Maven

See page: Maven

Setup your docker machine and elastic search container

Launch the docker quickstart terminal

Note: If you have the correct Docker installed (https://www.docker.com/community-edition#/download) you can skip the following 3 steps. To uninstall old versions of Docker please following this link: https://qiita.com/tnir/items/6b2caf018726c590cf92

  1. Create a new Docker VM.

docker-machine create --driver virtualbox default

2. Set the environment variable

docker-machine env default

3. Connect your shell to the default machine.

- create an Elastic Search docker container

  • create a folder "elasticsearch" in your preferered location

  • create subfolder "config" in the created "elasticsearch" folder

  • create subfolder "data" in the created "elasticsearch" folder

  • create a file called "elasticsearch.yml" in "config" folder with the contents → 





  • create a docker decompose file "docker-compose.yml" in "elasticsearch" with contents → 



  • docker-compose up  ( use "-d" option to run in the background) or sudo docker-compose up if you get "oci runtime errors" 

  • docker ps → verify the container is running

  • in a Chrome browser http://192.168.99.100:9200/ (localhost:9200 if your using docker for mac - native) - you should get an elastic search REST response

Set your mac hosts file

vi /etc/hosts → insert the line (use whatever host name you want you need to match it with your nginx conf below)



Configure your NGINX proxy

cd /usr/local/etc/nginx

vi nginx.conf 

Open the file and replace the http { ... } section with (please note that your server name must match the host name you set above)



Set environment variables



vi ~/.bash_profile → insert the following(change the file paths where necessary to match your machine):



Create databases

To start mysql database use following command

mysql.server start

Start up your sequel pro and connect to localhost (127.0.0.1) default port username root with no password

Then create the databases:


Check out and build the git repos

Build projects (it will take long the first time cause of maven and npm downloads) - please note you will need to run them in separate terminals as instructed below: 
cd <path to ws here>/TIS-SHARED-MODULES
git pull
mvn clean install
cd <path to ws here>/TIS-COMMON
git pull
cd front-end

npm install

bower install
grunt dev 
-> new terminal 
cd <path to ws here>/TIS-GMC-CONNECT
git pull
mvn clean package spring-boot:run
-> new terminal 
cd <path to ws here>/TIS-PROFILE
git pull

mvn clean install

cd profile-service
mvn clean package spring-boot:run

-> new terminal 

cd <path to ws here>/TIS-NOTIFICATIONS

git pull

mvn clean package spring-boot:run

-> new terminal

cd <path to ws here>/TIS-CONCERNS
git pull
mvn clean package spring-boot:run

-> new terminal 
cd <path to ws here>/TIS-TCS
git pull

mvn clean install

cd tcs-service
mvn clean package spring-boot:run


-> new terminal 
cd <path to ws here>/TIS-REFERENCE
git pull

mvn clean install

cd reference-service
mvn clean package spring-boot:run
-> new terminal (optional)
cd <path to ws here>/TIS-INSPECTLET/
git pull
cd front-end/
npm install
bower update
grunt serve
-> new terminal 
cd <path to ws here>/TIS-REVALIDATION
git pull
mvn clean package spring-boot:run
*********************

Run the ETL's


-> new terminal
cd /Users/Alex/ws/hee_tis/TIS-GMC-SYNC
git pull

mvn clean spring-boot:run -Dspring.profiles.active=local

cd <path to ws here>/TIS-INTREPID-DR-ETL

git pull

mvn clean spring-boot:run -Dspring.profiles.active=local

After running the etl test if the elastic search indexes have been created properly. In your browser or rest client do a get on:

http://loalhost:9200/revalidations/?pretty

You are looking for: 

"designatedBodyCode": {
"type": "string",
"index": "not_analyzed"
},

If the designated body code is missing the "not_analyzed" entry then you won't see any data inside revalidation (it's an intermittent bug that we have not been able to fix). To fix it just delete the elastic search indexes:

curl -XDELETE "http://localhost:9200/_all"

Then rerun the ETL.

Setup an RO user on your local DB: 



INSERT INTO `HeeUser` (`name`, `firstName`, `lastName`, `gmcId`, `phoneNumber`, `emailAddress`, `active`)
VALUES
('jamesh', 'James', 'Hudson', '1000000', '7788996655', 'jamesh@fake.com', 1);
INSERT INTO `UserRole` (`userName`, `roleName`)
VALUES
('jamesh', 'ConcernsAdmin');
INSERT INTO `UserDesignatedBody` (`userName`, `designatedBodyCode`)
VALUES
('jamesh', '1-AIIDR8'),
('jamesh', '1-AIIDSA'),
('jamesh', '1-AIIDVS'),
('jamesh', '1-AIIDWA'),
('jamesh', '1-AIIDWI');



insert into Role values ('SuperUser');
INSERT INTO `RolePermission` (`roleName`, `permissionName`) 
SELECT 'SuperUser' as 'roleName', `name` as 'permissionName'
FROM `Permission`;

delete from RolePermission where permissionName = 'revalidation:submit:to:gmc' and roleName = 'SuperUser';


INSERT INTO `UserRole` (`userName`, `roleName`)
VALUES
('jamesh', 'SuperUser');



INSERT INTO `HeeUser` (`name`, `firstName`, `lastName`, `gmcId`, `phoneNumber`, `emailAddress`, `active`)
VALUES
('local_ro', 'local', 'RO', '1234567', NULL , 'local.ro@fake.email.com', 1);
INSERT INTO `UserDesignatedBody` (`userName`, `designatedBodyCode`)
VALUES
('local_ro', '1-85KJU0');

INSERT INTO `UserRole` (`userName`, `roleName`)
VALUES
('local_ro', 'RVOfficer');



INSERT INTO `HeeUser` (`name`, `firstName`, `lastName`, `gmcId`, `phoneNumber`, `emailAddress`, `active`)
VALUES
('gmc_etl', 'local', 'RO', '1234567', NULL , 'local.ro@fake.email.com', 1);

INSERT INTO `UserRole` (`userName`, `roleName`)
VALUES
('gmc_etl', 'ETL');





Shell script to automate running the application

Install


Optional



Below are a list of useful aiiases to add to your ~/.bash_profile or ~/.bash_aliases. Not all are required but if you dont use them all then tweak your shell script accordingly.


  • Replace the shell script path in the runDev alias as per your machine config.

  • Replace the XXXXX password with your machine password. This is to automatically enter in the password when prompted as sudo command is used. 

    • Note - you can skip this but tweaks plus a password prompt is required.

    • Additional Note - If you use special characters in your password, you may need to replace the double quotes with back ticks e.g. 'echo `XXXXX` | ...


# aliases
alias runDev='source ~/Sites/HEE/runDev.sh'
alias boot='mvn clean spring-boot:run'
alias boot:test='mvn clean spring-boot:run -Dspring.profiles.active=testData'
alias nginx:start='echo "XXXXX" | sudo -S nginx'
alias nginx:stop='echo "XXXXX" | sudo -S nginx -s stop'
alias mysql:start='mysql.server start;'
alias mysql:stop='mysql.server stop;'



Create the shell script and place it in your preferred location. 

  • Tweak as needed - i.e the directory paths to the apps/dependencies or removing/adding terminal tabs etc.





  • Reload .bash_profile via source ~/.bash_profile.

  • Make the script executable with chmod +x runDev.sh

  • Run the shell script by its alias runDev




Arrange to have their laptop's MAC address added to the whitelist. This is to bypass content filtering in London. If in doubt, ask @John Simmons (Deactivated)