This repository holds the code and Docker components for a simple Angular Store App, made using this tutorial: https://angular.io/start.
To run the app locally, you need the following installed:
- node ~10.16.0
To install all other dependencies just run:
npm install
Afterwards, just run the below to run the app locally:
ng serve -o
In this repository, there are two Dockerfiles:
This is a standard Dockerfile with that runs ng serve to run the app.
To build an image with it:
docker build -t docker101:dev .
To run the image:
docker run -d -p 4201:4200 --name docker101-dev --rm docker101:dev
To run the image with volumes:
docker run -d -p 4201:4200 --name docker101-dev --rm -v $(pwd):/code docker101:dev
See the app running:
http://localhost:4201
This is a multi-stage Dockerfile that does the following:
- Build the application with ng build --prod
- Copy the dist directory from the build stage and copy it into the web server directory in Nginx
To build an image with it:
docker build -f Dockerfile.multistage -t docker101:prod .
To run the image:
docker run -d -p 8080:80 --name docker101-prod --rm docker101:prod
See the app running:
http://localhost:8080
Instead of using the above Docker commands to build and run the images, you can use Docker Compose to do all of that with one command!
Just make sure you have the following installed:
- Docker
- Docker Compose
To use docker-compose.yml:
docker-compose up -d
Once everything is running you should be able to access both containers in your browser:
http://localhost:4201
http://localhost:8080