A Dockerfile to create and run an Angular application using Docker and the latest Node, NPM and Angular CLI.
-
First of all, install Docker and Docker Compose;
-
If running on Windows, enable the Shared Drivers on Docker Settings;
-
Clone this repo;
-
Run the following command to create the project using Angular CLI (answer 'n' when asked to overwrite
README.md):
docker-compose run --rm web ng new --skip-install --directory ./ --skip-commit --routing app_name
Change app_name with your application's name.
- Edit the
.angular-cli.jsonfile. Add the following line to the 'defaults' section:
"poll":1000
It will looks like this:
"defaults": {
"styleExt": "css",
"component": {},
"poll": 1000
}
- Edit the
package.jsonfile.
Change the line:
"start": "ng serve",
To:
"start": "ng serve --host 0.0.0.0",
-
Run
docker-compose up -d; -
Run
docker logs ng-web -fand see the magic happening. -
After seeing the
webpack: Compiled successfullymessage, openhttp://localhost:4200in your browser.
-
The default
docker-compose.ymlconfig will open the4200port and map it to the same host port. -
It will also open and map the
49153port. This is needed for Live Reloading to work. -
The
init.shscript will runnpm installalways when you start the container. This can take some time before the app become available.
If you want to contribute, open an issue or send me a pull request. ;)