From 85e4ddbfa723318f7fcd11f4867cadd352642233 Mon Sep 17 00:00:00 2001 From: Tom Cooling Date: Tue, 16 Jan 2018 08:57:11 +0000 Subject: [PATCH 1/5] Add Dockerfile and .dockerignore file --- .dockerignore | 3 +++ Dockerfile | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..38f3e49 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +node_modules +npm-debug.log +log \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d987c04 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,37 @@ +# https://nodejs.org/en/docs/guides/nodejs-docker-webapp/ +# Need to be able to specify running it as a DEV +# e.g. Need hot reloading +# Note: need .dockerignore file to ignore node modules + +FROM node:6.11.5 + +# Create app directory +WORKDIR /usr/src/app + +# Install app dependencies +# A wildcard is used to ensure both package.json AND package-lock.json are copied +# where available (npm@5+) +COPY package*.json ./ + +RUN npm install +# If you are building your code for production +# RUN npm install --only=production + +# Bundle app source +COPY . . + +EXPOSE 3001 +ENV SERVE_HTML true +ENV NPM_CONFIG_LOGLEVEL info +# 'npm start' will create the static build files and then serve them +CMD [ "npm", "start" ] + +# what to do about long wait after running 'npm run build'? + + +# Commands +# docker build -t bi-ui . +# docker images +# docker run -p 3001:3001 -d bi-ui +# docker ps +# docker logs From f57e1b6d9d8778c5cc1117f3dd76df430b6e6368 Mon Sep 17 00:00:00 2001 From: Tom Cooling Date: Fri, 26 Jan 2018 12:36:26 +0000 Subject: [PATCH 2/5] Add env var to apiGateway config - Use passed in env var for server url, so that we can pass in a docker url --- server/config/urls.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/config/urls.js b/server/config/urls.js index 2fc0047..baac595 100644 --- a/server/config/urls.js +++ b/server/config/urls.js @@ -1,7 +1,7 @@ const urls = { AUTH_URL: process.env.SERVER_AUTH_URL, API_GW: process.env.SERVER_API_GW_URL, - API_URL: 'http://localhost:9000', + API_URL: process.env.API_URL, API_VERSION: 'v1', }; From bbaf142e6ea8605c572af313d818f3190700c6b3 Mon Sep 17 00:00:00 2001 From: Tom Cooling Date: Tue, 6 Mar 2018 09:31:08 +0000 Subject: [PATCH 3/5] Remove misc notes from dockerfile --- Dockerfile | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index d987c04..f6180b1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,4 @@ # https://nodejs.org/en/docs/guides/nodejs-docker-webapp/ -# Need to be able to specify running it as a DEV -# e.g. Need hot reloading -# Note: need .dockerignore file to ignore node modules FROM node:6.11.5 @@ -14,8 +11,6 @@ WORKDIR /usr/src/app COPY package*.json ./ RUN npm install -# If you are building your code for production -# RUN npm install --only=production # Bundle app source COPY . . @@ -23,13 +18,11 @@ COPY . . EXPOSE 3001 ENV SERVE_HTML true ENV NPM_CONFIG_LOGLEVEL info + # 'npm start' will create the static build files and then serve them CMD [ "npm", "start" ] -# what to do about long wait after running 'npm run build'? - - -# Commands +# Useful Docker Commands: # docker build -t bi-ui . # docker images # docker run -p 3001:3001 -d bi-ui From 6d9f173843b31a54178d80e8f29eebe0a9a6d83a Mon Sep 17 00:00:00 2001 From: Tom Cooling Date: Tue, 13 Mar 2018 11:55:20 +0000 Subject: [PATCH 4/5] Update README with better running instructions --- Dockerfile | 13 +++++++++++++ README.md | 23 +++++++++++++++++++---- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index f6180b1..0739608 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,8 +16,20 @@ RUN npm install COPY . . EXPOSE 3001 + +ENV NODE_ENV development ENV SERVE_HTML true ENV NPM_CONFIG_LOGLEVEL info +ENV SERVER_AUTH_URL http://localhost:3002/auth +ENV SERVER_API_GW_URL http://localhost:3002 +ENV API_URL http://localhost:9000 +ENV BI_UI_TEST_ADMIN_USERNAME admin +ENV BI_UI_TEST_ADMIN_PASSWORD admin +ENV BI_UI_TEST_USER_USERNAME test +ENV BI_UI_TEST_USER_PASSWORD test +ENV REACT_APP_ENV local +ENV REACT_APP_AUTH_URL http://localhost:3001 +ENV REACT_APP_API_URL http://localhost:3001/api # 'npm start' will create the static build files and then serve them CMD [ "npm", "start" ] @@ -28,3 +40,4 @@ CMD [ "npm", "start" ] # docker run -p 3001:3001 -d bi-ui # docker ps # docker logs +# docker attach diff --git a/README.md b/README.md index eba0bdf..57871c0 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Install NPM, it is included with Node.js ([Download](https://nodejs.org/en/)) ## Running the UI: -1. Clone this repo and install dependencies +Clone this repo and install dependencies ```shell git clone https://github.com/ONSdigital/bi-ui.git @@ -32,18 +32,33 @@ cd bi-ui npm install ``` -2. Start the `Node.js` server +### Development Setup + +1. Start the `React.js` development server (which uses hot reloading): + +```shell +npm run start:react +``` + +2. Start the `Node.js` server: ```shell npm run start:server ``` -3. Start the `React.js` development server (with hot reloading) +3. Go to [localhost:3000](http://localhost:3000) to see bi-ui. + +### Docker Setup + +1. Build and run the UI inside a Docker container. ```shell -npm run start:react +docker build -t bi-ui . +docker run -p 3001:3001 bi-ui ``` +2. Go to [localhost:3001](http://localhost:3001) to see bi-ui. + ## Running the API * [business-index-api](https://github.com/ONSdigital/business-index-api): From 37f0a88d454a80a92ebf975f4af9683b07e22c7d Mon Sep 17 00:00:00 2001 From: Tom Cooling Date: Tue, 13 Mar 2018 11:59:29 +0000 Subject: [PATCH 5/5] Update Jenkinsfile shared pipeline branch --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index ca3c913..f6d93b5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,5 @@ #!groovy -@Library('jenkins-pipeline-shared@feature/new-cf') _ +@Library('jenkins-pipeline-shared@develop') _ /* * bi-ui Jenkins Pipeline