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:
brew update
brew cask install java
- install maven
- brew install maven
- Create the settings.xml for maven - Follow the steps from here: https://hee-tis.atlassian.net/wiki/display/TISDEV/Maven, also ensure that your public ssh key is on the jenkins azure box
- 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
- brew install mysql
- Install SequelPro → https://www.sequelpro.com/
- 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 your docker machine and elastic search container
Launch the docker quickstart terminal
- 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.
$ eval "$(docker-machine env default)"
- 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 →
script.inline: on script.indexed: on
- create a docker decompose file "docker-compose.yml" in "elasticsearch" with contents →
version: '2' services: elasticsearch: restart: "on-failure:10" image: "elasticsearch:2.4" ports: - "9200:9200" - "9300:9300" command: elasticsearch -Des.network.host=0.0.0.0 environment: JAVA_OPTS: "-Xms1G -Xmx1G" volumes: - ./config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml - ./data:/usr/share/elasticsearch/data
- docker-compose up ( use "-d" option to run in the background)
- 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)
127.0.0.1 local.dev.com local.tis.com
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)
events { worker_connections 1024; } http { server { listen 80; server_name local.dev.com; #jamesh: set $token eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJUcTdvbmNHMVlXUXlMT1FWOFM3NVVvQ3VTak5uczdPQkZJWE1KUm1DMjVRIn0.eyJqdGkiOiI5YjBiM2JkMS04M2NiLTQzNTMtOGIyMi05NjI3NzQ1MjViMjciLCJleHAiOjE0Nzc0OTIzODcsIm5iZiI6MCwiaWF0IjoxNDc3NDkyMDg3LCJpc3MiOiJodHRwczovL2Rldi1hcGkudHJhbnNmb3JtY2xvdWQubmV0L2F1dGgvcmVhbG1zL2xpbiIsImF1ZCI6ImFwaS1nYXRld2F5Iiwic3ViIjoiMDg5MDJhZDItYmMwMC00NTAxLTg2OTAtNmZhMjY0M2JkMmUwIiwidHlwIjoiQmVhcmVyIiwiYXpwIjoiYXBpLWdhdGV3YXkiLCJub25jZSI6IllIWnF4c0VtdWxoN1lxY25zc2xCN0VERURPSG1odU51TE13aVBFM0pVX3ciLCJhdXRoX3RpbWUiOjE0Nzc0OTIwODcsInNlc3Npb25fc3RhdGUiOiJkYTY2ZGVmNy0xNDAyLTRhYTktODViYS1iOTg0ZjEyNWZjMjIiLCJhY3IiOiIxIiwiY2xpZW50X3Nlc3Npb24iOiI1MTBlOGVjOS00OWMxLTRjNGMtOWI0NC05NmM0MTE2YzI3ZGQiLCJhbGxvd2VkLW9yaWdpbnMiOlsiaHR0cHM6Ly9kZXYtYXBpLnRyYW5zZm9ybWNsb3VkLm5ldCIsImh0dHBzOi8vYXBwcy5saW4ubmhzLnVrIiwiaHR0cDovL2xvY2FsaG9zdDo4MDg3IiwiaHR0cHM6Ly9zdGFnZS1hcHBzLmxpbi5uaHMudWsiXSwicmVhbG1fYWNjZXNzIjp7InJvbGVzIjpbIlJWQWRtaW4iLCJ1bWFfYXV0aG9yaXphdGlvbiJdfSwicmVzb3VyY2VfYWNjZXNzIjp7ImFjY291bnQiOnsicm9sZXMiOlsibWFuYWdlLWFjY291bnQiLCJ2aWV3LXByb2ZpbGUiXX19LCJyb2xlcyI6IltvZmZsaW5lX2FjY2VzcywgbWFuYWdlLWFjY291bnQsIHZpZXctcHJvZmlsZSwgUlZBZG1pbiwgdW1hX2F1dGhvcml6YXRpb25dIiwibmFtZSI6IkphbWVzIEh1ZHNvbiIsImdyb3VwcyI6IltvZmZsaW5lX2FjY2VzcywgbWFuYWdlLWFjY291bnQsIHZpZXctcHJvZmlsZSwgUlZBZG1pbiwgdW1hX2F1dGhvcml6YXRpb25dIiwicHJlZmVycmVkX3VzZXJuYW1lIjoiamFtZXNoIiwiZ2l2ZW5fbmFtZSI6IkphbWVzIiwiZmFtaWx5X25hbWUiOiJIdWRzb24ifQ.UWJo6Gsa-svoyZrIPMS0NbuwPYYJD9trgCFF9hC74QVoITSZXRct5khq36yQU0WcQaTFG3EDBxbxvJC1XqEvxTyruxU2idA9RpA3XaJmb8p0VfhP8PWhAvtCOp6zYeQK-ovduFpzeF_txvb5yENifFZer7brhmqQc3fpOUjO3DJ3i2xmHRUVj0Mpz0WSmfClQ3KpEXQFjOWa5FYi-UrXkzyhaGuS-8G4Cm_DF9rtOh--hbaWrD4VM0l0hdPMYquz7bEeu46Kr38Ob-alsSDd9ZVuqr91VyybLjafEPI9g5A5-vtDyNHwUY1A8JvC2Lqo5ihXycpUq7PKnj1d_i2I7g; location / { proxy_pass http://127.0.0.1:9000; } location /admin { proxy_pass http://127.0.0.1:4200; proxy_pass_request_headers on; } # Proxy the Websocket connection to the Webpack server. location /sockjs-node/ { proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; rewrite ^/(.*)$ /$1 break; proxy_set_header Host localhost; proxy_pass http://localhost:4200/; } location /revalidation { proxy_pass http://127.0.0.1:28080; proxy_set_header OIDC_access_token $token; proxy_pass_request_headers on; } location /concerns { proxy_pass http://127.0.0.1:28084; proxy_set_header OIDC_access_token $token; proxy_pass_request_headers on; } location /connection-discrepancies { proxy_pass http://127.0.0.1:8095; proxy_set_header OIDC_access_token $token; proxy_pass_request_headers on; } location /reference { proxy_pass http://127.0.0.1:28088; proxy_set_header OIDC_access_token $token; proxy_pass_request_headers on; } location /profile { proxy_pass http://127.0.0.1:8082; proxy_set_header OIDC_access_token $token; proxy_pass_request_headers on; } location /common { rewrite /common/(.*) /$1 break; proxy_pass http://127.0.0.1:8085; } location /notifications { proxy_pass http://127.0.0.1:28092; proxy_set_header OIDC_access_token $token; proxy_pass_request_headers on; } location /tcs { proxy_pass http://127.0.0.1:28093; proxy_set_header OIDC_access_token $token; proxy_pass_request_headers on; } location /tracking { rewrite /tracking/(.*) /$1 break; proxy_pass http://127.0.0.1:8091; } location /fonts { proxy_pass http://127.0.0.1:8085; } location /favicon.ico { proxy_pass http://127.0.0.1:8085/favicon/favicon.ico; } location /favicon-16x16.png { proxy_pass http://127.0.0.1:8085/favicon/favicon-16x16.png; } location /favicon-32x32.png { proxy_pass http://127.0.0.1:8085/favicon/favicon-32x32.png; } } include servers/*; }
Set environment variables
vi ~/.bash_profile → insert the following(change the file paths where necessary to match your machine):
export TIS_ENV=development export REVALIDATION_CONTEXT_ROOT=revalidation export PROFILE_CONTEXT_ROOT=profile export CONCERNS_CONTEXT_ROOT=concerns export REFERENCE_CONTEXT_ROOT=reference export TRAINEE_CONTEXT_ROOT=trainee-id export LOCALHOST_URL=http://local.dev.com export ES_HOST=192.168.99.100 (or localhost) #export ES_HOST=localhost #You may need to use this line if your using docker native export INSPECTLET_ENABLED=false export INSPECTLET_ACCOUNT=851503328 #If you wish to enable inspectlet #export INSPECTLET_ENABLED=true #export INSPECTLET_ACCOUNT=547111913 export CONCERNS_SERVICE_ENDPOINT=http://localhost:8084/concerns/concern-id export LOG_DIR=/<YOUR WORKSPACE PATH>/logs export CHROME_DRIVER_HOME=/usr/local/Cellar/chromedriver/2.26/bin/
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:
create database heetiscleardbconcerns; #create database heetiscleardbprofile; no longer needed as jhipster uses profile db #create database heetiscleardbreference; no longer needed as jhipster uses reference db create database heetiscleardbrevalidation; create database heetiscleardbtraineeid; create database heetiscleardbnotification; create database reference; create database profile; create database tcs; create database connectiondiscrepancy;
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
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
Setup an RO user on your local DB:
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
('jamesh', 'James', 'Hudson', '1000000', NULL , 'james@fake.email.com', 1);
INSERT INTO `UserDesignatedBody` (`userName`, `designatedBodyCode`)
VALUES
('jamesh', '1-85KJU0');
INSERT INTO `UserRole` (`userName`, `roleName`)
VALUES
('jamesh', 'ConcernsAdmin'),
('jamesh', 'RVAdmin');
Shell script to automate running the application
Install
Optional
- iTerm2 - https://www.iterm2.com/ - according to ttab's docs it works natively with mac osx's terminal app
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.
#!/bin/bash # SCRIPT VARIABLES - UPDATE THESE TO SUIT YOUR ENV WORKSPACE=/Users/paul/Dev/Projects/nhs/code # 1. start docker and run elastic search - choose either 1.1 or 1.2 # 1.1 PRE DOCKER FOR MAC USING VIRTUAL MACHINES #docker-machine start default #eval "$(docker-machine env default)" #docker start 50c07680dfb1 #docker ps # 1.2 DOCKER FOR MAC - NATIVE cd $WORKSPACE/elasticsearch docker-compose down docker-compose up -d # 2. run nginx ttab -t 'nginx' -d "$WORKSPACE" 'nginx:stop; nginx:start' # 3. run MYSQL ttab -t 'mysql' -d "$WORKSPACE" 'mysql:stop; mysql:start' # 4. run commonComponents ttab -t 'commonComponents' -d "$WORKSPACE/TIS-COMMON-COMPONENTS" 'git pull' # 5. run common ttab -t 'common' -d "$WORKSPACE/TIS-COMMON/front-end" 'git pull; npm install; npm update; bower update; bower install; grunt prod; grunt serve' # 6. run gmcConnect ttab -t 'gmcConnect' -d "$WORKSPACE/TIS-GMC-CONNECT" 'git pull; boot' # 7. run profile ttab -t 'profile' -d "$WORKSPACE/TIS-PROFILE" 'git pull; mvn clean install; mvn -pl profile-service spring-boot:run' # 8. run revalidation ttab -t 'revalidation' -d "$WORKSPACE/TIS-REVALIDATION" 'git pull; npm update; npm install; bower update; bower install; boot' # 9. run concerns ttab -t 'concerns' -d "$WORKSPACE/TIS-CONCERNS" 'git pull; boot' # 10. run grunt serve for concerns ttab -t 'grunt serve concerns' -d "$WORKSPACE/TIS-CONCERNS" 'npm update; npm install; bower update; bower install; grunt serve' # 11. open fresh tab for git ttab -t 'git' -d "$WORKSPACE/TIS-CONCERNS" 'git status' # 12. open new tab for Reference service ttab -t 'reference' -d "$WORKSPACE/TIS-REFERENCE" 'git pull; boot' # 13. open new tab for Notifications service ttab -t 'notifications' -d "$WORKSPACE/TIS-NOTIFICATIONS" 'git pull; boot' # 14. inspectlet ttab -t 'inspectlet' -d "$WORKSPACE/TIS-INSPECTLET/front-end" 'git pull; npm install; bower update; bower install; grunt serve'
- Reload .bash_profile via source ~/.bash_profile.
- Make the script executable with chmod +x runDev.sh
- Run the shell script by its alias runDev
0 Comments