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 windows package manager chocolatey

- Install chocolatey win package manager

  • Install chocolatey by downloading it from this link (https://chocolatey.org/install) and completing the installation steps
  • Run a PowerShell terminal as an administrator and type in the following commands

                 Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

                 iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex

  • Check the installed version of chocolatey on your machine by using the command  - > chocolatey -v

If you encounter any issues while installing any of the following packages, disable your windows antivirus

- Install chocolatey packages

The majority of packages required can be installed automatically using the following Chocolatey config file and the command - > choco install <path-to-config-file> -y

View file
nametis-dev-packages.config
height250

- Install node packages

  • In a new cmd terminal, check the installed version node on your machine by using the command  - > npm -v
  • Install grunt by typing in the command - > npm install -g grunt
  • Install grunt-cli by typing in the command - > npm install -g grunt-cli
  • Install bower by typing in the command - > npm install -g bower
  • Install karma-cli by typing in the command - > npm install -g karma-cli
  • Install gulp by typing in the command - > npm install -g gulp

- Install mysql (Run docker image)

Use:

docker run --name nhs -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -d mysql:5.7

Then in a terminal, run:

docker start nhs

- Reboot system

Setup your docker machine and elastic search container

- Setup your docker machine and your terminal → https://docs.docker.com/machine/reference/env/

  • Open new command prompt without PowerShell and run the following commands

          docker-machine create --driver virtualbox dev

          docker-machine ls 

          N.B. If this tells you the docker-machine is "stopped", run  docker-machine restart dev (Happens if you have to reboot your PC for some reason)

The next set of instructions (between the asterisks) work when using  cmd prompt as an administrator (i.e. right click the cmd prompt icon and click on 'Run as administrator'). Also, they won't work if you are using elevated PowerShell.

******

  • Run the following commands

          docker-machine.exe env --shell cmd dev

  • Copy the text below (update the relevant values for your IP and username) and run in the command prompt (p.s. ensure that there are no trailing spaces at the end of each command)

          set DOCKER_TLS_VERIFY=1

          set DOCKER_HOST=tcp://<your host IP here>:2376

          set DOCKER_CERT_PATH=C:\Users\<your win user here>\.docker\machine\machines\dev

          set DOCKER_MACHINE_NAME=dev

- Create an Elastic Search docker container

  • Create a folder and call it 'docker' in your local directory (i.e. C:\docker)
  • Create a file of type 'File' and call it 'Dockerfile'. Paste the command below in the newly created file and save it in the C:\docker folder

          FROM elasticsearch:2.4

  • In command prompt, change your working directory 'C:\docker' and type in the following command (please include the dot at the end of command)

          docker build -t elasticsearch:2.4 . 

  • To get the image ID, type in the following command

          docker images 

  • Make a note of the image ID, insert it into the command below before typing it into the command prompt

          docker run -p 9200:9200 -p 9300:9300 -d <insert image ID here> 

  • Verify that the conatainer is running by typing in following command

          docker ps 

  • Additionally, pasting http://192.168.99.100:9200/ into a google chrome browser should get an elastic search REST response

******

Set your windows hosts file

  • Find your 'hosts' file by navigating to the following location - > C:\Windows\System32\drivers\etc\hosts

          Insert the line below into the file (use any initial you want as long as it matches your nginx conf below)

Code Block
127.0.0.1       localhost local.<YOUR_INITIALS>.com local.dev.com local.tis.com

          Windows has a lovely "feature" built in which can mean the line on the hosts file gets ignored. See this article for more info. To get round it, just type the line in manually. You may need to run notepad as administrator and open the file from within there to be able to save it.

Configure your NGINX proxy

  • Locate your nginx.conf file - it should be inside this folder - > C:\ProgramData\Chocolatey\lib\nginx\tools\nginx-1.12.0\conf
  • Open the file and replace the http { ... } section with (please note that your server name must match the host name (i.e. YOUR_INITIALS) you set above)

          NB If you copy and paste the text from here, you will get hidden characters included in the file which will generate errors when you try to run nginx. http://www.cs.toronto.edu/~krueger/csc209h/tut/line-endings.html It is better to copy the entire conf file over you your folder to replace the

          existing one.

         

View file
namenginx.conf
height250

Open the file (you will need to run notepad as administrator and open the file from there) and replace alxd with your initials (or whatever you used in the host file in local.<initials>.com)

Code Block
events {
    worker_connections  1024;
}


http {
 server {   
 listen       80;
 server_name local.tis.nhs.uk;

#jamesh:
set $token eyJhbGciOiJSUzI1NiIsInR5cCIgOiiAiSldUIiwia2lkIiA6ICJUcTdvbmNHMVlXUXlMT1FWOFM3NVVvQ3VTak5uczdPQkZJWE1KUm1DMjVRIn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ibmFtZSI6IkphbWVzIEh1ZHNvbiIsImdyb3VwcyI6IltvZmZsaW5lX2FjY2VzcywgbWFuYWdlLWFjY291bnQsIHZpZXctcHJvZmlsZSwgUlZBZG1pbiwgdW1hX2F1dGhvcml6YXRpb25dIiwicHJlZmVycmVkX3VzZXJuYW1lIjoiamFtZXNoIiwiZ2l2ZW5fbmFtZSI6IkphbWVzIiwiZmFtaWx5X25hbWUiOiJIdWRzb24ifQ.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;
    }
	location /trainee {
       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 /assessments {
       proxy_pass http://127.0.0.1:28097;
       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/*;
}

One you have edited the file, make sure you can start nginx.

  • Open a cmd prompt as administrator, cd to the nginx folder (e.g. C:\ProgramData\chocolatey\lib\nginx\tools\nginx-1.12.0) and type start nginx. A window should appear that stays open:

        Image Removed

        If the window opens and closes immediately, there is something wrong with the conf file (most likely) See http://nginx.org/en/docs/windows.html for more info. Having mentioned that, this does not imply that nginx hasn't started

        running. To verify that nginx has started, go to the windows task manager where you should see two nginx.exe instances under the processes tab.

Set environment variables

Open up an admin privileges command prompt and copy paste - Please change the LOCALHOST_URL and LOG_DIR to match your local env:

setx TIS_ENV "staging"
setx REVALIDATION_CONTEXT_ROOT "revalidation"
setx PROFILE_CONTEXT_ROOT "profile"
setx CONCERNS_CONTEXT_ROOT "concerns"
setx REFERENCE_CONTEXT_ROOT "reference"
setx CONNECTION_DISCREPANCIES_CONTEXT_ROOT "connection-discrepancies"
setx LOCALHOST_URL "http://local.YOUR_INITIALS.com"
setx ES_HOST localhost
setx INSPECTLET_ENABLED "false"
setx INSPECTLET_ACCOUNT "851503328"
setx CONCERNS_SERVICE_ENDPOINT "http://localhost:8084/concerns/concern-id"
setx LOG_DIR "C:\dev\logs"

Create databases

In a command prompt:

mysql -u root
create database esr;
create database heetiscleardbconcerns;
create database profile;
create database reference;
create database heetiscleardbrevalidation;
create database heetiscleardbtraineeid;
create database heetiscleardbnotification;
create database tcs;
create database connectiondiscrepancy;

SSH

Generate a public/private ssh key pair (https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/) and provide the public key to the git admin within the team. Add the public key to your git account (Settings > SSH and GPG keys > New SSH Key)

Now follow the guide on the /wiki/spaces/TISDEV/pages/31981641 page.

If there are issues with SSH, you can set up your repos to use https instead https://help.github.com/articles/changing-a-remote-s-url/

Check out and build the git repository

You may have to rename the npm file inside: C:\Program Files\nodejs (maven executor plugin get's confused and tries to run it instead of npm.cmd)
You may also have to rename bower and grunt files inside: C:\Users\<Your User Account>\AppData\Roaming\npm (same reason as above)

^ this is the case when building TIS-NOTIFICATIONS package ^

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: 

You need to be granted access to Github by devops. You will need a Github account - provide your username to whoever has the admin rights. You will need to upload your own SSH public key to your profile to access Github.

Checkout repos from : https://github.com/Health-Education-England as you need them.

TIS-SHARED-MODULES

Go into the repo and click the Clone or Download button. Copy the URL to the clipboard

          Image Removed

  • Create a new folder under your windows user account (.i.e. C:\Users\<Your User Account>\TISProject)
  • In a new command prompt, type in the following commands pressing enter after each one 

          cd C:\Users\<Your User Account>\TISProject

          git clone Windows setup is documented on Github here:
https://github.com/Health-Education-England/TIS-SHARED-MODULES.git

          cd TIS-SHARED-MODULES

          mvn clean install

          N.B. You may get errors when running the git clone command on a windows 10 machine - mentioning something about too many environment variables. If so, use Intellij to connect to git

          File > New > Project from Version Control > GitHub and connect using your credentials (set the auth type to password). You should be able to clone from within Intellij. With that done, you

          can then change to the relevant directory and do a maven clean install in a cmd prompt terminal

TIS-COMMON

  • In a new command prompt, type in the following commands pressing enter after each one 

          cd C:\Users\<Your User Account>\TISProject

          git clone https://github.com/Health-Education-England/TIS-COMMON.git

          cd TIS-COMMON

          cd front-end

          npm install

          bower install

If this gets stuck, you need to make the TIS-COMMON-COMPONENTS repo public (briefly, while you run bower install).

Then make it private again

          grunt dev

          The last line of the output should say "listening on port 8085"

          You can check that TIS-COMMON is running correctly by accessing:

           http://local.YOUR_INITIALS.com/fake and you should get 504 gateway timeout nginx/1.12.0.

           http://local.YOUR_INITIALS.com/common/vendor.js and you should get the js file back

...

  • In a new command prompt, type in the following commands pressing enter after each one 

          cd C:\Users\<Your User Account>\TISProject

          git clone dev-handbook/blob/master/environment-setup/common.md

https://github.com/Health-Education-England/TIS-ADMINS-UI.git

          cd TIS-ADMINS-UI

          npm install

          npm start

TIS-PROFILE

You will need access to the maven repo for this one. Devops need to grant you access to the maven repo using your Git account login (or you may be given one)

You will need to generate a basic auth username and password using the jenkins job called hee-grant-access https://build.tis.nhs.uk/jenkins/job/hee-grant-access/

Build with parameters and enter a username and password.

Update the maven settings conf file to include the code from here: Maven (edit the settings.xml file to include the new username and password)

  • In a new command prompt, type in the following commands pressing enter after each one 

          cd C:\Users\<Your User Account>\TISProject

          git clone https://github.com/Health-Education-England/TIS-PROFILE.git

         cd TIS-PROFILE

          mvn clean install

          cd profile-service

          mvn clean package spring-boot:run

...

  • In a new command prompt, type in the following commands pressing enter after each one 

          cd C:\Users\<Your User Account>\TISProject

          git clone https://github.com/Health-Education-England/TIS-REFERENCE.git

          cd TIS-REFERENCE

          mvn clean install

          cd reference-service

          mvn clean package spring-boot:run

...

  • In a new command prompt, type in the following commands pressing enter after each one 

          cd C:\Users\<Your User Account>\TISProject

          git clone https://github.com/Health-Education-England/TIS-TCS.git

          cd TIS-TCS

          mvn clean install

          cd tcs-service

          mvn clean package spring-boot:run

etc etc

*********************

Run the ETLs

Make sure all packages are running 

TIS-SHARED-MODULES

  • In a new command prompt, type in the following commands pressing enter after each one 

          cd C:\Users\<Your User Account>\TISProject

          git clone https://github.com/Health-Education-England/TIS-SHARED-MODULES.git

          cd TIS-SHARED-MODULES

          git checkout tags/0.0.3

          mvn clean install

TIS-GMC-SYNC

  • In a new command prompt, type in the following commands pressing enter after each one 

          cd C:\Users\<Your User Account>\TISProject

          git clone https://github.com/Health-Education-England/TIS-GMC-SYNC.git

          cd TIS-GMC-SYNC

          mvn clean package spring-boot:run

          You may get an error relating to spring.profiles.active=local (can't remember the error, sorry!).

          You should be able to set the value to "local" by running the command

          clean package spring-boot:run -Drun.jvmArguments=-Dspring.profiles.active=local

          If this doesn't work, to fix, go to intellij, then...find TIS-GMC-SYNC > src > main > resources > application.properties and update the line to say 

          spring.profiles.active=local

          There is also a bug where you need to run the package a second time to get the data (mvn clean install spring-boot:run)

          However, it may not fix it the second time. If this is the case, download a suitable REST client (https://www.getpostman.com/)

          Enter the URL http://192.168.99.100:9200/_all (check the IP matches that of your docker → use "docker-machine ls" in a cmd prompt

          Choose DELETE and click Send

          Rerun mvn clean package spring-boot:run

TIS-INTREPID-REVAL-ETL

  • In a new command prompt, type in the following commands pressing enter after each one 

          cd C:\Users\<Your User Account>\TISProject

          git clone https://github.com/Health-Education-England/TIS-INTREPID-REVAL-ETL.git

          cd TIS-INTREPID-REVAL-ETL

         

          Manually install the sql jar file from archive (extract it into your .m2/repository/com folder - this is C:\Users\<user account?>\.m2 in windows)
         

View file
namemicrosoft.zip
height250

         mvn clean package spring-boot:run

         N.B. You may need to update TIS-INTREPID-REVAL-ETL > src > main > resources > application.properties  so that the line says 

         spring.profiles.active=local

...

To setup the a user on your local DB, do the following

  • Open a local instance of your MySQL workbench, copy and paste the  lines of code below and paste it into a new query window. Ensure that the profile schema is selected (i.e. double click on it)

          and then run the query.

          

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'),
('jamesh', 'ETL'),
('jamesh', 'ProfileAdmin'),
('jamesh', 'RVAdmin'),
('jamesh', 'TisAdmin');
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 `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');

--Add TCS user for writing to some tables:
CREATE USER 'tcs'@'%';
GRANT ALL ON *.* TO 'tcs';

At the end of it all your app should run like so:

      Image Removed

Implications of line endings settings on windows development environment 

Programming on Windows alongside developers who are not (or vice-versa), will usually result in line-ending issues at some point. This is because Windows uses both a carriage-return character and a linefeed character for newlines in its files, whereas Mac and Linux systems use only the linefeed character. Because the team predominantly consists of MAC users, to ensure that the line-ending  issue doesn't occur, apply a one off fix by typing in the following command

           git config --global core.autocrlf input

This fix will leave you with CRLF endings in Windows checkouts, but LF endings on Mac and Linux systems and in the repository.

Things Requiring Attention

...

<groupId>com.transformuk.hee</groupId>
<artifactId>reference-client</artifactId>
<version>2.1.2</version>

...

dev-handbook/blob/main/environment-setup/windows.md

...

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)