-
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(webapp): added helm chart for angular webapp deployment
anginx helm chart allow nginx webserver with angular content deployable into unprivileged containers
- Loading branch information
Showing
47 changed files
with
382 additions
and
414 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,54 @@ | ||
### STAGE 1: Build ### | ||
|
||
FROM node:11 as builder | ||
#FROM node:10-alpine as builder | ||
|
||
###################################################################### | ||
FROM node:11-alpine as dev-dependencies | ||
###################################################################### | ||
WORKDIR /app | ||
|
||
COPY package.json package-lock.json ./ | ||
|
||
RUN npm ci | ||
|
||
###################################################################### | ||
FROM node:11-alpine as builder | ||
#FROM node:11 as builder | ||
###################################################################### | ||
WORKDIR /app | ||
COPY --from=dev-dependencies /app /app | ||
COPY . . | ||
|
||
## Build the angular app in production mode and store the artifacts in dist folder | ||
RUN $(npm bin)/ng build --project=webapp -c=production | ||
|
||
### STAGE 2: Setup ### | ||
|
||
FROM fholzer/nginx-brotli:v1.15.8 | ||
LABEL maintainer="Sumanth <xmlking@gmail.com>" | ||
|
||
## Copy our nginx config | ||
# COPY .deploy/webapp/nginx.prod.conf /etc/nginx/conf.d/nginx.conf | ||
|
||
ARG NODE_OPTIONS="--max-old-space-size=1024" | ||
ENV NODE_OPTIONS $NODE_OPTIONS | ||
ENV NODE_ENV production | ||
RUN $(npm bin)/ng build webapp --prod | ||
|
||
###################################################################### | ||
FROM nginxinc/nginx-unprivileged:1.15.10-alpine | ||
###################################################################### | ||
## Remove default nginx website | ||
USER root | ||
RUN set -x \ | ||
&& rm -rf /usr/share/nginx/html/* | ||
USER 1001 | ||
|
||
## From 'builder' stage copy over the artifacts in dist folder to default nginx public folder | ||
COPY --from=builder /app/dist/apps/webapp /usr/share/nginx/html | ||
|
||
EXPOSE 8080 | ||
# Metadata params | ||
ARG VERSION=0.0.1 | ||
ARG BUILD_DATE | ||
ARG VCS_URL=ngx-starter-kit | ||
ARG VCS_REF=1 | ||
ARG NAME=ngxweb | ||
ARG VENDOR=sumo | ||
|
||
# Metadata | ||
LABEL maintainer="Sumanth <xmlking@gmail.com>" \ | ||
org.label-schema.build-date=$BUILD_DATE \ | ||
org.label-schema.name=$NAME \ | ||
org.label-schema.description="NGX Web" \ | ||
org.label-schema.url="https://example.com" \ | ||
org.label-schema.vcs-url=https://github.com/xmlking/$VCS_URL \ | ||
org.label-schema.vcs-ref=$VCS_REF \ | ||
org.label-schema.vendor=$VENDOR \ | ||
org.label-schema.version=$VERSION \ | ||
org.label-schema.docker.schema-version="1.0" \ | ||
org.label-schema.docker.cmd="docker run -it -p 8080:8080 xmlking/ngxweb" | ||
|
||
CMD ["nginx", "-g", "daemon off;"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,64 @@ | ||
# NxgApp | ||
# NxgWeb | ||
|
||
Build and Deploy NgxApp webapp. | ||
|
||
> use [nginxconfig](https://nginxconfig.io/) to generate `nginx.conf` | ||
Build and Deploy NgxWeb webapp. | ||
|
||
### Build | ||
|
||
```bash | ||
# build | ||
VERSION=2.0.0-SNAPSHOT | ||
# build, optionally use `--no-cache` | ||
export VERSION=2.0.0-SNAPSHOT | ||
export DOCKER_BUILDKIT=1 | ||
docker build \ | ||
--no-cache \ | ||
--build-arg VERSION=$VERSION \ | ||
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \ | ||
-t xmlking/ngxapp -f .deploy/webapp/Dockerfile . | ||
-t xmlking/ngxweb -f .deploy/webapp/Dockerfile . | ||
|
||
# if you need more memory for build | ||
export NODE_OPTIONS=--max-old-space-size=4096 | ||
export VERSION=2.0.0-SNAPSHOT | ||
export DOCKER_BUILDKIT=1 | ||
docker build \ | ||
--build-arg VERSION=$VERSION \ | ||
--build-arg NODE_OPTIONS=$NODE_OPTIONS \ | ||
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \ | ||
-t xmlking/ngxweb -f .deploy/webapp/Dockerfile . | ||
|
||
# tag | ||
docker tag xmlking/ngxapp xmlking/ngxapp:$VERSION | ||
docker tag xmlking/ngxweb xmlking/ngxweb:$VERSION | ||
|
||
# push | ||
docker push xmlking/ngxapp:$VERSION | ||
docker push xmlking/ngxapp:latest | ||
docker push xmlking/ngxweb:$VERSION | ||
docker push xmlking/ngxweb:latest | ||
|
||
# check | ||
docker inspect xmlking/ngxapp:$VERSION | ||
docker inspect xmlking/ngxweb:$VERSION | ||
docker image prune -f | ||
``` | ||
|
||
### Run | ||
|
||
Run docker locally for testing. | ||
|
||
```bash | ||
docker run -it -p 4200:8080 -v .deploy/webapp/nginx.conf:/etc/nginx/conf.d/nginx.conf xmlking/ngxapp | ||
# start ngxweb pod in interative mode. Use 'Ctrl+C' to terminate pod and delete temp service. | ||
kubectl run -it --rm ngxweb --port 8080 --hostport=8080 --expose=true --image=xmlking/ngxweb:$VERSION --restart=Never | ||
kubectl port-forward ngxweb 8080:8080 | ||
kubectl exec -it ngxweb -- /bin/sh | ||
``` | ||
|
||
### Test | ||
|
||
### Deploy | ||
|
||
#### Deploying to Kubernetes | ||
> The app will be available at http://localhost:8080 | ||
```bash | ||
# TODO | ||
open http://localhost:8080 | ||
``` | ||
|
||
#### Deploying OpenShift | ||
|
||
```bash | ||
# login with your ID | ||
oc login <my OpenShift URL> | ||
# oc login https://console.starter-us-east-1.openshift.com | ||
oc project ngx-starter-kit | ||
cd .deploy/webapp | ||
|
||
# create app (first time deployment) | ||
oc new-app -f webapp.tmpl.yml -p APPNAME=webapp -n ngx-starter-kit | ||
|
||
# follow next steps if you want completely delete and deploy. | ||
# delete only deploymentConfig | ||
oc delete all -l app=webapp -n cockpit | ||
|
||
# delete fully | ||
oc delete all,configmap,secret -l app=webapp -n ngx-starter-kit | ||
|
||
# redeploy | ||
from OpenShift Console UI, | ||
Applications > Deployments > webapp > Deploy | ||
``` | ||
|
||
|
||
|
||
### Access NgxApp | ||
|
||
The app will be available at http://localhost:4200 | ||
|
||
You can tweak the nginx config `nginx.conf` for your specific needs. | ||
|
||
### SSH | ||
|
||
```bash | ||
# SSH to the running container (CONTAINER ID from `docker ps` command) | ||
docker exec -it <CONTAINER ID> sh | ||
# if you started via docker-compose | ||
docker-compose exec web sh | ||
``` | ||
### Deploy | ||
|
||
Follow instructions from [helm](./helm) or [OpenShift](./openshift) | ||
|
||
### Reference | ||
|
||
- If you get 137 error | ||
- https://samwize.com/2016/05/19/docker-error-returned-a-non-zero-code-137/ | ||
- https://docs.docker.com/docker-for-mac/#advanced | ||
- use [nginxconfig](https://nginxconfig.io/) to generate `nginx.conf` |
Oops, something went wrong.