Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

320
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda