Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Moved to shared jenkins pipeline. Added UiRouter
  • Loading branch information
jcustenborder committed May 11, 2023
commit 67ea9cad49686a811286ccdcac39eb51ca86de77
80 changes: 2 additions & 78 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,79 +1,3 @@
pipeline {
agent {
kubernetes {
cloud 'kubernetes'
inheritFrom 'default'
yaml '''
apiVersion: v1
kind: Pod
metadata:
labels:
some-label: some-label-value
spec:
containers:
- name: java
image: openjdk:11
command:
- cat
tty: true
- name: node
image: node:20.1.0-alpine3.17
command:
- cat
tty: true
'''
}
}
library('jenkins-pipeline@pr-2')

environment {
PROD = "${env.GIT_BRANCH == 'main' || env.GIT_BRANCH == 'master'}"
APPLICATION_VERSION="1.0.${BUILD_NUMBER}"
}

stages {
stage('build') {
steps {
container('node') {
dir('ui') {
sh "npm install"
sh "npm run compile"
sh "npm run bundle"
}
}
container('java') {
dir('server') {
sh "./gradlew clean build --no-daemon"
}
}
}
}
// stage('release') {
// steps {
//// if(env.PROD == "true") {
// container('java') {
// withCredentials([usernamePassword(credentialsId: 'docker-hub', passwordVariable: 'REGISTRY_PASSWORD', usernameVariable: 'REGISTRY_USERNAME')]) {
// sh "./gradlew clean jib --no-daemon -Papplication.version=${APPLICATION_VERSION}"
// }
//// }
// }
// }
// }
// stage('deploy') {
// steps {
// sh "sed 's/DOCKER_IMAGE/nstream\\/demo-ripple:${APPLICATION_VERSION}/g' k8s.yml > k8s.apply.yml"
// archiveArtifacts artifacts: 'k8s.apply.yml', followSymlinks: false
//
// withCredentials([string(credentialsId: 'demo-deployer-k8s-cluster-ca', variable: 'CLUSTER_CA'), string(credentialsId: 'demo-deployer-k8s-cluster-endpoint', variable: 'ENDPOINT')]) {
// withKubeConfig(caCertificate: CLUSTER_CA, credentialsId: 'demo-deployer-k8s-cluster-token', serverUrl: ENDPOINT) {
// container('java'){
// // TODO Figure out a container we can use that already has kubectl so we don't download it each time
// sh "curl --no-progress-meter -O https://s3.us-west-2.amazonaws.com/amazon-eks/1.25.7/2023-03-17/bin/linux/amd64/kubectl"
// sh "chmod +x ./kubectl"
// sh "./kubectl apply -f k8s.apply.yml"
// }
// }
// }
// }
// }
}
}
demoServerUiPipeline("ripple")
3 changes: 2 additions & 1 deletion run.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
cd ui
npm install
npm run compile && npm run bundle
mkdir -p ../server/ui
mkdir -p ../server/ui ../server/src/main/resources/ui/
cp -rf index.html dist ../server/ui/
cp -rf index.html dist ../server/src/main/resources/ui/
cd ../server
./gradlew clean run

33 changes: 33 additions & 0 deletions server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ buildscript {
}
}

plugins {
id 'com.google.cloud.tools.jib' version '3.3.1'
}


apply plugin: 'java-library'
apply plugin: 'application'
apply plugin: 'nebula.ospackage-application'
Expand Down Expand Up @@ -93,6 +98,34 @@ afterEvaluate {
}
}

jib {
from {
image = "openjdk:11"
}
to {
image = "nstream/demo-ripple:${version}"
auth {
username = "$System.env.REGISTRY_USERNAME"
password = "$System.env.REGISTRY_PASSWORD"
}
}
container {
mainClass = mainClassName
ports = ['9001/tcp']
jvmFlags = ['-Dswim.config=/config/server.recon']
}
extraDirectories {
paths {
path {
// copies a single-file.xml
from = 'src/main/resources'
into = '/config'
includes = ['*.recon']
}
}
}
}

run {
dependsOn jar
if (useModules) {
Expand Down
1 change: 1 addition & 0 deletions server/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@
exports swim.ripple;

provides swim.api.plane.Plane with swim.ripple.RipplePlane;
provides swim.kernel.Kernel with swim.ripple.RippleUiRouter;
}
101 changes: 101 additions & 0 deletions server/src/main/java/swim/ripple/RippleUiRouter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
// Copyright 2015-2022 Swim.inc
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package swim.ripple;

import swim.kernel.KernelProxy;
import swim.structure.Value;
import swim.uri.UriPath;
import swim.web.WebRequest;
import swim.web.WebResponse;
import swim.web.WebRoute;
import swim.web.route.ResourceDirectoryRoute;

/**
* SwimOS kernel module for routing HTTP requests for the bundled UI.
*/
public class RippleUiRouter extends KernelProxy {
final double kernelPriority;
final WebRoute uiRoute;

public RippleUiRouter(double kernelPriority) {
this.kernelPriority = kernelPriority;
this.uiRoute = new ResourceDirectoryRoute(getClass().getClassLoader(), UriPath.parse("ui/"), "index.html");
}

public RippleUiRouter() {
this(KERNEL_PRIORITY);
}

@Override
public final double kernelPriority() {
return this.kernelPriority;
}

@Override
public WebResponse routeRequest(WebRequest request) {
final WebResponse response = this.uiRoute.routeRequest(request);
if (response.isAccepted()) {
return response;
} else {
return super.routeRequest(request);
}
}

@Override
public void trace(Object message) {
// Use this hook to intercept and forward trace log messages
}

@Override
public void debug(Object message) {
// Use this hook to intercept and forward debug log messages
}

@Override
public void info(Object message) {
super.info(message);
// Use this hook to intercept and forward info log messages
}

@Override
public void warn(Object message) {
super.warn(message);
// Use this hook to intercept and forward warning log messages
}

@Override
public void error(Object message) {
super.error(message);
// Use this hook to intercept and forward error log messages
}

@Override
public void fail(Object message) {
super.fail(message);
// Use this hook to intercept and forward failure log messages
}

private static final double KERNEL_PRIORITY = 100.0;

public static RippleUiRouter fromValue(Value moduleConfig) {
final Value header = moduleConfig.getAttr("kernel");
final String kernelClassName = header.get("class").stringValue(null);
if (kernelClassName == null || RippleUiRouter.class.getName().equals(kernelClassName)) {
final double kernelPriority = header.get("priority").doubleValue(KERNEL_PRIORITY);
return new RippleUiRouter(kernelPriority);
}
return null;
}
}
2 changes: 1 addition & 1 deletion server/src/main/resources/server.recon
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@kernel(class: 'swim.store.db.DbStoreKernel', optional: true)
@kernel(class: 'swim.reflect.ReflectKernel', optional: true)
@kernel(class: "swim.ripple.RippleUiRouter")

ripple: @fabric {
@plane(class: "swim.ripple.RipplePlane")
Expand All @@ -14,7 +15,6 @@ ripple: @fabric {

@web(port: 9001) {
space: "ripple"
documentRoot: "../ui/"
@websocket {
serverCompressionLevel: 0# -1 = default; 0 = off; 1-9 = deflate level
clientCompressionLevel: 0# -1 = default; 0 = off; 1-9 = deflate level
Expand Down