Merge pull request #86 in TEA/mina-sidor-fa-web from feature/acc-deployment to develop
Squashed commit of the following: commit b80896487554d90ed95c1a93596e2f3330202983 Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se> Date: Fri Sep 10 10:45:07 2021 +0200 Added deployment for acc
This commit is contained in:
31
angular.json
31
angular.json
@@ -83,6 +83,33 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"acc": {
|
||||||
|
"fileReplacements": [
|
||||||
|
{
|
||||||
|
"replace": "apps/mina-sidor-fa/src/environments/environment.ts",
|
||||||
|
"with": "apps/mina-sidor-fa/src/environments/environment.acc.ts"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"optimization": true,
|
||||||
|
"outputHashing": "all",
|
||||||
|
"sourceMap": false,
|
||||||
|
"namedChunks": false,
|
||||||
|
"extractLicenses": true,
|
||||||
|
"vendorChunk": false,
|
||||||
|
"buildOptimizer": true,
|
||||||
|
"budgets": [
|
||||||
|
{
|
||||||
|
"type": "initial",
|
||||||
|
"maximumWarning": "2mb",
|
||||||
|
"maximumError": "5mb"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "anyComponentStyle",
|
||||||
|
"maximumWarning": "6kb",
|
||||||
|
"maximumError": "10kb"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"api": {
|
"api": {
|
||||||
"fileReplacements": [
|
"fileReplacements": [
|
||||||
{
|
{
|
||||||
@@ -103,6 +130,10 @@
|
|||||||
"production": {
|
"production": {
|
||||||
"browserTarget": "mina-sidor-fa:build:production"
|
"browserTarget": "mina-sidor-fa:build:production"
|
||||||
},
|
},
|
||||||
|
"acc": {
|
||||||
|
"browserTarget": "mina-sidor-fa:build:acc",
|
||||||
|
"proxyConfig": "./config/proxy.conf.api.json"
|
||||||
|
},
|
||||||
"api": {
|
"api": {
|
||||||
"browserTarget": "mina-sidor-fa:build:api",
|
"browserTarget": "mina-sidor-fa:build:api",
|
||||||
"proxyConfig": "./config/proxy.conf.api.json"
|
"proxyConfig": "./config/proxy.conf.api.json"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
export interface Environment {
|
export interface Environment {
|
||||||
environment: 'api' | 'local' | 'prod';
|
environment: 'api' | 'local' | 'acc' | 'prod';
|
||||||
clientId: string;
|
clientId: string;
|
||||||
loginUrl: string;
|
loginUrl: string;
|
||||||
logoutUrl: string;
|
logoutUrl: string;
|
||||||
|
|||||||
13
apps/mina-sidor-fa/src/environments/environment.acc.ts
Normal file
13
apps/mina-sidor-fa/src/environments/environment.acc.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import { Environment } from '@msfa-models/environment.model';
|
||||||
|
|
||||||
|
export const environment: Environment = {
|
||||||
|
environment: 'acc',
|
||||||
|
clientId: '5d08c2e4-763e-42f6-b858-24e4773bb83d',
|
||||||
|
loginUrl: 'https://ciam-test.arbetsformedlingen.se:8443/uas/oauth2/authorization?response_type=code&scope=openid',
|
||||||
|
logoutUrl: 'https://ciam-test.arbetsformedlingen.se:8443/uas/logout',
|
||||||
|
production: true,
|
||||||
|
api: {
|
||||||
|
url: '/api',
|
||||||
|
headers: {},
|
||||||
|
},
|
||||||
|
};
|
||||||
144
openshift/acc/Jenkinsfile
vendored
Normal file
144
openshift/acc/Jenkinsfile
vendored
Normal file
@@ -0,0 +1,144 @@
|
|||||||
|
def cicdproject = "${CICD_NAMESPACE}"
|
||||||
|
def appname = "${APP_NAME}"
|
||||||
|
def utv_project = "${UTV_NAMESPACE}"
|
||||||
|
def acc_project = "${ACC_NAMESPACE}"
|
||||||
|
def jenkinsslave = "nodejs15-agent"
|
||||||
|
def dist_path = "dist/apps/mina-sidor-fa"
|
||||||
|
|
||||||
|
pipeline {
|
||||||
|
|
||||||
|
agent {
|
||||||
|
node {label "${jenkinsslave}"}
|
||||||
|
}
|
||||||
|
|
||||||
|
environment {
|
||||||
|
CURRENT_COMMIT = getShortCommitHash()
|
||||||
|
BUILD_TAG = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
stages {
|
||||||
|
|
||||||
|
stage("Initialize") {
|
||||||
|
steps {
|
||||||
|
echo '### Generating build tag... ###'
|
||||||
|
script {
|
||||||
|
def rootDir = pwd()
|
||||||
|
echo "Current Directory: \"${ rootDir }\""
|
||||||
|
|
||||||
|
def packageJson = readJSON file: 'package.json'
|
||||||
|
BUILD_TAG = "acc_v${packageJson.version}_${env.BUILD_NUMBER}_${CURRENT_COMMIT}"
|
||||||
|
echo '### Build tag ###'
|
||||||
|
echo "${BUILD_TAG}"
|
||||||
|
}
|
||||||
|
echo '### Build tag generated! ###'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage("Install dependencies") {
|
||||||
|
environment {
|
||||||
|
NEXUS_CREDS = "${env.NEXUS_USERNAME}:${env.NEXUS_PASSWORD}"
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
echo '### Installing dependencies... ###'
|
||||||
|
sh '''
|
||||||
|
ENCODED=$(echo -n "${NEXUS_CREDS}" | openssl base64)
|
||||||
|
CACHE_DIRECTORY=/home/jenkins/.npm/cache
|
||||||
|
mkdir -p ${CACHE_DIRECTORY}
|
||||||
|
echo "_auth=${ENCODED}" >> .npmrc
|
||||||
|
|
||||||
|
# set -x
|
||||||
|
cat .npmrc
|
||||||
|
|
||||||
|
# Pull from cache if it exists
|
||||||
|
(
|
||||||
|
# Fail if any step fail
|
||||||
|
set -e
|
||||||
|
# Remove line 3 from package-lock, which contain the package.json version. Store backup.
|
||||||
|
# We only care about dependencies, not the version
|
||||||
|
sed -i.bak -e '3d' package-lock.json
|
||||||
|
# Hash the package-lock.json file
|
||||||
|
sha1sum package-lock.json | tr -s " " | awk '{print $1}' > hashed.pkg-lock
|
||||||
|
# Restore package-lock.json with version number intact
|
||||||
|
mv package-lock.json.bak package-lock.json
|
||||||
|
# Try to get the file from cache
|
||||||
|
cp ${CACHE_DIRECTORY}/$(cat hashed.pkg-lock) node_modules.tar.gz 2> /dev/null
|
||||||
|
# Check if we found the cached node_modules
|
||||||
|
test -f node_modules.tar.gz
|
||||||
|
# If we found the cached node_modules, extract the files to node_modules
|
||||||
|
(test -f node_modules.tar.gz && tar -zxf node_modules.tar.gz && echo "Using cached node_modules from ${CACHE_DIRECTORY}/$(cat hashed.pkg-lock)") || echo "No cached node_modules.tar.gz found"
|
||||||
|
# Echo to the logs stating that we are using cache
|
||||||
|
echo "Using cached node_modules from ${CACHE_DIRECTORY}/$(cat hashed.pkg-lock)"
|
||||||
|
) || true
|
||||||
|
|
||||||
|
# If we did not find the cached node_modules, install from the lock
|
||||||
|
test -f node_modules.tar.gz || npm ci;
|
||||||
|
|
||||||
|
# Store cache
|
||||||
|
(
|
||||||
|
# Fail if any step fail
|
||||||
|
set -e
|
||||||
|
# Only update the cache if we found no previous cache
|
||||||
|
test ! -f node_modules.tar.gz
|
||||||
|
# Tar the cache
|
||||||
|
tar -zcf node_modules.tar.gz node_modules
|
||||||
|
# Clean old cache
|
||||||
|
rm -rf ${CACHE_DIRECTORY}/*
|
||||||
|
# Store the cache
|
||||||
|
cp node_modules.tar.gz ${CACHE_DIRECTORY}/$(cat hashed.pkg-lock)
|
||||||
|
) || true
|
||||||
|
'''
|
||||||
|
echo '### Dependencies installed! ###'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage("Build application") {
|
||||||
|
environment {
|
||||||
|
NGINX_PATH = "${dist_path}/."
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
echo '### Building application... ###'
|
||||||
|
sh '''
|
||||||
|
npm run build-os -- --config acc --version ${BUILD_TAG}
|
||||||
|
cp -r nginx/* ${NGINX_PATH}
|
||||||
|
'''
|
||||||
|
echo '### Application built! ###'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('App bake') {
|
||||||
|
steps {
|
||||||
|
echo '### Creating image... ###'
|
||||||
|
script {
|
||||||
|
openshift.withCluster() {
|
||||||
|
openshift.withProject(utv_project) {
|
||||||
|
openshift.selector("bc", "${ appname }").startBuild("--from-dir=${dist_path}", "--wait=true")
|
||||||
|
openshift.tag("${ appname }:latest", "${ appname }:${BUILD_TAG}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '### Image created! ###'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Deploy to "acc"') {
|
||||||
|
steps {
|
||||||
|
echo '### Deploying to "acc"... ###'
|
||||||
|
script {
|
||||||
|
openshift.withCluster() {
|
||||||
|
openshift.withProject(acc_project) {
|
||||||
|
openshift.raw("set image dc/${ appname } ${ appname }=docker-registry.default.svc:5000/${utv_project}/${ appname }:${BUILD_TAG} --record=true --source=docker ")
|
||||||
|
openshift.raw("annotate dc ${ appname } version=${BUILD_TAG} --overwrite=true")
|
||||||
|
openshift.selector("dc", "${ appname }").rollout().status();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo '### Deployed to "acc"! ###'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def getShortCommitHash() {
|
||||||
|
return sh(returnStdout: true, script: "git log -n 1 --pretty=format:'%h'").trim()
|
||||||
|
}
|
||||||
2
openshift/prod/Jenkinsfile
vendored
2
openshift/prod/Jenkinsfile
vendored
@@ -107,7 +107,7 @@ pipeline {
|
|||||||
steps {
|
steps {
|
||||||
echo '### Building application... ###'
|
echo '### Building application... ###'
|
||||||
sh '''
|
sh '''
|
||||||
npm run build-os -- --version ${BUILD_TAG}
|
npm run build-os -- --config prod --version ${BUILD_TAG}
|
||||||
cp -r nginx/* ${NGINX_PATH}
|
cp -r nginx/* ${NGINX_PATH}
|
||||||
'''
|
'''
|
||||||
echo '### Application built! ###'
|
echo '### Application built! ###'
|
||||||
|
|||||||
@@ -16,8 +16,8 @@
|
|||||||
"start-os:api": "bash ./tools/serve-os.sh -- --config api",
|
"start-os:api": "bash ./tools/serve-os.sh -- --config api",
|
||||||
"build": "ng build mina-sidor-fa",
|
"build": "ng build mina-sidor-fa",
|
||||||
"build:api": "ng build mina-sidor-fa --configuration api",
|
"build:api": "ng build mina-sidor-fa --configuration api",
|
||||||
|
"build:acc": "ng build mina-sidor-fa --configuration acc",
|
||||||
"build-os": "bash ./tools/build-os.sh",
|
"build-os": "bash ./tools/build-os.sh",
|
||||||
"build-os:api": "bash ./tools/build-os.sh -- --config api",
|
|
||||||
"test": "ng test mina-sidor-fa",
|
"test": "ng test mina-sidor-fa",
|
||||||
"release": "bash ./tools/release.sh",
|
"release": "bash ./tools/release.sh",
|
||||||
"release:dry": "bash ./tools/release.sh dry",
|
"release:dry": "bash ./tools/release.sh dry",
|
||||||
|
|||||||
@@ -46,8 +46,8 @@ echo -e "${GREEN}VERSION set to ${version}${NOCOLOR}"
|
|||||||
|
|
||||||
|
|
||||||
if [ $config = "prod" ]; then
|
if [ $config = "prod" ]; then
|
||||||
echo -e "${CYAN}Running npm run build -- --prod${NOCOLOR}"
|
echo -e "${CYAN}Running npm run build -- --production${NOCOLOR}"
|
||||||
npm run build -- --prod
|
npm run build -- --production
|
||||||
echo -e "${GREEN}Application built ${VERSION}${NOCOLOR}"
|
echo -e "${GREEN}Application built ${VERSION}${NOCOLOR}"
|
||||||
exit
|
exit
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ echo -e "${GREEN}VERSION set to ${version}${NOCOLOR}"
|
|||||||
|
|
||||||
|
|
||||||
if [ $config = "prod" ]; then
|
if [ $config = "prod" ]; then
|
||||||
echo -e "${CYAN}Running npm run start -- --prod${NOCOLOR}"
|
echo -e "${CYAN}Running npm run start -- --configuration production${NOCOLOR}"
|
||||||
npm run start -- --prod
|
npm run start -- --configuration production
|
||||||
echo -e "${GREEN}Application started${NOCOLOR}"
|
echo -e "${GREEN}Application started${NOCOLOR}"
|
||||||
exit
|
exit
|
||||||
elif [ $config = 'local' ]; then
|
elif [ $config = 'local' ]; then
|
||||||
@@ -54,6 +54,11 @@ elif [ $config = 'local' ]; then
|
|||||||
npm run start
|
npm run start
|
||||||
echo -e "${GREEN}Application started${NOCOLOR}"
|
echo -e "${GREEN}Application started${NOCOLOR}"
|
||||||
exit
|
exit
|
||||||
|
elif [ $config = 'acc' ]; then
|
||||||
|
echo -e "${CYAN}Running npm run start -- --configuration acc${NOCOLOR}"
|
||||||
|
npm run start -- --configuration acc
|
||||||
|
echo -e "${GREEN}Application started${NOCOLOR}"
|
||||||
|
exit
|
||||||
else
|
else
|
||||||
echo -e "${CYAN}Running npm run start:${CONFIG}${NOCOLOR}"
|
echo -e "${CYAN}Running npm run start:${CONFIG}${NOCOLOR}"
|
||||||
npm run start:$config
|
npm run start:$config
|
||||||
|
|||||||
Reference in New Issue
Block a user