Skip to content

Commit 4fab3c5

Browse files
committed
Initial commits.
1 parent 45406ea commit 4fab3c5

145 files changed

Lines changed: 27283 additions & 1 deletion

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@
1010

1111
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
1212
hs_err_pid*
13+
target
14+
.idea
15+
*.iml
16+
attic

CREDITS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Snow globe icon:
2+
https://thenounproject.com/term/snow-globe/27807/
3+
4+
Public domain by Matt Brooks
5+

Jenkinsfile

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
node {
2+
stage name:"Checkout"
3+
checkout scm;
4+
5+
// No longer required
6+
//stage name:"Dependencies"
7+
//buildTempDeps()
8+
9+
stage name:"Build"
10+
build()
11+
12+
stage name:"Publish"
13+
publishDocker()
14+
}
15+
16+
17+
def build() {
18+
19+
def mvnHome = tool 'latest'
20+
env.MAVEN_OPTS="-Xmx2G";
21+
withJavaEnv {
22+
sh "${mvnHome}/bin/mvn -DskipTests clean install"
23+
}
24+
}
25+
26+
def publishDocker() {
27+
28+
// Prepare
29+
sh './prod/build.sh';
30+
31+
String tags = "dev.nirima.com/snowglobe:${env.BUILD_NUMBER}";
32+
33+
def image = docker.build(tags, "-f prod/Dockerfile prod");
34+
35+
image.push();
36+
}
37+
38+
39+
def buildTempDeps() {
40+
// Temporary dependencies to things that have not yet been fixed
41+
dir('docker-java') {
42+
43+
git url: "https://github.com/magnayn/docker-java.git"
44+
45+
def mvnHome = tool 'latest'
46+
env.MAVEN_OPTS="-Xmx2G";
47+
48+
sh "${mvnHome}/bin/mvn -DskipTests clean install"
49+
}
50+
51+
}
52+
53+
void withJavaEnv(List envVars = [], def body) {
54+
String npmTool = tool name: 'Node', type: 'jenkins.plugins.nodejs.tools.NodeJSInstallation'
55+
echo npmTool;
56+
57+
List javaEnv = ["PATH+JDK=${npmTool}/bin"]
58+
59+
// Add any additional environment variables.
60+
javaEnv.addAll(envVars)
61+
62+
// Invoke the body closure we're passed within the environment we've created.
63+
withEnv(javaEnv) {
64+
body.call()
65+
}
66+
}

README.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,34 @@
11
# SnowGlobe
2-
Container Management Tool
2+
Infrastructure as Code
3+
4+
## What is SnowGlobe
5+
6+
SnowGlobe is a tool in the same area as Terraform, Cloudformation, docker-compose.
7+
8+
SnowGlobe is currently very experimental. It is useful for us in our deployment scenarios!
9+
10+
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.
11+
12+
13+
It is very similar to (and deeply inspired by) Terraform - but with some differences
14+
15+
* 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.
16+
- 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.
17+
18+
* SnowGlobe is built on Java/Groovy rather than golang
19+
20+
* Terraform tends to concentrate more on AWS - we are interested (primarily) in Docker, though other providers could easily be added
21+
22+
* 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.
23+
24+
* Terraform is much more mature and has more effort applied to it.
25+
26+
## Docker Image
27+
28+
Running the docker image:
29+
30+
* Use a volume so stored globes & state survive.
31+
32+
docker run -dtiP -v /Users/store/.snowglobe:/var/snowglobe -v /var/run/docker.sock:/var/run/docker.sock nirima/snowglobe
33+
34+
[docs](./docs/index.md)

_config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
theme: jekyll-theme-cayman

docs/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Documentation
2+
-------------
3+

pom.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.nirima.workspaces</groupId>
5+
<artifactId>snowglobe-workspace</artifactId>
6+
<packaging>pom</packaging>
7+
<version>0.0.1</version>
8+
9+
10+
11+
<modules>
12+
<module>pom</module>
13+
<module>snowglobe</module>
14+
15+
</modules>
16+
17+
18+
19+
</project>

pom/pom.xml

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
<?xml version="1.0"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<name>SnowGlobe Parent POM</name>
7+
<groupId>com.nirima.snowglobe</groupId>
8+
<artifactId>master-pom</artifactId>
9+
<packaging>pom</packaging>
10+
<version>0.0.1</version>
11+
12+
<scm>
13+
<connection>scm:git:git://github.com/nirima/SnowGlobe.git</connection>
14+
<developerConnection>scm:git:git@github.com:nirima/SnowGlobe.git</developerConnection>
15+
<url>http://github.com/nirima/SnowGlobe</url>
16+
</scm>
17+
18+
19+
<properties>
20+
<gmavenVersion>1.6</gmavenVersion>
21+
<gmavenProviderSelection>2.0</gmavenProviderSelection>
22+
<groovyVersion>2.4.12</groovyVersion>
23+
<groovy.version>2.4.12</groovy.version>
24+
25+
<jetty.version>9.3.21.v20170918</jetty.version>
26+
27+
<slf4j.version>1.7.25</slf4j.version>
28+
<jersey.version>2.22.1</jersey.version>
29+
<jackson.version>2.9.4</jackson.version>
30+
<guice.version>4.0</guice.version>
31+
<httpclient.version>4.5.3</httpclient.version>
32+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
33+
<graniteds.version>3.0.4.GA</graniteds.version>
34+
<shiro.version>1.2.5</shiro.version>
35+
<hibernate.version>5.2.8.Final</hibernate.version>
36+
<hibernate.validator.version>4.2.0.Final</hibernate.validator.version>
37+
<guicebridge.version>2.5.0-b60</guicebridge.version>
38+
<tomcat.version>8.0.30</tomcat.version>
39+
<cfg4j.version>4.4.0</cfg4j.version>
40+
<logback.version>1.2.3</logback.version>
41+
</properties>
42+
43+
<build>
44+
<pluginManagement>
45+
<plugins>
46+
<plugin>
47+
<groupId>org.apache.maven.plugins</groupId>
48+
<artifactId>maven-compiler-plugin</artifactId>
49+
<version>3.7.0</version>
50+
<configuration>
51+
<source>1.8</source>
52+
<target>1.8</target>
53+
<encoding>UTF-8</encoding>
54+
<fork>true</fork>
55+
</configuration>
56+
</plugin>
57+
</plugins>
58+
</pluginManagement>
59+
60+
</build>
61+
<dependencyManagement>
62+
<dependencies>
63+
<dependency>
64+
<groupId>org.codehaus.groovy</groupId>
65+
<artifactId>groovy-all</artifactId>
66+
<version>${groovy.version}</version>
67+
</dependency>
68+
69+
<dependency>
70+
<groupId>org.cfg4j</groupId>
71+
<artifactId>cfg4j-core</artifactId>
72+
<version>${cfg4j.version}</version>
73+
</dependency>
74+
75+
<dependency>
76+
<groupId>org.slf4j</groupId>
77+
<artifactId>slf4j-api</artifactId>
78+
<version>${slf4j.version}</version>
79+
</dependency>
80+
81+
<dependency>
82+
<groupId>com.google.guava</groupId>
83+
<artifactId>guava</artifactId>
84+
<version>19.0</version>
85+
</dependency>
86+
<dependency>
87+
<groupId>com.github.docker-java</groupId>
88+
<artifactId>docker-java</artifactId>
89+
<version>3.0.14</version>
90+
</dependency>
91+
92+
<dependency>
93+
<groupId>ch.qos.logback</groupId>
94+
<artifactId>logback-core</artifactId>
95+
<version>${logback.version}</version>
96+
</dependency>
97+
<dependency>
98+
<groupId>ch.qos.logback</groupId>
99+
<artifactId>logback-classic</artifactId>
100+
<version>${logback.version}</version>
101+
</dependency>
102+
103+
<dependency>
104+
<groupId>org.apache.httpcomponents</groupId>
105+
<artifactId>httpclient</artifactId>
106+
<version>${httpclient.version}</version>
107+
</dependency>
108+
109+
110+
111+
<dependency>
112+
<groupId>org.apache.commons</groupId>
113+
<artifactId>commons-io</artifactId>
114+
<version>1.4</version>
115+
</dependency>
116+
<dependency>
117+
<groupId>commons-io</groupId>
118+
<artifactId>commons-io</artifactId>
119+
<version>2.5</version>
120+
</dependency>
121+
122+
123+
</dependencies>
124+
</dependencyManagement>
125+
126+
127+
</project>

prod/Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM java:8
2+
3+
# dot for images
4+
RUN apt-get update && apt-get install -y graphviz && rm -rf /var/lib/apt/lists/*
5+
6+
RUN mkdir -p /usr/local/snowglobe/
7+
RUN mkdir -p /var/snowglobe/
8+
9+
10+
ADD snowglobe.jar /usr/local/snowglobe/
11+
ADD run.sh /usr/local/snowglobe/
12+
13+
RUN chmod -R a+rw /usr/local/snowglobe
14+
15+
RUN ls -l /usr/local/snowglobe
16+
17+
ENV repositoryRoot /var/snowglobe
18+
19+
#expose so it can survive restarts
20+
VOLUME /var/snowglobe
21+
VOLUME /var/run/docker.sock
22+
23+
EXPOSE 8808
24+
25+
CMD ["/bin/bash", "/usr/local/snowglobe/run.sh"]

prod/build.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
#DIR = directory of script
4+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
5+
6+
rm $DIR/*.war
7+
rm $DIR/*.jar
8+
9+
ls
10+
11+
M2_REPO=~/.m2/repository
12+
VERSION=0.0.1
13+
14+
BINARY_JAR=$DIR/../snowglobe/server/snowglobe-server-exe/target/snowglobe-server-exe-$VERSION-jar-with-dependencies.jar
15+
16+
echo Directory = $DIR
17+
echo Binary = $BINARY_JAR
18+
19+
cp $BINARY_JAR $DIR/snowglobe.jar
20+
21+
# --> docker build -f Dockerfile -t snowglobe .

0 commit comments

Comments
 (0)