Use docker for deployments

Signed-off-by: William Brawner <me@wbrawner.com>
This commit is contained in:
William Brawner 2020-01-29 21:35:43 -07:00
parent c08a3a38c7
commit d1994dc9ff
6 changed files with 20 additions and 81 deletions

View file

@ -1,5 +0,0 @@
{
"projects": {
"default": "budget-c7da5"
}
}

9
Dockerfile Normal file
View file

@ -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

50
Jenkinsfile vendored
View file

@ -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()
}
}
}

View file

@ -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"
}
"defaultProject": "twigs"
}

View file

@ -1,16 +0,0 @@
{
"hosting": {
"public": "dist/budget",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}

View file

@ -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",