From d1994dc9fff82331a438077b609009aed86d1d3f Mon Sep 17 00:00:00 2001 From: William Brawner Date: Wed, 29 Jan 2020 21:35:43 -0700 Subject: [PATCH] Use docker for deployments Signed-off-by: William Brawner --- .firebaserc | 5 ----- Dockerfile | 9 +++++++++ Jenkinsfile | 50 -------------------------------------------------- angular.json | 20 ++++++++++---------- firebase.json | 16 ---------------- package.json | 1 + 6 files changed, 20 insertions(+), 81 deletions(-) delete mode 100644 .firebaserc create mode 100644 Dockerfile delete mode 100644 Jenkinsfile delete mode 100644 firebase.json diff --git a/.firebaserc b/.firebaserc deleted file mode 100644 index 4048afa..0000000 --- a/.firebaserc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "projects": { - "default": "budget-c7da5" - } -} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b25f946 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM node:latest as builder +COPY . /app +WORKDIR /app +RUN npm install && \ + npm run-script package + +FROM nginx:latest +COPY --from=builder /app/dist/twigs /usr/share/nginx/html + diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index ce25a95..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,50 +0,0 @@ -def remote = [:] -remote.name = 'budget' -remote.host = 'budget.wbrawner.com' -remote.user = 'root' -remote.identityFile = '/var/lib/jenkins/.ssh/id_rsa' -remote.knownHosts = '/var/lib/jenkins/.ssh/known_hosts' - -pipeline { - agent any - stages { - stage('Build') { - steps { - checkout scm - sh 'npm install' - sh 'ng build --prod --aot' - } - } - stage('Prepare Archive') { - steps { - sh 'zip -j archive.zip dist/budget/*' - } - } - stage('Deploy to Production') { - when { - expression { - env.BRANCH_NAME == 'master' - } - } - steps { - withCredentials([string(credentialsId: '4a0b8908-75eb-4bc3-9961-db044f848bc5', variable: 'FIREBASE_DEPLOY_TOKEN')]) { - sh 'firebase deploy --token "$FIREBASE_DEPLOY_TOKEN"' - } - } - } - stage('Deploy to Dev') { - steps { - sh 'rm -rf /var/www/html/*' - sh 'cp -rv dist/budget/* /var/www/html/' - } - } - } - post { - always { - archiveArtifacts artifacts: 'archive.zip', fingerprint: true - } - cleanup { - cleanWs() - } - } -} diff --git a/angular.json b/angular.json index e07c92f..b6dede3 100644 --- a/angular.json +++ b/angular.json @@ -3,7 +3,7 @@ "version": 1, "newProjectRoot": "projects", "projects": { - "budget": { + "twigs": { "root": "", "sourceRoot": "src", "projectType": "application", @@ -13,7 +13,7 @@ "build": { "builder": "@angular-devkit/build-angular:browser", "options": { - "outputPath": "dist/budget", + "outputPath": "dist/twigs", "index": "src/index.html", "main": "src/main.ts", "polyfills": "src/polyfills.ts", @@ -62,18 +62,18 @@ "serve": { "builder": "@angular-devkit/build-angular:dev-server", "options": { - "browserTarget": "budget:build" + "browserTarget": "twigs:build" }, "configurations": { "production": { - "browserTarget": "budget:build:production" + "browserTarget": "twigs:build:production" } } }, "extract-i18n": { "builder": "@angular-devkit/build-angular:extract-i18n", "options": { - "browserTarget": "budget:build" + "browserTarget": "twigs:build" } }, "test": { @@ -108,7 +108,7 @@ } } }, - "budget-e2e": { + "twigs-e2e": { "root": "e2e/", "projectType": "application", "architect": { @@ -116,11 +116,11 @@ "builder": "@angular-devkit/build-angular:protractor", "options": { "protractorConfig": "e2e/protractor.conf.js", - "devServerTarget": "budget:serve" + "devServerTarget": "twigs:serve" }, "configurations": { "production": { - "devServerTarget": "budget:serve:production" + "devServerTarget": "twigs:serve:production" } } }, @@ -136,5 +136,5 @@ } } }, - "defaultProject": "budget" -} \ No newline at end of file + "defaultProject": "twigs" +} diff --git a/firebase.json b/firebase.json deleted file mode 100644 index 1c501ca..0000000 --- a/firebase.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "hosting": { - "public": "dist/budget", - "ignore": [ - "firebase.json", - "**/.*", - "**/node_modules/**" - ], - "rewrites": [ - { - "source": "**", - "destination": "/index.html" - } - ] - } -} diff --git a/package.json b/package.json index 5ef0004..a7f9e9f 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "ng": "node_modules/@angular/cli/bin/ng", "start": "node_modules/@angular/cli/bin/ng serve --host '0.0.0.0'", "build": "node_modules/@angular/cli/bin/ng build", + "package": "node_modules/@angular/cli/bin/ng build --prod --service-worker", "publish": "node_modules/@angular/cli/bin/ng build --prod --service-worker && firebase deploy", "test": "node_modules/@angular/cli/bin/ng test", "lint": "node_modules/@angular/cli/bin/ng lint",