[AIRAVATA-2054][WIP] create docker images for airavata deployment components

1. Introduce Docker images for each deployment component of airavata.
2. Deployed those in docker hub repository (scigap),
        try: docker search scigap
3. Use exhibitor docker images intead of zookeeper which is a much better
compare to using vanilla zookeeper.
http://techblog.netflix.com/2012/04/introducing-exhibitor-supervisor-system.html

4. IMHO we should never use docker images from public repository, Everything
we should create our own docker images from public images and test with those 
and
move to production.

5. Added a simple script(airavata/build.sh) to build airavata docker components.

      ./build.sh [component-name] - This will build a docker image for given 
component.

This is a temporary script we can use until AIRAVATA-2056 which integrates 
docker push with some CI tool like jenkins.


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/8474763b
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/8474763b
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/8474763b

Branch: refs/heads/lahiru/AIRAVATA-2065
Commit: 8474763b16288a571c787cb0d52c40afea62df48
Parents: 875fc27
Author: Lahiru Ginnaliya Gamathige <lah...@apache.org>
Authored: Sun Aug 21 00:49:58 2016 -0700
Committer: Lahiru Ginnaliya Gamathige <lah...@apache.org>
Committed: Mon Sep 12 23:27:26 2016 -0700

----------------------------------------------------------------------
 build.sh                                     | 65 +++++++++++++++
 deploy/images/airavata/Dockerfile            | 16 ++++
 deploy/images/exhibitor/Dockerfile           |  6 ++
 deploy/images/exhibitor/exhibitor.properties | 14 ++++
 deploy/images/java/Dockerfile                | 32 ++++++++
 deploy/images/rabbitmq/Dockerfile            |  3 +
 deploy/images/rabbitmq/rabbitmq.config       |  5 ++
 deploy/systemd/aws-metadata.service          | 19 +++++
 deploy/systemd/consul-download.service       | 11 +++
 deploy/systemd/consul.service                |  8 ++
 deploy/systemd/zookeeper.service             | 14 ++++
 pom.xml                                      | 97 ++++++++++++++++++++++-
 12 files changed, 289 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/8474763b/build.sh
----------------------------------------------------------------------
diff --git a/build.sh b/build.sh
new file mode 100755
index 0000000..da3c5b7
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,65 @@
+#!/usr/bin/env bash
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+
+# todo Add environment specific docker image creation and create docker image 
per component (api-server, orchestrator, gfac etc)
+
+echo $MAVEN_HOME
+echo $PATH
+
+cd $WORKSPACE/airavata-head/
+
+/home/jenkins/tools/maven/apache-maven-3.3.9/bin/mvn  clean install 
-Dmaven.test.skip=true
+if [ -d "docker-build" ]; then
+    printf '%s\n' "Removing old docker-build directory"
+    rm -rf docker-build
+fi
+
+mkdir docker-build
+cp modules/distribution/target/apache-airavata-server*.zip docker-build
+
+unzip docker-build/apache-airavata-server*.zip -d docker-build/airavata
+rm docker-build/apache-airavata-server*.zip
+
+cp deploy/images/airavata/Dockerfile docker-build/airavata/*/
+
+cd docker-build/airavata/*/
+
+# disable embedded zookeeper configuration
+echo  embedded.zk=false >> bin/airavata-server.properties
+
+component_name="all"
+if [ $# -gt 0 ]
+  then
+      docker build --build-arg COMPONENT=${component_name} -t 
airavata-${component_name} .
+      # docker push scigap/airavata-${component_name}
+fi
+
+docker build --build-arg COMPONENT=apiserver -t 
scigap/${environment}-airavata-apiserver .
+# docker push scigap/airavata-apiserver
+
+docker build --build-arg COMPONENT=gfac -t scigap/${environment}-airavata-gfac 
.
+# docker push scigap/airavata-gfac
+
+docker build --build-arg COMPONENT=orchestrator -t 
scigap/${environment}-airavata-orchestrator .
+# docker push scigap/airavata-orchestrator
+
+docker build --build-arg COMPONENT=credentialstore -t 
scigap/${environment}-airavata-credentialstore .
+# docker push scigap/airavata-credentialstore
+
+

http://git-wip-us.apache.org/repos/asf/airavata/blob/8474763b/deploy/images/airavata/Dockerfile
----------------------------------------------------------------------
diff --git a/deploy/images/airavata/Dockerfile 
b/deploy/images/airavata/Dockerfile
new file mode 100644
index 0000000..6b051ae
--- /dev/null
+++ b/deploy/images/airavata/Dockerfile
@@ -0,0 +1,16 @@
+#
+# To build from the airavata root dir until jenkins script or maven build to 
create docker image
+#
+FROM scigap/java:8
+ARG COMPONENT="all"
+
+ENV COMPONENT=$COMPONENT
+
+RUN mkdir /airavata
+COPY . /airavata
+
+WORKDIR /airavata
+
+RUN chmod +x ./bin/airavata-server-start.sh
+
+ENTRYPOINT ./bin/airavata-server-start.sh $COMPONENT

http://git-wip-us.apache.org/repos/asf/airavata/blob/8474763b/deploy/images/exhibitor/Dockerfile
----------------------------------------------------------------------
diff --git a/deploy/images/exhibitor/Dockerfile 
b/deploy/images/exhibitor/Dockerfile
new file mode 100644
index 0000000..feb7674
--- /dev/null
+++ b/deploy/images/exhibitor/Dockerfile
@@ -0,0 +1,6 @@
+FROM netflixoss/exhibitor:1.5.2
+
+ADD exhibitor.properties /exhibitor/exhibitor.properties
+
+ENTRYPOINT ["java", "-jar", "exhibitor-1.0-jar-with-dependencies.jar", "-c", 
"file", "--defaultconfig", "/exhibitor/exhibitor.properties"]
+

http://git-wip-us.apache.org/repos/asf/airavata/blob/8474763b/deploy/images/exhibitor/exhibitor.properties
----------------------------------------------------------------------
diff --git a/deploy/images/exhibitor/exhibitor.properties 
b/deploy/images/exhibitor/exhibitor.properties
new file mode 100644
index 0000000..b099e60
--- /dev/null
+++ b/deploy/images/exhibitor/exhibitor.properties
@@ -0,0 +1,14 @@
+java-environment=export JAVA_OPTS\="-Xms1000m -Xmx1000m"
+zookeeper-data-directory=/zookeeper/data
+cleanup-period-ms=200000
+zookeeper-install-directory=/zookeeper
+check-ms=2000
+client-port=2181
+cleanup-max-files=10
+connect-port=2888
+log4j-properties=
+observer-threshold=4
+election-port=3888
+zoo-cfg-extra=syncLimit\=5&tickTime\=2000&initLimit\=10
+auto-manage-instances-settling-period-ms=10000
+auto-manage-instances=1
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/8474763b/deploy/images/java/Dockerfile
----------------------------------------------------------------------
diff --git a/deploy/images/java/Dockerfile b/deploy/images/java/Dockerfile
new file mode 100644
index 0000000..e3a5dd6
--- /dev/null
+++ b/deploy/images/java/Dockerfile
@@ -0,0 +1,32 @@
+FROM debian:stable
+
+ENV JAVA_MAJOR 8
+ENV JAVA_MINOR 102
+ENV JAVA_BUILD 14
+
+ENV JAVA_HOME /opt/jdk
+ENV PATH ${PATH}:${JAVA_HOME}/bin
+
+RUN apt-get update \
+  && apt-get install --assume-yes curl ca-certificates \
+  && apt-get clean \
+  && rm -rf /var/lib/apt/lists/* /var/log/apt/*
+
+RUN curl -jksSLH "Cookie: oraclelicense=accept-securebackup-cookie" \
+  
http://download.oracle.com/otn-pub/java/jdk/${JAVA_MAJOR}u${JAVA_MINOR}-b${JAVA_BUILD}/server-jre-${JAVA_MAJOR}u${JAVA_MINOR}-linux-x64.tar.gz
 \
+  | tar -zxvf - -C /opt && \
+  ln -s /opt/jdk1.${JAVA_MAJOR}.0_${JAVA_MINOR} /opt/jdk && \
+  rm -rf /opt/jdk/man/* \
+         /opt/jdk/jre/bin/jjs \
+         /opt/jdk/jre/bin/keytool \
+         /opt/jdk/jre/bin/orbd \
+         /opt/jdk/jre/bin/pack200 \
+         /opt/jdk/jre/bin/policytool \
+         /opt/jdk/jre/bin/rmid \
+         /opt/jdk/jre/bin/rmiregistry \
+         /opt/jdk/jre/bin/servertool \
+         /opt/jdk/jre/bin/tnameserv \
+         /opt/jdk/jre/bin/unpack200 \
+         /opt/jdk/jre/lib/ext/nashorn.jar \
+         /opt/jdk/jre/lib/oblique-fonts
+

http://git-wip-us.apache.org/repos/asf/airavata/blob/8474763b/deploy/images/rabbitmq/Dockerfile
----------------------------------------------------------------------
diff --git a/deploy/images/rabbitmq/Dockerfile 
b/deploy/images/rabbitmq/Dockerfile
new file mode 100644
index 0000000..8dae7d4
--- /dev/null
+++ b/deploy/images/rabbitmq/Dockerfile
@@ -0,0 +1,3 @@
+FROM rabbitmq:3-management
+
+COPY rabbitmq.config /etc/rabbitmq/
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/8474763b/deploy/images/rabbitmq/rabbitmq.config
----------------------------------------------------------------------
diff --git a/deploy/images/rabbitmq/rabbitmq.config 
b/deploy/images/rabbitmq/rabbitmq.config
new file mode 100644
index 0000000..a3be93c
--- /dev/null
+++ b/deploy/images/rabbitmq/rabbitmq.config
@@ -0,0 +1,5 @@
+[
+  {rabbit, [
+    {tcp_listeners, [{"127.0.0.1", 5672}]}
+  ]}
+].

http://git-wip-us.apache.org/repos/asf/airavata/blob/8474763b/deploy/systemd/aws-metadata.service
----------------------------------------------------------------------
diff --git a/deploy/systemd/aws-metadata.service 
b/deploy/systemd/aws-metadata.service
new file mode 100644
index 0000000..ac8ef57
--- /dev/null
+++ b/deploy/systemd/aws-metadata.service
@@ -0,0 +1,19 @@
+[Unit]
+Description=Loads AWS Metadata
+After=network-online.target
+Wants=network-online.target
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+EnvironmentFile=/etc/environment
+ExecStart=-/usr/bin/bash -c "systemctl set-environment AWS_REGION=$(curl -s 
http://[ip]/latest/meta-data/placement/availability-zone | sed -e 's/[a-z]$//')"
+ExecStart=-/usr/bin/bash -c "systemctl set-environment AWS_HOSTNAME=$(curl -s 
http://[ip]/latest/meta-data/local-hostname)"
+ExecStart=-/usr/bin/bash -c "systemctl set-environment AWS_ZONE=$(curl -s 
http://[ip]/latest/meta-data/placement/availability-zone)"
+ExecStart=-/usr/bin/bash -c "systemctl set-environment 
AWS_INSTANCE_TYPE=$(curl -s http://[ip]/latest/meta-data/instance-type)"
+ExecStart=-/usr/bin/bash -c "systemctl set-environment 
COREOS_PRIVATE_IPV4=${COREOS_PRIVATE_IPV4}"
+ExecStart=-/usr/bin/bash -c "systemctl set-environment 
COREOS_PUBLIC_IPV4=${COREOS_PUBLIC_IPV4}"
+ExecStart=-/usr/bin/bash -c "systemctl set-environment COREOS_FREE_DISK=$(df 
-l | awk '{ s+=$4 } END {print s}')"
+ExecStart=-/usr/bin/bash -c "systemctl set-environment COREOS_TOTAL_MEM=$(cat 
/proc/meminfo | grep MemTotal | awk '{print $2/1024+2048}')"
+ExecStart=-/usr/bin/bash -c "systemctl set-environment COREOS_TOTAL_CPUS=$(cat 
/proc/cpuinfo | grep processor | wc -l | awk  '{print $s*2}')"
+[Install]
+WantedBy=multi-user.target
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/8474763b/deploy/systemd/consul-download.service
----------------------------------------------------------------------
diff --git a/deploy/systemd/consul-download.service 
b/deploy/systemd/consul-download.service
new file mode 100644
index 0000000..c430bb8
--- /dev/null
+++ b/deploy/systemd/consul-download.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Downloads Consul
+After=network-online.target
+Wants=network-online.target
+ConditionPathExists=!/opt/consul/0.6.3/consul
+[Service]
+Type=oneshot
+Environment=CONSUL_VERSION=0.6.3
+ExecStartPre=/usr/bin/bash -c 'wget --progress=dot -e dotbytes=10M 
https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip
 -O /tmp/consul.zip'
+ExecStartPre=/usr/bin/bash -c "mkdir -p /opt/bin /opt/consul/${CONSUL_VERSION}"
+ExecStart=/usr/bin/bash -c "/usr/bin/unzip -o /tmp/consul.zip -d 
/opt/consul/${CONSUL_VERSION} && ln -sf /opt/consul/${CONSUL_VERSION}/consul 
/opt/bin/consul"

http://git-wip-us.apache.org/repos/asf/airavata/blob/8474763b/deploy/systemd/consul.service
----------------------------------------------------------------------
diff --git a/deploy/systemd/consul.service b/deploy/systemd/consul.service
new file mode 100644
index 0000000..4a887f6
--- /dev/null
+++ b/deploy/systemd/consul.service
@@ -0,0 +1,8 @@
+[Unit]
+Description=Consul Service Discovery and DNS
+After=consul-download.service aws-metadata.service
+Requires=consul-download.service aws-metadata.service
+[Service]
+EnvironmentFile=/etc/environment
+Restart=on-failure
+ExecStart=/opt/bin/consul agent -server -data-dir /var/lib/consul -bind 
${COREOS_PRIVATE_IPV4} -dc ${AWS_REGION} -config-file /etc/consul/config.json 
-ui -client 0.0.0.0

http://git-wip-us.apache.org/repos/asf/airavata/blob/8474763b/deploy/systemd/zookeeper.service
----------------------------------------------------------------------
diff --git a/deploy/systemd/zookeeper.service b/deploy/systemd/zookeeper.service
new file mode 100644
index 0000000..38e631b
--- /dev/null
+++ b/deploy/systemd/zookeeper.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Exhibitor and Zookeeper
+After=docker.service
+Requires=docker.service
+[Service]
+EnvironmentFile=/etc/environment
+TimeoutStartSec=60
+Restart=on-failure
+ExecStartPre=-/usr/bin/docker rm -f zookeeper
+ExecStartPre=-/usr/bin/docker pull scigap/exhibitor
+    ExecStart=/usr/bin/docker run --net=host --name zookeeper -v 
/var/lib/zookeeper/data:/zookeeper/data scigap/exhibitor --hostname 
${COREOS_PRIVATE_IPV4} --port 8081
+ExecStop=/usr/bin/docker stop zookeeper
+[Install]
+WantedBy=multi-user.target
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/8474763b/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 3988fd0..1589171 100644
--- a/pom.xml
+++ b/pom.xml
@@ -570,8 +570,103 @@
                                <!--<module>modules/workflow</module>-->
                                <!--<module>modules/xbaya-gui</module>-->
                                <module>modules/distribution</module>
-            </modules>
+                       </modules>
                </profile>
+        <profile>
+            <id>jenkins</id>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-remote-resources-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <goals>
+                                    <goal>process</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
+                        <artifactId>maven-resources-plugin</artifactId>
+                        <version>2.5</version>
+                        <executions>
+                            <execution>
+                                <id>copy-resources</id>
+                                <!-- here the phase you need -->
+                                <phase>validate</phase>
+                                <goals>
+                                    <goal>copy-resources</goal>
+                                </goals>
+                                <configuration>
+                                    
<outputDirectory>${basedir}/target/classes/META-INF</outputDirectory>
+                                    <resources>
+                                        <resource>
+                                            
<directory>${basedir}/src/main/assembly/dist</directory>
+                                            <filtering>true</filtering>
+                                        </resource>
+                                    </resources>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-compiler-plugin</artifactId>
+                        <version>3.1</version>
+                        <configuration>
+                            <source>1.8</source>
+                            <target>1.8</target>
+                        </configuration>
+                    </plugin>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-surefire-plugin</artifactId>
+                        <version>${surefire.version}</version>
+                        <configuration>
+                            <failIfNoTests>false</failIfNoTests>
+                            <skipTests>${skipTests}</skipTests>
+                            
<workingDirectory>${project.build.testOutputDirectory}</workingDirectory>
+                            <!-- making sure that the sure-fire plugin doesn't 
run the integration
+                                tests -->
+                            <!-- Integration tests are run using the fail-safe 
plugin in the module
+                                pom -->
+                            <excludes>
+                                <exclude>**/IT.java</exclude>
+                                <exclude>**/*TestWithMyProxyAuth.java</exclude>
+                                <exclude>**/*TestWithSSHAuth.java</exclude>
+                                <exclude>**/*TestWithEC2Auth.java</exclude>
+                            </excludes>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+            <modules>
+                <module>modules/configuration</module>
+                <module>airavata-api</module>
+                <module>modules/commons</module>
+                <module>modules/messaging</module>
+                <module>modules/gfac</module>
+                <module>modules/registry</module>
+                <module>modules/security</module>
+                <module>modules/credential-store</module>
+                <module>modules/orchestrator</module>
+                <module>modules/monitoring</module>
+                <module>modules/user-profile</module>
+                <!--<module>modules/cloud</module>-->
+                <module>modules/server</module>
+                <module>modules/workflow</module>
+                <module>modules/test-suite</module>
+                <!-- Deprecated Modules-->
+                <!--<module>modules/integration-tests</module>-->
+                <!--<module>modules/workflow-model</module>-->
+                <!--<module>modules/workflow</module>-->
+                <!--<module>modules/xbaya-gui</module>-->
+            </modules>
+        </profile>
                <profile>
                        <id>pedantic</id>
                        <build>

Reply via email to