diff --git a/.dockerignore b/.dockerignore index 2f00d4c1b..cb1beb5e7 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,5 @@ node_modules *~ *.swp +runtime/node_modules +fabric8-ui \ No newline at end of file diff --git a/Dockerfile.deploy.runtime b/Dockerfile.deploy.runtime new file mode 100644 index 000000000..ff455ee0f --- /dev/null +++ b/Dockerfile.deploy.runtime @@ -0,0 +1,11 @@ +FROM fabric8/fabric8-openshift-nginx:vd83b3a1 + +USER root + +RUN rm -rf /usr/share/nginx/html/ +COPY ./runtime/dist /usr/share/nginx/html +RUN chmod -R 777 /var/lib/nginx/ +RUN chmod -R 777 /usr/share/nginx/html/ + + +USER ${FABRIC8_USER_NAME} \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile index 1d7baffd3..46e8feb8a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,10 +1,11 @@ -@Library('github.com/fabric8io/fabric8-pipeline-library@master') +@Library('github.com/pranavgore09/fabric8-pipeline-library@standalone-planner') def utils = new io.fabric8.Utils() def flow = new io.fabric8.Fabric8Commands() def project = 'fabric8-ui/fabric8-planner' def ciDeploy = false def tempVersion def imageName +def standaloneImageName node{ properties([ disableConcurrentBuilds() @@ -27,9 +28,12 @@ fabric8UITemplate{ pipeline.buildImage(imageName) } + standaloneImageName = "fabric8/fabric8-planner:${tempVersion}" + container('docker'){ + pipeline.getStandaloneImage(standaloneImageName) + } ciDeploy = true - } else if (utils.isCD()){ sh "git checkout master" sh "git pull" @@ -65,10 +69,10 @@ fabric8UITemplate{ // deploy a snapshot fabric8-ui pod and notify pull request of details if (ciDeploy){ - def prj = 'fabric8-ui-'+ env.BRANCH_NAME - prj = prj.toLowerCase() - def route - timeout(time: 10, unit: 'MINUTES') { + timeout(time: 50, unit: 'MINUTES') { + def prj = 'fabric8-ui-'+ env.BRANCH_NAME + prj = prj.toLowerCase() + def route deployOpenShiftNode(openshiftConfigSecretName: 'fabric8-intcluster-config'){ stage("deploy ${prj}"){ route = deployOpenShiftSnapshot{ @@ -95,5 +99,33 @@ if (ciDeploy){ } } } + prj = 'f8-plan-std'+ env.BRANCH_NAME + prj = prj.toLowerCase() + deployOpenShiftNode(openshiftConfigSecretName: 'fabric8-intcluster-config'){ + stage("deploy ${prj}"){ + route = deployPlannerSnapshot{ + openShiftProject = prj + openShiftTemplate = 'https://raw.githubusercontent.com/pranavgore09/fabric8-planner/standalone-plannerUI-snapshot/openshift/fabric8-planner.app.yml' + originalImageName = 'fabric8/fabric8-planner' + newImageName = standaloneImageName + githubRepo = 'fabric8-planner' + githubProject = project + } + } + stage("notify for ${prj}"){ + def changeAuthor = env.CHANGE_AUTHOR + if (!changeAuthor){ + error "no commit author found so cannot comment on PR" + } + def pr = env.CHANGE_ID + if (!pr){ + error "no pull request number found so cannot comment on PR" + } + def message = "@${changeAuthor} ${imageName} standalone planner UI is deployed and available for testing at http://${route}" + container('clients'){ + flow.addCommentToPullRequest(message, pr, project) + } + } + } } } diff --git a/deploy/release.groovy b/deploy/release.groovy index 126d990ed..85508a58e 100644 --- a/deploy/release.groovy +++ b/deploy/release.groovy @@ -47,6 +47,40 @@ def buildImage(imageName){ } } +def getStandaloneImage(imageName){ + stage('build standalone npm') { + container('ui'){ + sh ''' + npm install + npm run build + npm pack dist/ + ''' + } + dir('runtime'){ + container('ui'){ + sh 'npm cache clean --force' + sh 'npm install' + sh ''' + export API_URL=https://api.prod-preview.openshift.io/api/ + export FABRIC8_REALM=fabric8-test + export FABRIC8_WIT_API_URL=https://api.prod-preview.openshift.io/api/ + export FABRIC8_SSO_API_URL=https://sso.prod-preview.openshift.io/ + export FABRIC8_AUTH_API_URL=https://auth.prod-preview.openshift.io/api/ + npm run build + ''' + } + } + } + + stage('build standalone snapshot image'){ + sh "docker build -t ${imageName} -f ./Dockerfile.deploy.runtime ." + } + + stage('push standalone snapshot image'){ + sh "docker push ${imageName}" + } +} + def cd (b){ stage('Repo Fix'){ sh './scripts/fix-git-repo.sh' diff --git a/openshift/fabric8-planner.app.yml b/openshift/fabric8-planner.app.yml new file mode 100644 index 000000000..811a7aa22 --- /dev/null +++ b/openshift/fabric8-planner.app.yml @@ -0,0 +1,161 @@ +apiVersion: v1 +kind: Template +metadata: + name: f8planner + creationTimestamp: null +objects: +- apiVersion: v1 + kind: DeploymentConfig + metadata: + creationTimestamp: null + generation: 1 + labels: + service: f8planner + app: fabric8-planner + provider: fabric8 + name: f8planner + spec: + replicas: 3 + selector: + service: f8planner + strategy: + resources: {} + rollingParams: + intervalSeconds: 1 + maxSurge: 25% + maxUnavailable: 25% + timeoutSeconds: 600 + updatePeriodSeconds: 1 + type: Rolling + template: + metadata: + creationTimestamp: null + labels: + service: f8planner + app: fabric8-planner + provider: fabric8 + spec: + containers: + - image: fabric8/fabric8-planner:standalone + imagePullPolicy: Always + name: f8planner + ports: + - containerPort: 80 + protocol: TCP + env: + - name: WS_K8S_API_SERVER + value: ${WS_K8S_API_SERVER} + - name: K8S_API_SERVER_PROTOCOL + value: ${K8S_API_SERVER_PROTOCOL} + - name: K8S_API_SERVER_BASE_PATH + value: ${K8S_API_SERVER_BASE_PATH} + - name: OAUTH_ISSUER + value: ${OAUTH_ISSUER} + - name: OAUTH_CLIENT_ID + value: ${OAUTH_CLIENT_ID} + - name: OAUTH_SCOPE + value: ${OAUTH_SCOPE} + - name: OAUTH_AUTHORIZE_URI + value: ${OAUTH_AUTHORIZE_URI} + - name: AUTH_LOGOUT_URI + value: ${AUTH_LOGOUT_URI} + - name: FABRIC8_PIPELINES_NAMESPACE + value: ${FABRIC8_PIPELINES_NAMESPACE} + - name: PROXIED_K8S_API_SERVER + value: ${PROXIED_K8S_API_SERVER} + - name: PROXY_PASS_URL + value: ${PROXY_PASS_URL} + - name: FABRIC8_RECOMMENDER_API_URL + value: ${FABRIC8_RECOMMENDER_API_URL} + - name: FABRIC8_FORGE_API_URL + value: ${FABRIC8_FORGE_API_URL} + - name: OPENSHIFT_CONSOLE_URL + value: ${OPENSHIFT_CONSOLE_URL} + resources: {} + terminationMessagePath: /dev/termination-log + readinessProbe: + tcpSocket: + port: 8080 + initialDelaySeconds: 20 + timeoutSeconds: 10 + livenessProbe: + tcpSocket: + port: 8080 + initialDelaySeconds: 120 + timeoutSeconds: 10 + dnsPolicy: ClusterFirst + restartPolicy: Always + securityContext: {} + terminationGracePeriodSeconds: 30 + test: false + triggers: + - type: ConfigChange + status: {} +- apiVersion: v1 + kind: Service + metadata: + creationTimestamp: null + labels: + service: f8planner + app: fabric8-planner + provider: fabric8 + name: f8planner + spec: + ports: + - name: "8080" + port: 8080 + protocol: TCP + targetPort: 8080 + selector: + service: f8planner + sessionAffinity: None + type: ClusterIP + status: + loadBalancer: {} +- apiVersion: v1 + kind: Route + metadata: + creationTimestamp: null + labels: + service: f8planner + app: fabric8-planner + provider: fabric8 + name: fabric8-planner + spec: + host: '' + port: + targetPort: "8080" + to: + kind: Service + name: f8planner + weight: 100 + wildcardPolicy: None + status: {} +parameters: +- name: WS_K8S_API_SERVER + value: api.free-int.openshift.com:443 +- name: K8S_API_SERVER_PROTOCOL + value: https +- name: K8S_API_SERVER_BASE_PATH + value: /_p/oso +- name: OAUTH_ISSUER + value: https://api.free-int.openshift.com:443 +- name: OAUTH_CLIENT_ID + value: fabric8 +- name: OAUTH_SCOPE + value: user:full +- name: OAUTH_AUTHORIZE_URI + value: https://api.free-int.openshift.com:443/oauth/authorize +- name: AUTH_LOGOUT_URI + value: https://api.free-int.openshift.com:443/connect/endsession?id_token={{id_token}} +- name: FABRIC8_PIPELINES_NAMESPACE +- name: PROXY_PASS_URL + value: https://api.free-int.openshift.com:443 +- name: OPENSHIFT_CONSOLE_URL + value: https://console.free-int.openshift.com/console/ +- name: PROXIED_K8S_API_SERVER + value: api.free-int.openshift.com:443 +- name: FABRIC8_RECOMMENDER_API_URL + value: https://api-bayesian.dev.rdu2c.fabric8.io/api/v1/ +- name: FABRIC8_FORGE_API_URL + value: https://forge.api.prod-preview.openshift.io