This app is written in Angular 2 with Angular-cli and Docker.
At first, it will be necessary to get and install docker-toolbox, this toolbox has important tools to up, deploy and handle the project.
- Docker Engine
- Docker Compose
- Docker Machine
- Kitematic (Included in Docker Toolbox)
The next step is installing Virtual Box (when this documentation was written the current version was 5.0)
All the necessary components can be installed individually (Docker Engine, Docker Compose, Docker Machine, Virtual Box).
There are three steps to create a new environment
Docker Machine will be responsable to create a virtual environment and after to make deployments, it accepts several drivers, among them, the virtualbox, what's why, we need to run the command below to create the virtual environment or developer environment:
$ docker-machine create --driver virtualbox qedu-provas-front
Due to a file sharing bug in boot2docker
. You should run the following command to correct it.
$ curl -L http://bit.do/dm-lin-home | docker-machine ssh ${MACHINE:-qedu-provas-front} sudo tee /var/lib/boot2docker/bootlocal.sh
$ docker-machine ssh ${MACHINE:-qedu-provas-front} sudo chmod +x /var/lib/boot2docker/bootlocal.sh
$ docker-machine ssh ${MACHINE:-qedu-provas-front} sudo /var/lib/boot2docker/bootlocal.sh
After run this commands, restart your machine to apply the modifications.
After this, we need to tell Docker to talke to the new machine:
$ docker-machine env qedu-provas-front
Enter into the machine:
$ eval "$(docker-machine env qedu-provas-front)"
Need to expose the public so browsers can connect to live reload port:
docker-machine ssh qedu-provas-front -f -N -L 4200:localhost:4200
Docker compose will configure all the containers at the same time and links them in the same infrastructure.
So, after enter into the machine using docker-machine command and run follow:
$ docker-compose -f provision/docker-compose.yml up -d
To get the machine IP, run the follow command:
$ docker-machine ip qedu-provas-front
Define provas.qedu.dev
as hostname, so, put the public ip into local hosts to define a hostname, example:
192.168.99.100 provas.qedu.dev
$ docker exec -it qedu-provas-front bash
Run yarn build
to build the project. The build artifacts will be stored in the dist/
directory. Use the -prod
flag for a production build.
*IMPORTANT*
Some tests fails unexpectedly when running inside docker environment and break the execution. Due this strange behavior, run the tests locally:
Run yarn test
to execute the unit tests via Karma.
Run yarn e2e
to execute the end-to-end tests via Protractor.
Before running the tests make sure you are serving the app via ng serve
.
To get more help on the angular-cli
use ng --help
or go check out the Angular-CLI README.