diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c335715 --- /dev/null +++ b/Dockerfile @@ -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;" ] \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..f3975c6 --- /dev/null +++ b/Jenkinsfile @@ -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() + } + } + } diff --git a/angular.json b/angular.json index 638a1b5..ba7f204 100644 --- a/angular.json +++ b/angular.json @@ -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", diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..ed59efa --- /dev/null +++ b/nginx.conf @@ -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; + } + +} \ No newline at end of file diff --git a/src/polyfills.ts b/src/polyfills.ts index d310405..7cc4d0f 100644 --- a/src/polyfills.ts +++ b/src/polyfills.ts @@ -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; \ No newline at end of file