Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

313
Views
Angular Library, Watch, and Docker

I have an angular library that I build like so: ng build my-library -- --watch and a dist directory gets generated.

I have a dummy angular app to test my library, in package.json: docker:start : ng serve --host 0.0.0.0 --poll 1

When I run in my terminal, during development, I run the build in one terminal and the app in another. As I make changes, the build picks them up, and once the new library is built, the service takes the changes and I see them in the browser.

I'm trying to recreate this in Docker like so:

FROM node:10-alpine

WORKDIR /app

EXPOSE 4200

# Install Angular/CLI to use `ng`
RUN npm install -g @angular/cli

# My Application
COPY ./package*.json ./
RUN npm install

# Build ./dist/my-library
COPY ./ ./
RUN cd ./projects/my-library && npm run build

CMD ["npm","run","docker:start"]

My docker-compose.yml:

version: '3'
services:
  app:
    container_name: 'app'
    build:
      context: .
      dockerfile: Dockerfile.dev
    ports:
      - '4200:4200'
    volumes:
      - /app/node_modules
      - .:/app

I want to be able to run docker-compose up and do development like I do in the multiple terminals.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

If you want to emulate multiple terminals, you can just run multiple 'services' in docker-compose:

version: '3'
services:
  app:
    container_name: 'app'
    build:
      context: .
      dockerfile: Dockerfile.dev
    ports:
      - '4200:4200'
    volumes:
      - /app/node_modules
      - .:/app
  lib:
    container_name: 'lib'
    build:
      context: .
      dockerfile: Dockerfile.dev
    volumes:
      - /app/node_modules
      - .:/app
    command: sh -c 'ng build my-library -- --watch'

Here is an example of a app/test docker-compose definition that I commonly use:

version: '3.7'
services:
  web:
    image: node:12-alpine
    volumes:
      - .:/src/app:cached
    ports:
      - 4200:4200
    working_dir: /src/app
    command: /bin/sh -c "npm install && npm run start-docker"
  tests:
    image: node:12-alpine
    volumes:
      - .:/src/app:cached
    working_dir: /src/app
    command: /bin/sh -c "npm install && npm run test:watch"
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!