Front-end application written in Node.js that puts together all of the microservices under microservices-demo.
Platform : Ubuntu 16.04
# Install Pre reqs
sudo apt-get update
sudo apt-get install git wget curl build-essential -yq
# Install Nodejs with NPM
cd /tmp
wget -c https://nodejs.org/dist/v4.8.6/node-v4.8.6-linux-x64.tar.xz
sudo tar -xzf node-v4.8.6-linux-x64.tar.xz -C /usr/local --strip-components=1
ln -s /usr/local/bin/node /usr/local/bin/nodejs
# validation
node --version
nodejs --version
npm --version
cd /opt
git clone https://github.com/microservices-demo/front-end.git
cd front-end/
yarn install
The front-end service can be launched with npm using the following command.
export NODE_ENV=production
npm start
Service will launch on port 8079
Follow common steps from above section.
- Create release directories
mkdir -p /opt/apps/frontend/releases
- Download the latest artifact from this page to the releases directory created above e.g.
cd /opt/apps/frontend/releases
wget -c https://github.com/udbc/front-end/archive/1.0.1.tar.gz
- Extract the artifact
cd /opt/apps/frontend/releases
tar -xzf 1.0.1.tar.gz
ls
front-end-1.0.1
- Create a symlink /opt/frontend pointing to the latest release
e.g.
ln -s /opt/apps/frontend/releases/front-end-1.0.1 /opt/frontend
- Install Dependencies and start the app
cd /opt/frontend
npm install
npm start
You could also use the init script available at path scripts/frontend . You could copy this script to /etc/init.d so that you could start and stop service as,
service frontend start
service frontend stop
Frontend connects with all the backend services using endpoint configurations. These configs are in a file api/endpoints.js
Sample of which is given below.
module.exports = {
catalogueUrl: util.format("http://catalogue%s", domain),
tagsUrl: util.format("http://catalogue%s/tags", domain),
cartsUrl: util.format("http://carts%s/carts", domain),
ordersUrl: util.format("http://orders%s", domain),
customersUrl: util.format("http://user%s/customers", domain),
addressUrl: util.format("http://user%s/addresses", domain),
cardsUrl: util.format("http://user%s/cards", domain),
loginUrl: util.format("http://user%s/login", domain),
registerUrl: util.format("http://user%s/register", domain),
};
===========================
Name | Version |
---|---|
Docker | >= 1.12 |
Docker Compose | >= 1.8.0 |
Make (optional) | >= 4.1 |
npm install
make test-image
make up
Make sure that the microservices are up & running
make test
To make sure that the test suite is running against the latest (local) version with your changes, you need to manually build the image, run the container and attach it to the proper Docker networks. There is a make task that will do all this for you:
make dev
That will also tail the logs of the container to make debugging easy. Then you can run the tests with:
make e2e
npm start
make server
curl http://localhost:8081
curl http://localhost:8080
GROUP=weaveworksdemos COMMIT=test ./scripts/push.sh