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

Updates #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM nginx:alpine
EXPOSE 8080
RUN rm -rf /usr/share/nginx/html/*
COPY dist/* /usr/share/nginx/html/
RUN rm /etc/nginx/conf.d/*
COPY nginx.conf /etc/nginx/conf.d/
RUN ls /usr/share/nginx/html
RUN chmod -R 755 /usr/share/nginx/html
CMD [ "nginx", "-g", "daemon off;" ]
97 changes: 97 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
pipeline {
agent {
label "jenkins-nodejs"
}
environment {
ORG = $ORG_NAME
APP_NAME = $APP_NAME
CHARTMUSEUM_CREDS = credentials('jenkins-x-chartmuseum')
}
stages {
stage('CI Build and push snapshot') {
when {
branch 'PR-*'
}
environment {
PREVIEW_VERSION = "0.0.0-SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER"
PREVIEW_NAMESPACE = "$APP_NAME-$BRANCH_NAME".toLowerCase()
HELM_RELEASE = "$PREVIEW_NAMESPACE".toLowerCase()
}
steps {
container('nodejs') {
sh "npm install"
//Note: This breaks in Angular6
sh "CI=true DISPLAY=:99 npm test"

sh 'export VERSION=$PREVIEW_VERSION && skaffold build -f skaffold.yaml'


sh "jx step post build --image $DOCKER_REGISTRY/$ORG/$APP_NAME:$PREVIEW_VERSION"
}

dir ('./charts/preview') {
container('nodejs') {
sh "make preview"
sh "jx preview --app $APP_NAME --dir ../.."
}
}
}
}
stage('Build Release') {
when {
branch 'master'
}
steps {
container('nodejs') {
// ensure we're not on a detached head
sh "git checkout master"
sh "git config --global credential.helper store"

sh "jx step git credentials"
// so we can retrieve the version in later steps
sh "echo \$(jx-release-version) > VERSION"
}
dir ('./charts/$APP_NAME') {
container('nodejs') {
sh "make tag"
}
}
container('nodejs') {
sh "npm install"

//Note: This breaks in Angular6
sh "CI=true DISPLAY=:99 npm test"

sh "npm run build:prod"

sh 'export VERSION=`cat VERSION` && skaffold build -f skaffold.yaml'

sh "jx step post build --image $DOCKER_REGISTRY/$ORG/$APP_NAME:\$(cat VERSION)"
}
}
}
stage('Promote to Environments') {
when {
branch 'master'
}
steps {
dir ('./charts/$APP_NAME') {
container('nodejs') {
sh 'jx step changelog --version v\$(cat ../../VERSION)'

// release the helm chart
sh 'jx step helm release'

// promote through all 'Auto' promotion Environments
sh 'jx promote -b --all-auto --timeout 1h --version \$(cat ../../VERSION)'
}
}
}
}
}
post {
always {
cleanWs()
}
}
}
2 changes: 1 addition & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/angular-io-quickstart",
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
Expand Down
24 changes: 24 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
server {

listen 8080;

sendfile on;

default_type application/octet-stream;


gzip on;
gzip_http_version 1.1;
gzip_disable "MSIE [1-6]\.";
gzip_min_length 256;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_comp_level 9;

location / {
root /usr/share/nginx/html;
index index.html;
}

}
4 changes: 4 additions & 0 deletions src/polyfills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,7 @@ import 'zone.js/dist/zone'; // Included with Angular CLI.
/***************************************************************************************************
* APPLICATION IMPORTS
*/

// Add global to window, assigning the value of window itself.
// Socket.io fix
(window as any).global = window;