Skip to content

This repository contains the docker file to used for Angular 7 production apps.

License

Notifications You must be signed in to change notification settings

MexsonFernandes/Angular7-Nginx-Docker-Production

Repository files navigation

Angular 7 Nginx Docker for Production (SSL also included)

Buy Me a Coffee at ko-fi.com

Initial setup

  • Compile your Angular project for production use
    • "ng build --prod"
    • copy the 'Dockerfile', 'nginx.conf', files from this repository to 'dist' folder in your project.

Docker setup using Dockerfile

  • run "docker build -t angular-docker ."
  • check docker image using "docker image ls"
  • start docker using "docker run -p 3000:80 --rm angular-docker"
  • open browser tab and run "http://localhost:3000/"

Docker setup uing docker-compose.yml

  • run "docker-compose up --build" to build docker image and start the server.
  • run "docker build -t angular-docker ." if the above command gives error.
  • run "docker-compose up" to start existing docker image.
  • run "docker-compose down" to stop docker process.
  • Optional "docker-compose down --rmi all" to remove everything.

NOTE:

  • You can use either of the method specified above. The simplest one is by using docker-compose.yml file.
  • To start the server on port 80, make sure that there is no service currently open, which is using port 80. In the case of nginx running already on port 80, use "sudo service nginx stop" command. Then use "docker run -p 80:80 --rm angular-docker"
  • For ssl comment out lines from nginx.conf file and alos include the required ssl files like .crt(ssl certificate) and .key(private key).

Releases

No releases published

Packages

No packages published