Skip to content

Commit

Permalink
Initial commits.
Browse files Browse the repository at this point in the history
  • Loading branch information
magnayn committed Mar 26, 2018
1 parent 45406ea commit 4fab3c5
Show file tree
Hide file tree
Showing 145 changed files with 27,283 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
target
.idea
*.iml
attic
5 changes: 5 additions & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Snow globe icon:
https://thenounproject.com/term/snow-globe/27807/

Public domain by Matt Brooks

66 changes: 66 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
node {
stage name:"Checkout"
checkout scm;

// No longer required
//stage name:"Dependencies"
//buildTempDeps()

stage name:"Build"
build()

stage name:"Publish"
publishDocker()
}


def build() {

def mvnHome = tool 'latest'
env.MAVEN_OPTS="-Xmx2G";
withJavaEnv {
sh "${mvnHome}/bin/mvn -DskipTests clean install"
}
}

def publishDocker() {

// Prepare
sh './prod/build.sh';

String tags = "dev.nirima.com/snowglobe:${env.BUILD_NUMBER}";

def image = docker.build(tags, "-f prod/Dockerfile prod");

image.push();
}


def buildTempDeps() {
// Temporary dependencies to things that have not yet been fixed
dir('docker-java') {

git url: "https://github.com/magnayn/docker-java.git"

def mvnHome = tool 'latest'
env.MAVEN_OPTS="-Xmx2G";

sh "${mvnHome}/bin/mvn -DskipTests clean install"
}

}

void withJavaEnv(List envVars = [], def body) {
String npmTool = tool name: 'Node', type: 'jenkins.plugins.nodejs.tools.NodeJSInstallation'
echo npmTool;

List javaEnv = ["PATH+JDK=${npmTool}/bin"]

// Add any additional environment variables.
javaEnv.addAll(envVars)

// Invoke the body closure we're passed within the environment we've created.
withEnv(javaEnv) {
body.call()
}
}
34 changes: 33 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,34 @@
# SnowGlobe
Container Management Tool
Infrastructure as Code

## What is SnowGlobe

SnowGlobe is a tool in the same area as Terraform, Cloudformation, docker-compose.

SnowGlobe is currently very experimental. It is useful for us in our deployment scenarios!

These tools aim to allow you to 'describe' how infrastructure is to be deployed, and allow incremental changes to be made. Instead of writing scripts that perform steps, your configuration defines what you want the outcome to look like, and the tooling figures out the necessary steps needed to make it work.


It is very similar to (and deeply inspired by) Terraform - but with some differences

* SnowGlobe scripts are code. The script is a DSL script built on top of groovy - so all valid groovy (and thus all valid java) can be used.
- This should make more 'advanced' deployment scenarios such as blue/green deployments easier to achieve without building external tools that must modify the deployment descriptor.

* SnowGlobe is built on Java/Groovy rather than golang

* Terraform tends to concentrate more on AWS - we are interested (primarily) in Docker, though other providers could easily be added

* It is easier to build 'layers' in SnowGlobe (e.g: a 'base' layer that defines a consul-on-docker, and an 'app' layer that then uses it.

* Terraform is much more mature and has more effort applied to it.

## Docker Image

Running the docker image:

* Use a volume so stored globes & state survive.

docker run -dtiP -v /Users/store/.snowglobe:/var/snowglobe -v /var/run/docker.sock:/var/run/docker.sock nirima/snowglobe

[docs](./docs/index.md)
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
theme: jekyll-theme-cayman
3 changes: 3 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Documentation
-------------

19 changes: 19 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.nirima.workspaces</groupId>
<artifactId>snowglobe-workspace</artifactId>
<packaging>pom</packaging>
<version>0.0.1</version>



<modules>
<module>pom</module>
<module>snowglobe</module>

</modules>



</project>
127 changes: 127 additions & 0 deletions pom/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>SnowGlobe Parent POM</name>
<groupId>com.nirima.snowglobe</groupId>
<artifactId>master-pom</artifactId>
<packaging>pom</packaging>
<version>0.0.1</version>

<scm>
<connection>scm:git:git://github.com/nirima/SnowGlobe.git</connection>
<developerConnection>scm:git:[email protected]:nirima/SnowGlobe.git</developerConnection>
<url>http://github.com/nirima/SnowGlobe</url>
</scm>


<properties>
<gmavenVersion>1.6</gmavenVersion>
<gmavenProviderSelection>2.0</gmavenProviderSelection>
<groovyVersion>2.4.12</groovyVersion>
<groovy.version>2.4.12</groovy.version>

<jetty.version>9.3.21.v20170918</jetty.version>

<slf4j.version>1.7.25</slf4j.version>
<jersey.version>2.22.1</jersey.version>
<jackson.version>2.9.4</jackson.version>
<guice.version>4.0</guice.version>
<httpclient.version>4.5.3</httpclient.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<graniteds.version>3.0.4.GA</graniteds.version>
<shiro.version>1.2.5</shiro.version>
<hibernate.version>5.2.8.Final</hibernate.version>
<hibernate.validator.version>4.2.0.Final</hibernate.validator.version>
<guicebridge.version>2.5.0-b60</guicebridge.version>
<tomcat.version>8.0.30</tomcat.version>
<cfg4j.version>4.4.0</cfg4j.version>
<logback.version>1.2.3</logback.version>
</properties>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<fork>true</fork>
</configuration>
</plugin>
</plugins>
</pluginManagement>

</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>${groovy.version}</version>
</dependency>

<dependency>
<groupId>org.cfg4j</groupId>
<artifactId>cfg4j-core</artifactId>
<version>${cfg4j.version}</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>19.0</version>
</dependency>
<dependency>
<groupId>com.github.docker-java</groupId>
<artifactId>docker-java</artifactId>
<version>3.0.14</version>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${httpclient.version}</version>
</dependency>



<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>


</dependencies>
</dependencyManagement>


</project>
25 changes: 25 additions & 0 deletions prod/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM java:8

# dot for images
RUN apt-get update && apt-get install -y graphviz && rm -rf /var/lib/apt/lists/*

RUN mkdir -p /usr/local/snowglobe/
RUN mkdir -p /var/snowglobe/


ADD snowglobe.jar /usr/local/snowglobe/
ADD run.sh /usr/local/snowglobe/

RUN chmod -R a+rw /usr/local/snowglobe

RUN ls -l /usr/local/snowglobe

ENV repositoryRoot /var/snowglobe

#expose so it can survive restarts
VOLUME /var/snowglobe
VOLUME /var/run/docker.sock

EXPOSE 8808

CMD ["/bin/bash", "/usr/local/snowglobe/run.sh"]
21 changes: 21 additions & 0 deletions prod/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

#DIR = directory of script
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

rm $DIR/*.war
rm $DIR/*.jar

ls

M2_REPO=~/.m2/repository
VERSION=0.0.1

BINARY_JAR=$DIR/../snowglobe/server/snowglobe-server-exe/target/snowglobe-server-exe-$VERSION-jar-with-dependencies.jar

echo Directory = $DIR
echo Binary = $BINARY_JAR

cp $BINARY_JAR $DIR/snowglobe.jar

# --> docker build -f Dockerfile -t snowglobe .
5 changes: 5 additions & 0 deletions prod/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

cd /usr/local/snowglobe

java -jar snowglobe.jar
25 changes: 25 additions & 0 deletions snowglobe/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0"?>
<project>
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.nirima.snowglobe</groupId>
<artifactId>master-pom</artifactId>
<version>0.0.1</version>
<relativePath>../pom/pom.xml</relativePath>
</parent>


<groupId>com.nirima</groupId>
<artifactId>snowglobe</artifactId>
<packaging>pom</packaging>

<modules>
<module>server</module>
<module>snowglobe-core</module>
<module>snowglobe-sinatra</module>
<module>snowglobe-exe</module>
</modules>


</project>
25 changes: 25 additions & 0 deletions snowglobe/server/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.nirima.snowglobe</groupId>
<artifactId>server</artifactId>
<packaging>pom</packaging>

<parent>
<groupId>com.nirima</groupId>
<artifactId>snowglobe</artifactId>
<version>0.0.1</version>
</parent>

<properties>

</properties>

<modules>
<module>snowglobe-webapp</module>
<module>snowglobe-war</module>
<module>snowglobe-server-ui</module>
<module>snowglobe-server-exe</module>
</modules>

</project>
Loading

0 comments on commit 4fab3c5

Please sign in to comment.