You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by bt...@apache.org on 2021/06/05 03:04:30 UTC
[james-project] 03/11: JAMES-3261 Package the Cassandra server
docker image with JIB
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 4015b6d9c84891fe4f7fb61c47ae7bc2d89e6649
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Sat May 29 13:38:47 2021 +0700
JAMES-3261 Package the Cassandra server docker image with JIB
---
dockerfiles/run/guice/cassandra/Dockerfile | 48 --------
.../run/guice/cassandra/destination/run_james.sh | 9 --
server/container/guice/cassandra-guice/README.adoc | 43 ++++++-
server/container/guice/cassandra-guice/pom.xml | 123 +++++++++++++++++++++
.../src/main}/extensions-jars/README.md | 2 +-
.../cassandra-guice/src/main}/glowroot/admin.json | 0
.../src/main}/glowroot/plugins/blobstore.json | 0
.../src/main}/glowroot/plugins/imap.json | 0
.../src/main}/glowroot/plugins/jmap.json | 2 +-
.../main}/glowroot/plugins/mailboxListener.json | 0
.../src/main}/glowroot/plugins/smtp.json | 0
.../src/main}/glowroot/plugins/spooler.json | 4 +-
.../src/main}/glowroot/plugins/task.json | 0
.../cassandra-guice/src/main/scripts/james-cli | 3 +
14 files changed, 172 insertions(+), 62 deletions(-)
diff --git a/dockerfiles/run/guice/cassandra/Dockerfile b/dockerfiles/run/guice/cassandra/Dockerfile
deleted file mode 100644
index c478642..0000000
--- a/dockerfiles/run/guice/cassandra/Dockerfile
+++ /dev/null
@@ -1,48 +0,0 @@
-# Run James
-#
-# VERSION 1.0
-
-FROM adoptopenjdk:11-jre-hotspot
-
-# Ports that are used
-#
-# 25 SMTP without authentication
-# 110 POP3
-# 143 IMAP with startTLS enabled
-# 465 SMTP with authentication and socketTLS enabled
-# 587 SMTP with authentication and startTLS enabled
-# 993 IMAP with socketTLS enabled
-# 8000 Web Admin interface (unsecured: expose at your own risks)
-
-EXPOSE 25 110 143 465 587 993 4000 8000
-
-WORKDIR /root
-RUN apt-get update && apt-get install -y unzip
-
-# Get data we need to run James : build results and configuration
-ADD destination/james-server-cassandra-guice.zip /root
-RUN unzip james-server-cassandra-guice.zip && \
- cp -r /root/james-server-cassandra-guice/* /root && \
- rm james-server-cassandra-guice.zip && \
- rm -r james-server-cassandra-guice
-ADD destination/james-server-cli.jar /root/james-cli.jar
-ADD destination/james-server-cli.lib /root/james-server-cli.lib
-ADD destination/glowroot/plugins /root/glowroot/plugins
-ADD destination/glowroot/glowroot.jar /root/glowroot/glowroot.jar
-ADD destination/glowroot/lib/glowroot-embedded-collector.jar /root/glowroot/lib/glowroot-embedded-collector.jar
-ADD destination/glowroot/lib/glowroot-logging-logstash.jar /root/glowroot/lib/glowroot-logging-logstash.jar
-ADD destination/glowroot/admin.json /root/glowroot/admin.json
-ADD destination/run_james.sh /root/run_james.sh
-
-# Data for ActiveMQ mailQueue
-VOLUME /root/var
-VOLUME /logs
-VOLUME /root/conf
-VOLUME /root/glowroot/plugins
-VOLUME /root/glowroot/data
-
-ENV PATH="$PATH:/root/glowroot/lib" \
- JVM_OPTIONS="" \
- GLOWROOT_ACTIVATED="false"
-
-ENTRYPOINT ./run_james.sh
diff --git a/dockerfiles/run/guice/cassandra/destination/run_james.sh b/dockerfiles/run/guice/cassandra/destination/run_james.sh
deleted file mode 100755
index 301fd99..0000000
--- a/dockerfiles/run/guice/cassandra/destination/run_james.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/usr/bin/env bash
-if [ "$GLOWROOT_ACTIVATED" == "true" ]; then
- GLOWROOT_OPTIONS=-javaagent:/root/glowroot/glowroot.jar
-fi
-
-java -Dworking.directory=. \
- $GLOWROOT_OPTIONS \
- $JVM_OPTIONS \
- -Dlogback.configurationFile=conf/logback.xml -jar james-server-cassandra-guice.jar
\ No newline at end of file
diff --git a/server/container/guice/cassandra-guice/README.adoc b/server/container/guice/cassandra-guice/README.adoc
index c4530e3..840728c 100644
--- a/server/container/guice/cassandra-guice/README.adoc
+++ b/server/container/guice/cassandra-guice/README.adoc
@@ -46,4 +46,45 @@ Once everything is set up, you just have to run the jar with:
$ java -Dworking.directory=. -Dlogback.configurationFile=conf/logback.xml -jar james-server-cassandra-guice.jar
----
-Note that binding ports below 1024 requires administrative rights.
\ No newline at end of file
+Note that binding ports below 1024 requires administrative rights.
+
+== Docker distribution
+
+To import the image locally:
+
+[source]
+----
+docker image load -i target/jib-image.tar
+----
+
+Then run it:
+
+[source]
+----
+docker run apache/james:cassandra-latest
+----
+
+Use the [JAVA_TOOL_OPTIONS environment option](https://github.com/GoogleContainerTools/jib/blob/master/docs/faq.md#jvm-flags)
+to pass extra JVM flags. For instance:
+
+[source]
+----
+docker run -e "JAVA_TOOL_OPTIONS=-Xmx500m -Xms500m" apache/james:cassandra-latest
+----
+
+[Glowroot APM](https://glowroot.org/) is packaged as part of the docker distribution to easily enable valuable performances insights.
+Disabled by default, its java agent can easily be enabled:
+
+
+[source]
+----
+docker run -e "JAVA_TOOL_OPTIONS=-javaagent:/root/glowroot.jar" apache/james:cassandra-latest
+----
+
+The [CLI](https://james.apache.org/server/manage-cli.html) can easily be used:
+
+
+[source]
+----
+docker exec CONTAINER-ID james-cli ListDomains
+----
\ No newline at end of file
diff --git a/server/container/guice/cassandra-guice/pom.xml b/server/container/guice/cassandra-guice/pom.xml
index 23ae773..f3d7d4a 100644
--- a/server/container/guice/cassandra-guice/pom.xml
+++ b/server/container/guice/cassandra-guice/pom.xml
@@ -88,6 +88,11 @@
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
+ <artifactId>james-server-cli</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
<artifactId>james-server-guice-cassandra</artifactId>
</dependency>
<dependency>
@@ -274,6 +279,124 @@
<build>
<plugins>
<plugin>
+ <groupId>com.googlecode.maven-download-plugin</groupId>
+ <artifactId>download-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>install-glowroot</id>
+ <goals>
+ <goal>wget</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <url>https://github.com/glowroot/glowroot/releases/download/v0.13.4/glowroot-0.13.4-dist.zip</url>
+ <unpack>true</unpack>
+ <outputDirectory>${project.build.directory}</outputDirectory>
+ <md5>93d472281a67ab8404033a88280c23c9</md5>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-glowroot-resources</id>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <outputDirectory>${basedir}/target/glowroot</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/glowroot</directory>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>com.google.cloud.tools</groupId>
+ <artifactId>jib-maven-plugin</artifactId>
+ <configuration>
+ <from>
+ <image>adoptopenjdk:11-jdk-hotspot</image>
+ </from>
+ <to>
+ <image>apache/james</image>
+ <tags>
+ <tag>cassandra-latest</tag>
+ </tags>
+ </to>
+ <container>
+ <mainClass>org.apache.james.CassandraJamesServerMain</mainClass>
+ <ports>
+ <port>80</port> <!-- JMAP -->
+ <port>143</port> <!-- IMAP -->
+ <port>993</port> <!-- IMAPS -->
+ <port>25</port> <!-- SMTP -->
+ <port>465</port> <!-- SMTP + STARTTLS -->
+ <port>587</port> <!-- SMTPS -->
+ <port>4000</port> <!-- GLOWROOT, if activated -->
+ <port>8000</port> <!-- WEBADMIN -->
+ </ports>
+ <appRoot>/root</appRoot>
+ <jvmFlags>
+ <jvmFlag>-Dlogback.configurationFile=/root/conf/logback.xml</jvmFlag>
+ <jvmFlag>-Dworking.directory=/root/</jvmFlag>
+ </jvmFlags>
+ <creationTime>USE_CURRENT_TIMESTAMP</creationTime>
+
+ <volumes>
+ <volume>/logs</volume>
+ <volume>/root/conf</volume>
+ <!-- Data for ActiveMQ mailQueue -->
+ <volume>/root/var</volume>
+ <volume>/root/glowroot/plugins</volume>
+ <volume>/root/glowroot/data</volume>
+ </volumes>
+ </container>
+ <extraDirectories>
+ <paths>
+ <path>
+ <from>sample-configuration</from>
+ <into>/root/conf</into>
+ </path>
+ <path>
+ <from>src/main/scripts</from>
+ <into>/usr/bin</into>
+ </path>
+ <path>
+ <from>target/glowroot</from>
+ <into>/root</into>
+ </path>
+ <path>
+ <from>src/main/extensions-jars</from>
+ <into>/root/extensions-jars</into>
+ </path>
+ </paths>
+ <permissions>
+ <permission>
+ <file>/usr/bin/james-cli</file>
+ <mode>755</mode> <!-- Read/write/execute for owner, read/execute for group/other -->
+ </permission>
+ </permissions>
+ </extraDirectories>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>buildTar</goal>
+ </goals>
+ <phase>package</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
diff --git a/dockerfiles/run/guice/cassandra/destination/extensions-jars/README.md b/server/container/guice/cassandra-guice/src/main/extensions-jars/README.md
similarity index 74%
rename from dockerfiles/run/guice/cassandra/destination/extensions-jars/README.md
rename to server/container/guice/cassandra-guice/src/main/extensions-jars/README.md
index 2cea759..dab5c40 100644
--- a/dockerfiles/run/guice/cassandra/destination/extensions-jars/README.md
+++ b/server/container/guice/cassandra-guice/src/main/extensions-jars/README.md
@@ -2,4 +2,4 @@
The jar in this folder will be added to JAMES classpath when mounted under /root/extensions-jars inside the running container.
-You can use it to add you customs Mailets/Matchers.
+You can use it to add your custom Mailets/Matchers.
diff --git a/dockerfiles/run/guice/cassandra/destination/glowroot/admin.json b/server/container/guice/cassandra-guice/src/main/glowroot/admin.json
similarity index 100%
rename from dockerfiles/run/guice/cassandra/destination/glowroot/admin.json
rename to server/container/guice/cassandra-guice/src/main/glowroot/admin.json
diff --git a/dockerfiles/run/guice/cassandra/destination/glowroot/plugins/blobstore.json b/server/container/guice/cassandra-guice/src/main/glowroot/plugins/blobstore.json
similarity index 100%
rename from dockerfiles/run/guice/cassandra/destination/glowroot/plugins/blobstore.json
rename to server/container/guice/cassandra-guice/src/main/glowroot/plugins/blobstore.json
diff --git a/dockerfiles/run/guice/cassandra/destination/glowroot/plugins/imap.json b/server/container/guice/cassandra-guice/src/main/glowroot/plugins/imap.json
similarity index 100%
rename from dockerfiles/run/guice/cassandra/destination/glowroot/plugins/imap.json
rename to server/container/guice/cassandra-guice/src/main/glowroot/plugins/imap.json
diff --git a/dockerfiles/run/guice/cassandra/destination/glowroot/plugins/jmap.json b/server/container/guice/cassandra-guice/src/main/glowroot/plugins/jmap.json
similarity index 88%
rename from dockerfiles/run/guice/cassandra/destination/glowroot/plugins/jmap.json
rename to server/container/guice/cassandra-guice/src/main/glowroot/plugins/jmap.json
index 9afce4b..b5a0ea1 100644
--- a/dockerfiles/run/guice/cassandra/destination/glowroot/plugins/jmap.json
+++ b/server/container/guice/cassandra-guice/src/main/glowroot/plugins/jmap.json
@@ -11,7 +11,7 @@
"captureKind": "transaction",
"transactionType": "JMAP",
"transactionNameTemplate": "JMAP method : {{this.class.name}}",
- "alreadyInTransactionBehavior": "capture-trace-entry",
+ "alreadyInTransactionBehavior": "capture-new-transaction",
"traceEntryMessageTemplate": "{{this.class.name}}.{{methodName}}",
"timerName": "jmapMethod"
}
diff --git a/dockerfiles/run/guice/cassandra/destination/glowroot/plugins/mailboxListener.json b/server/container/guice/cassandra-guice/src/main/glowroot/plugins/mailboxListener.json
similarity index 100%
rename from dockerfiles/run/guice/cassandra/destination/glowroot/plugins/mailboxListener.json
rename to server/container/guice/cassandra-guice/src/main/glowroot/plugins/mailboxListener.json
diff --git a/dockerfiles/run/guice/cassandra/destination/glowroot/plugins/smtp.json b/server/container/guice/cassandra-guice/src/main/glowroot/plugins/smtp.json
similarity index 100%
rename from dockerfiles/run/guice/cassandra/destination/glowroot/plugins/smtp.json
rename to server/container/guice/cassandra-guice/src/main/glowroot/plugins/smtp.json
diff --git a/dockerfiles/run/guice/cassandra/destination/glowroot/plugins/spooler.json b/server/container/guice/cassandra-guice/src/main/glowroot/plugins/spooler.json
similarity index 91%
rename from dockerfiles/run/guice/cassandra/destination/glowroot/plugins/spooler.json
rename to server/container/guice/cassandra-guice/src/main/glowroot/plugins/spooler.json
index fd7732d..5937ca5 100644
--- a/dockerfiles/run/guice/cassandra/destination/glowroot/plugins/spooler.json
+++ b/server/container/guice/cassandra-guice/src/main/glowroot/plugins/spooler.json
@@ -24,7 +24,7 @@
"captureKind": "transaction",
"transactionType": "Mailet",
"transactionNameTemplate": "Mailet : {{this.class.name}}",
- "alreadyInTransactionBehavior": "capture-trace-entry",
+ "alreadyInTransactionBehavior": "capture-new-transaction",
"traceEntryMessageTemplate": "{{this.class.name}}.{{methodName}}",
"timerName": "mailet"
},
@@ -37,7 +37,7 @@
"captureKind": "transaction",
"transactionType": "Matcher",
"transactionNameTemplate": "Mailet processor : {{this.class.name}}",
- "alreadyInTransactionBehavior": "capture-trace-entry",
+ "alreadyInTransactionBehavior": "capture-new-transaction",
"traceEntryMessageTemplate": "{{this.class.name}}.{{methodName}}",
"timerName": "matcher"
}
diff --git a/dockerfiles/run/guice/cassandra/destination/glowroot/plugins/task.json b/server/container/guice/cassandra-guice/src/main/glowroot/plugins/task.json
similarity index 100%
rename from dockerfiles/run/guice/cassandra/destination/glowroot/plugins/task.json
rename to server/container/guice/cassandra-guice/src/main/glowroot/plugins/task.json
diff --git a/server/container/guice/cassandra-guice/src/main/scripts/james-cli b/server/container/guice/cassandra-guice/src/main/scripts/james-cli
new file mode 100755
index 0000000..19a73b6
--- /dev/null
+++ b/server/container/guice/cassandra-guice/src/main/scripts/james-cli
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+java -cp /root/resources:/root/classes:/root/libs/* org.apache.james.cli.ServerCmd "$@"
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org