I started Angular

A record of trying Angular with Docker It took a lot of time to automatically detect and compile source code updates while the server was running.

environment

Docker for Windows Angular CLI: 8.1.2 Node: 11.15.0

Create and start a container

Dockerfile

FROM node:11.15.0-stretch

RUN npm install -g @angular/cli && ng config -g cli.packageManager yarn

WORKDIR /app
version: '3'

services:
  node:
    build: .
    ports:
      - "4200:4200"
    volumes:
      - ".:/app"
    tty: true

Container startup

docker-compose up -d

Enter the container console User is root or node or whatever you like

docker-compose exec --user node node bash

Angular Create a project in the app directory of the container --style can be css, scss, sass, etc. Add root module with --routing

ng new my-project --style=scss --routing

Server startup --host I'm using Docker, so 0.0.0.0 --poll If you are using Docker, you need to detect source code updates and specify the compile interval

cd my-project
ng serve --host=0.0.0.0 --poll=2000

You should now be able to access the Angular app from localhost: 4200 Furthermore, if you add the following command to docker-compose.yml, the server will also start when the container starts.

version: '3'  

services:
  node:
    build: .
    ports:
      - "4200:4200"
    volumes:
      - ".:/app"
    tty: true
    command: [sh, -c, cd my-project && ng serve --host=0.0.0.0 --poll=2000]

reference

https://qiita.com/k5n/items/1a4987a430cf32e3e57d https://qiita.com/k5n/items/dbda26cf6b899a11329d https://qiita.com/friedaji/items/c3aba48542872f029c21

Recommended Posts

I started Angular
I started Ruby
I started Java Gold (Chapter 1-1)
I tried Angular tutorial + SpringBoot + PostgreSQL
<First post> I started studying Ruby
I tried to get started with WebAssembly
I installed Docker on EC2 and started it
I tried Getting Started with Gradle on Heroku