Skip to content

Commit

Permalink
Feature/dockerfile (#31)
Browse files Browse the repository at this point in the history
* Add Dockerfile and .dockerignore file

* Add env var to apiGateway config

- Use passed in env var for server url, so that we can pass in a docker url

* Remove misc notes from dockerfile

* Update README with better running instructions

* Update Jenkinsfile shared pipeline branch
  • Loading branch information
ONS-Tom authored and ONS-Anthony committed Mar 13, 2018
1 parent cf1e85d commit e2bd3b6
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
npm-debug.log
log
43 changes: 43 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# https://nodejs.org/en/docs/guides/nodejs-docker-webapp/

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

# Bundle app source
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" ]

# Useful Docker Commands:
# docker build -t bi-ui .
# docker images
# docker run -p 3001:3001 -d bi-ui
# docker ps
# docker logs <container id>
# docker attach <container id>
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,41 @@ 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
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):
Expand Down
2 changes: 1 addition & 1 deletion server/config/urls.js
Original file line number Diff line number Diff line change
@@ -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',
};

Expand Down

0 comments on commit e2bd3b6

Please sign in to comment.