-
Notifications
You must be signed in to change notification settings - Fork 0
add Jenkinsfile for build ci pipeline #542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| node_modules | ||
| dist | ||
| .git | ||
| .gitignore | ||
| .env | ||
| .env.* | ||
| *.log | ||
| public/config.js |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| VITE_ENABLE_LOCAL_DEVELOPMENT=false | ||
|
|
||
| # url settings | ||
| VITE_APP_BASE_URL=https://bellis.celdev.sneakapeek.ch | ||
| VITE_CEL_API_URL=https://bellis.celdev.sneakapeek.ch | ||
|
|
||
| # keycloak configuration | ||
| VITE_KEYCLOAK_BASE_URL=https://iam.demospace.ch | ||
| VITE_KEYCLOAK_REALM=celdev | ||
| VITE_KEYCLOAK_CLIENT_ID=celdev | ||
|
|
||
| # cel access | ||
| VITE_CEL_USER= | ||
| VITE_CEL_TOKEN= | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could we remove for local configuration: cp config.sample.js public/config.js && vim public/config.js |
||
This file was deleted.
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use newly available dockerImagePipeline in with e.g.: https://github.com/progonline/progon-apps/blob/dev/event-webform/event-webform-frontend/Jenkinsfile |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| def appImage | ||
|
|
||
| pipeline { | ||
| agent { label 'docker' } | ||
| environment { | ||
| REGISTRY = 'ghcr.io' | ||
| ORG_NAME = 'celements' | ||
| APP_DIR = 'celements-admin-frontend' | ||
| IMAGE_NAME = 'celements-admin-frontend' | ||
| DOCKER_BUILDKIT = '1' | ||
| } | ||
| options { | ||
| disableConcurrentBuilds() | ||
| skipDefaultCheckout(true) | ||
| timestamps() | ||
| } | ||
| stages { | ||
| stage('Checkout') { | ||
| steps { | ||
| checkout scm | ||
| } | ||
| } | ||
| stage('Prepare Build') { | ||
| steps { | ||
| dir(APP_DIR) { | ||
| script { | ||
| env.GIT_REV = sh(script: 'git rev-parse HEAD', returnStdout: true).trim() | ||
| env.GIT_SHA = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim() | ||
| env.VERSION = sh( | ||
| script: 'node -p "require(\'./package.json\').version"', | ||
| returnStdout: true | ||
| ).trim() | ||
| env.IMAGE_REF = "${REGISTRY}/${ORG_NAME}/${IMAGE_NAME}:${VERSION}" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| stage('Build Frontend Docker Image') { | ||
| steps { | ||
| dir(APP_DIR) { | ||
| script { | ||
| appImage = docker.build( | ||
| IMAGE_REF, | ||
| "--build-arg VERSION=${VERSION} " + | ||
| "--build-arg REVISION=${GIT_REV} " + | ||
| "--load ." | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| stage('Push to GHCR') { | ||
| steps { | ||
| script { | ||
| docker.withRegistry("https://${REGISTRY}", 'ghcr-credentials') { | ||
| appImage.push() | ||
| appImage.push("${VERSION}-${GIT_SHA}") | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| :80 { | ||
| root * /srv | ||
|
|
||
| handle /config.js { | ||
| header Cache-Control "no-store, no-cache, must-revalidate" | ||
| file_server | ||
| } | ||
|
|
||
| handle { | ||
| try_files {path} /index.html | ||
| file_server | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,22 @@ | ||||||||||||||||||||||
| #!/bin/sh | ||||||||||||||||||||||
| set -eu | ||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
POSIX.1-2024 specification added support for |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| escape_js_string() { | ||||||||||||||||||||||
| printf '%s' "$1" | sed \ | ||||||||||||||||||||||
| -e 's/\\/\\\\/g' \ | ||||||||||||||||||||||
| -e "s/'/\\\\'/g" | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| cat > /srv/config.js <<EOF | ||||||||||||||||||||||
| window.__APP_CONFIG__ = { | ||||||||||||||||||||||
| appBaseUrl: '$(escape_js_string "${APP_BASE_URL:-}")', | ||||||||||||||||||||||
| keycloakBaseUrl: '$(escape_js_string "${KEYCLOAK_BASE_URL:-}")', | ||||||||||||||||||||||
| keycloakRealm: '$(escape_js_string "${KEYCLOAK_REALM:-}")', | ||||||||||||||||||||||
| keycloakClientId: '$(escape_js_string "${KEYCLOAK_CLIENT_ID:-}")', | ||||||||||||||||||||||
| keycloakClientSecret: '$(escape_js_string "${KEYCLOAK_CLIENT_SECRET:-}")', | ||||||||||||||||||||||
|
Comment on lines
+12
to
+16
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
mandatory fields should fast fail if unset (sh strict mode) to prevent config errors. |
||||||||||||||||||||||
| defaultLocale: '$(escape_js_string "${DEFAULT_LOCALE:-de}")', | ||||||||||||||||||||||
| enableLocalDevelopment: ${ENABLE_LOCAL_DEVELOPMENT:-false} | ||||||||||||||||||||||
| }; | ||||||||||||||||||||||
| EOF | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| exec "$@" | ||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| window.__APP_CONFIG__ = { | ||
| appBaseUrl: 'http://localhost:5173', | ||
| keycloakBaseUrl: 'https://iam.demospace.ch', | ||
| keycloakRealm: 'celdev', | ||
| keycloakClientId: 'celdev', | ||
| keycloakClientSecret: '', | ||
| defaultLocale: 'de', | ||
| enableLocalDevelopment: false | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| import '@/assets/main.css'; | ||
|
|
||
| import App from '@/App.vue'; | ||
| import { appConfig } from '@/conf/app'; | ||
| import { useAuthStore } from '@/core/stores/auth'; | ||
| import { createI18n } from '@/plugins/i18n'; | ||
| import { createAuthPlugin } from '@/plugins/plugin.auth'; | ||
|
|
@@ -112,7 +113,7 @@ export function createCelementsAdminApp(options: CelementsAdminMountOptions = {} | |
| const authStore = useAuthStore(); | ||
| const Auth = createAuthPlugin(Router, authStore); | ||
|
|
||
| const locale = options.locale ?? import.meta.env.VITE_DEFAULT_LOCALE; | ||
| const locale = options.locale ?? appConfig.defaultLocale; | ||
|
|
||
| app.use(Router); | ||
| app.use(createI18n({ locale })); | ||
|
|
@@ -128,7 +129,7 @@ export function createCelementsAdminApp(options: CelementsAdminMountOptions = {} | |
| }); | ||
|
|
||
| const localDev = | ||
| options.localDev ?? (import.meta.env.VITE_ENABLE_LOCAL_DEVELOPMENT ?? 'true') === 'true'; | ||
| options.localDev ?? appConfig.enableLocalDevelopment; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wouldnt it be simpler to use |
||
|
|
||
| app.provide('localDev', localDev); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| export interface AppConfig { | ||
| appBaseUrl: string; | ||
| keycloakBaseUrl: string; | ||
| keycloakRealm: string; | ||
| keycloakClientId: string; | ||
| keycloakClientSecret: string; | ||
| defaultLocale: string; | ||
| enableLocalDevelopment: boolean; | ||
| } | ||
|
|
||
| declare global { | ||
| interface Window { | ||
| __APP_CONFIG__?: Partial<AppConfig>; | ||
| } | ||
| } | ||
|
|
||
| export const appConfig: Readonly<AppConfig> = { | ||
| appBaseUrl: window.__APP_CONFIG__?.appBaseUrl || (import.meta.env.VITE_APP_BASE_URL as string) || '', | ||
| keycloakBaseUrl: window.__APP_CONFIG__?.keycloakBaseUrl || (import.meta.env.VITE_KEYCLOAK_BASE_URL as string) || '', | ||
| keycloakRealm: window.__APP_CONFIG__?.keycloakRealm || (import.meta.env.VITE_KEYCLOAK_REALM as string) || '', | ||
| keycloakClientId: window.__APP_CONFIG__?.keycloakClientId || (import.meta.env.VITE_KEYCLOAK_CLIENT_ID as string) || '', | ||
| keycloakClientSecret: window.__APP_CONFIG__?.keycloakClientSecret || (import.meta.env.VITE_KEYCLOAK_CLIENT_SECRET as string) || '', | ||
| defaultLocale: window.__APP_CONFIG__?.defaultLocale || (import.meta.env.VITE_DEFAULT_LOCALE as string) || 'de', | ||
| enableLocalDevelopment: window.__APP_CONFIG__?.enableLocalDevelopment !== undefined | ||
| ? window.__APP_CONFIG__.enableLocalDevelopment | ||
| : (import.meta.env.VITE_ENABLE_LOCAL_DEVELOPMENT ?? 'true') === 'true', | ||
| }; |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,3 +1,4 @@ | ||||||||||||||
| import { appConfig } from '@/conf/app'; | ||||||||||||||
| import { AuthService, createAuthService } from '@/core/services/auth/auth-service'; | ||||||||||||||
| import type { AuthOptions } from '@/core/services/auth/types'; | ||||||||||||||
| import type { AuthState } from '@/core/types/auth'; | ||||||||||||||
|
|
@@ -8,12 +9,12 @@ import type { Router } from 'vue-router'; | |||||||||||||
|
|
||||||||||||||
| const logger = useLogger('AuthPlugin'); | ||||||||||||||
|
|
||||||||||||||
| // Get keycloak specific data from env | ||||||||||||||
| const appBaseUrl = import.meta.env.VITE_APP_BASE_URL; | ||||||||||||||
| const authBaseUrl = import.meta.env.VITE_KEYCLOAK_BASE_URL; | ||||||||||||||
| const realm = import.meta.env.VITE_KEYCLOAK_REALM; | ||||||||||||||
| const clientId = import.meta.env.VITE_KEYCLOAK_CLIENT_ID; | ||||||||||||||
| const clientSecret = import.meta.env.VITE_KEYCLOAK_CLIENT_SECRET; | ||||||||||||||
| // Get keycloak specific data from config | ||||||||||||||
| const appBaseUrl = appConfig.appBaseUrl; | ||||||||||||||
| const authBaseUrl = appConfig.keycloakBaseUrl; | ||||||||||||||
| const realm = appConfig.keycloakRealm; | ||||||||||||||
| const clientId = appConfig.keycloakClientId; | ||||||||||||||
| const clientSecret = appConfig.keycloakClientSecret; | ||||||||||||||
|
Comment on lines
+13
to
+17
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
|
|
||||||||||||||
| const createAuthPlugin = (router: Router, authStore: Store<'auth', AuthState>) => { | ||||||||||||||
| const options: AuthOptions = { | ||||||||||||||
|
|
||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more frontends will likely follow :)