Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/dockerfile #31

Merged
merged 6 commits into from
Mar 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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