/angular-local-docker

Develop angular applications locally inside a docker environment

Primary LanguageTypeScript

AngularLocalDocker

This project was generated with Angular CLI version 8.0.1.

Edit package.json

The package.json start script should be edited as follow:

...,
"scripts": {
    "ng": "ng",
    "start": "ng serve --host 0.0.0.0 --poll 1",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
...

Build Docker Image

docker build -t ng-local-docker .

Run an instance of the image

docker-compose up

FYI

  1. NodeJs v10.16.0 was installed locally to create this angular project.
  2. Delete the node_modules dir installed when the project is created as we want these to be installed inside the docker image.
rm -rf /node_modules

Objective

I'm constantly switching between NodeJs v4.X, v6.X and v10.X projects and I would like to avoid having to manage NodeJs version using nvm. I'm trying a setup that relies on each project having a base docker image to contain node_modules and then map my drive (application source code) to the container as I develop on my local machine.

Current Challenge

The docker-compose configuration in this project ovewrites/hides the files (node_modules) that are inside the container when it runs. I had to install the node_modules in a temp folder, then move the folder over to the dir location of the mapped volume at run time. The major drawback here is the length of time it takes to copy the entire node_modules dir into the mapped volume (3-5 mins from Win10 linux containers).