Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/changhuixu/angular-nginx-docker
Serve a SPA using NGINX in a docker container
https://github.com/changhuixu/angular-nginx-docker
angular docker nginx nginx-docker nginx-server server spa web
Last synced: 13 days ago
JSON representation
Serve a SPA using NGINX in a docker container
- Host: GitHub
- URL: https://github.com/changhuixu/angular-nginx-docker
- Owner: changhuixu
- License: mit
- Created: 2020-05-08T23:45:27.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T05:22:09.000Z (almost 2 years ago)
- Last Synced: 2023-03-01T18:25:47.170Z (almost 2 years ago)
- Topics: angular, docker, nginx, nginx-docker, nginx-server, server, spa, web
- Language: TypeScript
- Homepage:
- Size: 2.66 MB
- Stars: 6
- Watchers: 2
- Forks: 4
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# Get Started with NGINX on Docker
[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/I3I63W4OK)
How to deploy a single-page app with NGINX in a docker container?
## [Medium Article](https://codeburst.io/get-started-with-nginx-on-docker-907e5c0c9f3a)
In this introductory article, we will use NGINX to server a Single-Page Application (SPA). We will set up and play with NGINX on docker, including (1) serving a website by mounting a volume to a docker container, and (2) building and running a docker image with a web app and NGINX.
---
```bash
ng new angular-nginx-docker --minimal# build a docker image
docker build -t angular-nginx-docker .docker run -d -p 80:80 angular-nginx-docker
docker run -it -p 80:80 angular-nginx-docker
docker exec -it angular-nginx-docker /bin/sh
``````bash
# run the default nginx website in a container
docker run --name docker-nginx -p 80:80 nginx# navigate the nginx files in the docker alpine image
docker run -it nginx:alpine sh
# navigate the nginx files in the docker image
docker run -it --name nginx-container -P nginx bash
root@805435da60f9:/# cd etc/nginx/```
```bash
ng build --proddocker run -it --rm -p 80:80 \
-v /$PWD/dist/angular-nginx-docker://usr/share/nginx/html:ro \
nginx:alpinedocker run -it --rm -p 4200:80 \
-v /$PWD/dist/angular-nginx-docker://usr/share/nginx/html:ro \
-v /$PWD/.nginx/nginx.conf://etc/nginx/nginx.conf:ro \
nginx:alpine```
```bash
# compare gzip effect using the following two commands$ curl http://localhost:80/ \
--silent \
--write-out "%{size_download}\n" \
--output /dev/null
# console output: 814$ curl http://localhost:80/ \
--silent \
-H "Accept-Encoding: gzip,deflate" \
--write-out "%{size_download}\n" \
--output /dev/null
# console output: 391
```## License
Feel free to use the code in this repository as it is under MIT license.
[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/I3I63W4OK)