From 8dfbeee1b1516e58f76d902b8050343046f3fcf9 Mon Sep 17 00:00:00 2001 From: FyloZ Date: Fri, 12 Feb 2021 00:48:28 -0500 Subject: [PATCH] CI/CD --- .gitlab-ci.yml | 2 +- build.gradle.kts | 5 ++++- ng.Dockerfile | 4 +++- src/main/frontend/src/environments/environment.prod.ts | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dee58a5..543b14a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -66,7 +66,7 @@ package-frontend: - apk update - apk add --no-cache zip - mkdir dist - - docker run --name $PACKAGE_CONTAINER_NAME $CI_REGISTRY_IMAGE_NG gradle buildFrontend + - docker run --name $PACKAGE_CONTAINER_NAME $CI_REGISTRY_IMAGE_NG gradle buildFrontend -PfrontendConfiguration=$FRONTEND_CONFIGURATION - docker cp $PACKAGE_CONTAINER_NAME:/usr/src/cre/dist/frontend/ dist/ - zip -r $ARTIFACT_NAME.zip dist/ - docker build -t $CI_REGISTRY_IMAGE_FRONTEND -f frontend.Dockerfile --build-arg ARTIFACT_NAME=$ARTIFACT_NAME . diff --git a/build.gradle.kts b/build.gradle.kts index b823a05..8f816b5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -111,6 +111,9 @@ tasks.register("buildBackend") { tasks.register("buildFrontend") { val outputDirectory = "dist/frontend" println("Building Angular frontend to ${projectDir.absolutePath}/$outputDirectory") + + val configuration = project.gradle.startParameter.projectProperties["frontendConfiguration"] ?: "production" + println("Using configuration $configuration") // Creates the output directory if it does not exists. val outputDirectoryFile = File("${projectDir.absolutePath}/$outputDirectory") @@ -123,7 +126,7 @@ tasks.register("buildFrontend") { } exec { - commandLineUniversal("cd src/main/frontend && npm run-script build") + commandLineUniversal("cd src/main/frontend && ng build --configuration=$configuration --output-hashing=none --stats-json --source-map=false") } exec { diff --git a/ng.Dockerfile b/ng.Dockerfile index 23f9932..e2db3d9 100644 --- a/ng.Dockerfile +++ b/ng.Dockerfile @@ -7,7 +7,9 @@ WORKDIR /usr/src/cre/ RUN apt update RUN apt install nodejs -y RUN apt install npm -y -RUN apt install zip -y + +RUN npm install -g typescript@3.9.7 +RUN npm install -g @angular/cli || true ENV NG_CLI_ANALYTICS=ci diff --git a/src/main/frontend/src/environments/environment.prod.ts b/src/main/frontend/src/environments/environment.prod.ts index 932df64..583d460 100644 --- a/src/main/frontend/src/environments/environment.prod.ts +++ b/src/main/frontend/src/environments/environment.prod.ts @@ -1,4 +1,4 @@ export const environment = { production: true, - apiUrl: '/api' + apiUrl: 'https://cre.fyloz.dev/api' };