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.json
file. Add the following line to the 'defaults' section:
"poll":1000
It will looks like this:
"defaults": {
"styleExt": "css",
"component": {},
"poll": 1000
}
- Edit the
package.json
file.
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 -f
and see the magic happening. -
After seeing the
webpack: Compiled successfully
message, openhttp://localhost:4200
in your browser.
-
The default
docker-compose.yml
config will open the4200
port and map it to the same host port. -
It will also open and map the
49153
port. This is needed for Live Reloading to work. -
The
init.sh
script will runnpm install
always 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. ;)