Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

...

...

Table of Contents


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  ): 

Code Block
brew update 
Code Block
brew tap caskroom/versions
Code Block
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

...

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

...

3. Connect your shell to the default machine.

Code Block
$ eval "$(docker-machine env default)"
Code Block

- 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 → 

Code Block
script.inline: on
script.indexed: on



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

Code Block
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) 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)

Code Block
127.0.0.1 local.tis.nhs.uk  local.trainee.nhs.uk


Configure your NGINX proxy

cd /usr/local/etc/nginx

vi nginx.conf 

...

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

...

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.


Code Block
#!/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

...


Arrange 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)