Skip to content

yashvantdevops/angular_with__docker

Repository files navigation

AngularD

This project was generated using Angular CLI v21.0.0 and includes Docker support for local development.

Prerequisites

  • Docker Desktop (Linux containers)
  • Docker Compose (v2) included with Docker Desktop
  • Node/npm only required on the host if you want to run locally without Docker

Run with Docker Compose (recommended)

This repository includes a Dockerfile and docker-compose.yml to run the dev server in a container.

  1. Build and start (PowerShell):
# Rebuild image and start (foreground)
docker compose build --no-cache
docker compose up --build

# Or run detached
docker compose up --build -d
  1. Open the app in a browser: http://localhost:4200

  2. Follow logs:

docker compose logs -f angular-app
  1. Open a shell in the running container (for debugging):
docker compose run --service-ports --rm angular-app sh
# or if bash exists:
docker compose run --service-ports --rm angular-app bash

What the compose setup does

  • Builds an image from the provided Dockerfile.
  • Exposes port 4200 on the host.
  • Mounts the project directory into the container for live code updates.
  • Uses a named Docker volume node_modules to preserve container-installed dependencies and avoid hiding them with a host mount.
  • Sets CHOKIDAR_USEPOLLING=true to improve file-watch reliability on Windows hosts.

Useful commands

  • Rebuild image and recreate containers:
docker compose up --build -d
  • Show container logs:
docker compose logs -f
  • Stop and remove containers:
docker compose down

Notes & troubleshooting

  • If you see errors like sh: ng: not found or spawn ng ENOENT, the container cannot find node_modules/.bin/ng. Ensure the named node_modules volume is used (see docker-compose.yml) and the image build completed npm install.
  • If file watching does not detect changes on Windows, ensure Docker Desktop is running Linux containers and CHOKIDAR_USEPOLLING=true is set in docker-compose.yml (already configured).
  • For reproducible installs in CI, consider adding a package-lock.json and using npm ci in the Dockerfile.
  • To debug Node version mismatch, run docker compose run --rm angular-app node --version.

Local development without Docker

Run these commands on a host with Node installed:

npm install
ng serve --host 0.0.0.0

If you want, an entrypoint script can be added to run npm install automatically when the node_modules volume is empty — say if you prefer the container to self-bootstrap.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published