Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

develop pull (#2) #22

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
23 changes: 23 additions & 0 deletions .deploy/api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM node:alpine as dev-dependencies
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci

FROM node:alpine as prod-dependencies
WORKDIR /app
COPY package.api.json package.json
RUN npm i --production

FROM node:alpine as builder
WORKDIR /app
COPY --from=dev-dependencies /app /app
COPY apps/api apps/api
COPY angular.json nx.json tsconfig.json ./
ENV NODE_ENV production
RUN npm run api:build

FROM astefanutti/scratch-node:11
COPY --from=prod-dependencies /app .
COPY --from=builder /app/dist/apps/api .
EXPOSE 3000
ENTRYPOINT ["./node", "main.js"]
17 changes: 11 additions & 6 deletions .deploy/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@ Deploying ngx-starter-kit API
### Build
```bash
# build app docker image
docker build --tag=ngx-starter-kit-api -f .deploy/api/prod.dockerfile .
docker build --tag=ngx-starter-kit-api -f .deploy/api/Dockerfile .
```

### Run
```bash
docker run -it --env TYPEORM_HOST=localhost -p 3000:3000 ngx-starter-kit-api
docker-compose up api
# docker run -it --env TYPEORM_HOST=postgres -p 3000:3000 ngx-starter-kit-api
# to see ditectory content:
docker-compose exec api ./node
docker-compose exec api ./node -e 'console.log(__dirname);'
docker-compose exec api ./node -e 'const fs = require('fs'); fs.readdirSync('.').forEach(file => { console.log(file);})
```

### Test
Expand All @@ -33,11 +38,11 @@ curl -v -X GET \
docker login

# tag
docker tag ngx-starter-kit-api xmlking/ngx-starter-kit-api:0.1.4-SNAPSHOT
docker tag xmlking/ngx-starter-kit-api:0.1.4-SNAPSHOT xmlking/ngx-starter-kit-api:latest
docker tag ngx-starter-kit-api xmlking/ngx-starter-kit-api:1.2.0-SNAPSHOT
docker tag xmlking/ngx-starter-kit-api:1.2.0-SNAPSHOT xmlking/ngx-starter-kit-api:latest

# push
docker push xmlking/ngx-starter-kit-api:0.1.4-SNAPSHOT
docker push xmlking/ngx-starter-kit-api:1.2.0-SNAPSHOT
docker push xmlking/ngx-starter-kit-api:latest
```

Expand All @@ -54,7 +59,7 @@ cd .deploy/api
# create app (first time deployment)
oc new-app -f api.tmpl.yml -p APPNAME=ngx-starter-kit-api -n ngx-starter-kit

# follow next steps if you want completely delete and deploy.
# follow next steps if you want completely delete and redeploy.
# delete only deploymentConfig
oc delete all -l app=ngx-starter-kit-api -n ngx-starter-kit

Expand Down
8 changes: 4 additions & 4 deletions .deploy/api/api.tmpl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: Template
metadata:
name: ${APPNAME}
annotations:
tags: "ngx-starter-kit-api,mongodb,template"
tags: "ngx-starter-kit-api,postgres,template"
description: ngx-starter-ki api template

objects:
Expand Down Expand Up @@ -72,13 +72,13 @@ objects:
protocol: TCP
env:
- name: TYPEORM_HOST
value: mongodb
value: postgres
- name: TYPEORM_PORT
value: 27017
value: 5432
- name: TYPEORM_DATABASE
value: cockpit
- name: TYPEORM_USERNAME
value: mdbuser
value: cockpit
- name: TYPEORM_PASSWORD
value: cockpit123

Expand Down
27 changes: 0 additions & 27 deletions .deploy/api/prod.dockerfile

This file was deleted.

39 changes: 26 additions & 13 deletions .deploy/webapp/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
WebApp
======
# WebApp

Dockerize Angular WebApp

> use [nginxconfig](https://nginxconfig.io/) to generate `nginx.conf`

### Deploy

#### Build Nginx

> Build and publish custom nginx image for OpenShift (One time only)

```bash
docker build -t openshift-nginx -f .deploy/webapp/nginx.dockerfile .
docker tag openshift-nginx xmlking/openshift-nginx:1.14-alpine
Expand All @@ -18,19 +21,23 @@ docker push xmlking/openshift-nginx:latest
```

#### Build App

> Build ngx-starter-kit docker image

```bash
# build app docker image
docker build --tag=ngx-starter-kit -f .deploy/webapp/prod.dockerfile .
docker build --tag=ngx-starter-kit -f .deploy/webapp/prod.dockerfile .
```

#### Docker Push

> Push ngx-starter-kit docker image

```bash
# login to hub.docker.com to push docker image
docker login

# tag
# tag
docker tag ngx-starter-kit xmlking/ngx-starter-kit:1.0.0-SNAPSHOT
docker tag xmlking/ngx-starter-kit:1.0.0-SNAPSHOT xmlking/ngx-starter-kit:latest

Expand All @@ -40,7 +47,9 @@ docker push xmlking/ngx-starter-kit:latest
```

#### OpenShift Deployment

> Deploy ngx-starter-kit app to OpenShift

```bash
# login with your ID
oc login <my OpenShift URL>
Expand All @@ -59,29 +68,32 @@ oc delete all -l app=webapp -n cockpit
oc delete all,configmap,secret -l app=webapp -n ngx-starter-kit

# redeploy
from OpenShift Console UI,
Applications > Deployments > webapp > Deploy
from OpenShift Console UI,
Applications > Deployments > webapp > Deploy
```


### K8S Commands

```bash
kubectl get services
kubectl get pods
kubectl logs -f keycloak-server-6-grfmg
```

### Run
### Run

Run docker locally for testing.

```bash
docker run -it -p 4200:8080 -v .deploy/webapp/nginx.conf:/etc/nginx/conf.d/nginx.conf cockpit
```

The app will be available at http://localhost:4200

You can tweak the nginx config ```nginx.conf``` for your specific needs.
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
Expand All @@ -90,13 +102,14 @@ docker-compose exec web sh
```

###Maintenance

```bash
docker container prune
docker image prune
```


### Ref
* 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

- 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
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ dist
tmp
sme

.git/
.gitignore

# dependencies
node_modules
bower_components
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
# dependencies
/node_modules

# profiling files
chrome-profiler-events.json
speed-measure-plugin.json

# IDEs and editors
/.idea
.project
Expand Down
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Add files here to ignore them from prettier formatting
tools/schematics/store/_files
40 changes: 40 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,43 @@
# [1.3.0](https://github.com/xmlking/ngx-starter-kit/compare/v1.2.0...v1.3.0) (2018-11-23)


### Bug Fixes

* **api:** fix auth config ([67f8c57](https://github.com/xmlking/ngx-starter-kit/commit/67f8c57))
* **api:** make typeorm work with 'ng serve api' ([e549023](https://github.com/xmlking/ngx-starter-kit/commit/e549023))
* **auth:** fix redirection to dashboard after login via ImplicitFLow ([6685ce9](https://github.com/xmlking/ngx-starter-kit/commit/6685ce9))
* **chat-box:** fix voice box for safari ([5068a72](https://github.com/xmlking/ngx-starter-kit/commit/5068a72))
* **core:** adding es7/array polyfill to support old browsers ([7340567](https://github.com/xmlking/ngx-starter-kit/commit/7340567))
* **core:** removed ng-package.prod.json as it is no longer needed by nx ([f51f0f5](https://github.com/xmlking/ngx-starter-kit/commit/f51f0f5))
* **eventbus:** workaround for ngxs router plugin issue ([78a41a2](https://github.com/xmlking/ngx-starter-kit/commit/78a41a2))
* **eventbus:** workaround for ngxs router plugin issue ([9fb3ab0](https://github.com/xmlking/ngx-starter-kit/commit/9fb3ab0))
* **experiments:** update ngx-knob, lock d3 version ([1b26e5b](https://github.com/xmlking/ngx-starter-kit/commit/1b26e5b))
* **grid:** fix drag: changed cdkDragRootElement from .mat-dialog-container .cdk-overlay-pane ([92153e6](https://github.com/xmlking/ngx-starter-kit/commit/92153e6))
* **material:** mat-placeholde -> mat-label ([95b3141](https://github.com/xmlking/ngx-starter-kit/commit/95b3141))
* **ThemePicker:** ThemePicker now using PreferenceState for storage ([d448bf8](https://github.com/xmlking/ngx-starter-kit/commit/d448bf8))


### Features

* **analytics:** added google analytics service ([f52e75f](https://github.com/xmlking/ngx-starter-kit/commit/f52e75f))
* **api:** added push API module to save PushSubscriptions ([945034c](https://github.com/xmlking/ngx-starter-kit/commit/945034c))
* **core:** using Inject(WINDOW) and new ServiceWorker ([2bfc467](https://github.com/xmlking/ngx-starter-kit/commit/2bfc467))
* **dashboard:** added profile and settings pages ([848d51e](https://github.com/xmlking/ngx-starter-kit/commit/848d51e))
* **dashboard:** added profile and settings pages ([1a77689](https://github.com/xmlking/ngx-starter-kit/commit/1a77689))
* **notifications:** added field: native to Notification model ([12fa080](https://github.com/xmlking/ngx-starter-kit/commit/12fa080))
* **notifications:** added notify, notifyAll API ([3600c99](https://github.com/xmlking/ngx-starter-kit/commit/3600c99))
* **push:** PushNotifications subscription backend API ([4b65131](https://github.com/xmlking/ngx-starter-kit/commit/4b65131))


### Performance Improvements

* **polish:** removed console.log ([12bde29](https://github.com/xmlking/ngx-starter-kit/commit/12bde29))


### Reverts

* **test:** test ([348c307](https://github.com/xmlking/ngx-starter-kit/commit/348c307))

# [1.2.0](https://github.com/xmlking/ngx-starter-kit.git/compare/v1.1.0...v1.2.0) (2018-10-28)


Expand Down
Loading