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:32 UTC
[james-project] 05/11: JAMES-3261 Package the JPA SMTP 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 648fd34090e45047b3c66138fd1526c42f2cbbe1
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Sat May 29 14:08:38 2021 +0700
JAMES-3261 Package the JPA SMTP server docker image with JIB
---
dockerfiles/run/guice/jpa-smtp/Dockerfile | 48 --------
.../run/guice/jpa-smtp/destination/run_james.sh | 11 --
server/container/guice/jpa-smtp/README.adoc | 42 ++++++-
server/container/guice/jpa-smtp/pom.xml | 125 ++++++++++++++++++++-
.../jpa-smtp/src/main}/extensions-jars/README.md | 2 +-
.../guice/jpa-smtp/src/main}/glowroot/admin.json | 0
.../jpa-smtp/src/main/glowroot/plugins/imap.json | 19 ++++
.../jpa-smtp/src/main/glowroot/plugins/jmap.json | 19 ++++
.../src/main/glowroot/plugins/mailboxListener.json | 19 ++++
.../jpa-smtp/src/main}/glowroot/plugins/smtp.json | 0
.../src/main}/glowroot/plugins/spooler.json | 0
.../jpa-smtp/src/main}/glowroot/plugins/task.json | 0
.../guice/jpa-smtp/src/main/scripts/james-cli | 3 +
13 files changed, 226 insertions(+), 62 deletions(-)
diff --git a/dockerfiles/run/guice/jpa-smtp/Dockerfile b/dockerfiles/run/guice/jpa-smtp/Dockerfile
deleted file mode 100644
index 1f2ce41..0000000
--- a/dockerfiles/run/guice/jpa-smtp/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
-# 143 IMAP with startTLS enabled
-# 465 SMTP with authentication and socketTLS enabled
-# 587 SMTP with authentication and startTLS enabled
-# 8000 Web Admin interface (unsecured: expose at your own risks)
-
-EXPOSE 25 143 465 587 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-jpa-smtp-guice.zip /root
-RUN unzip james-server-jpa-smtp-guice.zip && \
- cp -r /root/james-server-jpa-smtp-guice/* /root && \
- rm james-server-jpa-smtp-guice.zip && \
- rm -r james-server-jpa-smtp-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
-
-VOLUME /logs
-VOLUME /root/conf
-VOLUME /root/glowroot/plugins
-VOLUME /root/glowroot/data
-# Data for ActiveMQ mailQueue
-VOLUME /root/var
-# Data for derby database
-VOLUME /var/store
-
-ENV PATH="$PATH:/root/glowroot/lib" \
- JVM_OPTIONS="" \
- GLOWROOT_ACTIVATED="false"
-
-ENTRYPOINT ./run_james.sh
diff --git a/dockerfiles/run/guice/jpa-smtp/destination/run_james.sh b/dockerfiles/run/guice/jpa-smtp/destination/run_james.sh
deleted file mode 100755
index 4e518fe..0000000
--- a/dockerfiles/run/guice/jpa-smtp/destination/run_james.sh
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/usr/bin/env bash
-if [ "$GLOWROOT_ACTIVATED" == "true" ]; then
- GLOWROOT_OPTIONS=-javaagent:/root/glowroot/glowroot.jar
-fi
-
-
-java -javaagent:james-server-jpa-smtp-guice.lib/openjpa-3.1.2.jar \
- -Dworking.directory=. \
- $GLOWROOT_OPTIONS \
- $JVM_OPTIONS \
- -Dlogback.configurationFile=conf/logback.xml -jar james-server-jpa-smtp-guice.jar
\ No newline at end of file
diff --git a/server/container/guice/jpa-smtp/README.adoc b/server/container/guice/jpa-smtp/README.adoc
index bd51c8b..c3bc6d5 100644
--- a/server/container/guice/jpa-smtp/README.adoc
+++ b/server/container/guice/jpa-smtp/README.adoc
@@ -30,4 +30,44 @@ Once everything is set up, you just have to run the jar with:
$ java -javaagent:james-server-jpa-smtp-guice.lib/openjpa-3.1.2.jar -Dworking.directory=. -Dlogback.configurationFile=conf/logback.xml -jar james-server-jpa-smtp-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:jpa-smtp-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:jpa-smtp-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:jpa-smtp-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/jpa-smtp/pom.xml b/server/container/guice/jpa-smtp/pom.xml
index 52e47d0..145f260 100644
--- a/server/container/guice/jpa-smtp/pom.xml
+++ b/server/container/guice/jpa-smtp/pom.xml
@@ -48,6 +48,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-common</artifactId>
<type>test-jar</type>
<scope>test</scope>
@@ -103,7 +108,125 @@
</dependencies>
<build>
- <plugins>
+ <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>jpa-smtp-latest</tag>
+ </tags>
+ </to>
+ <container>
+ <mainClass>org.apache.james.JPAJamesServerMain</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>
+ <!-- Data for derby database -->
+ <volume>/var/store</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>
diff --git a/dockerfiles/run/guice/jpa-smtp/destination/extensions-jars/README.md b/server/container/guice/jpa-smtp/src/main/extensions-jars/README.md
similarity index 74%
rename from dockerfiles/run/guice/jpa-smtp/destination/extensions-jars/README.md
rename to server/container/guice/jpa-smtp/src/main/extensions-jars/README.md
index 00f9d15..dab5c40 100644
--- a/dockerfiles/run/guice/jpa-smtp/destination/extensions-jars/README.md
+++ b/server/container/guice/jpa-smtp/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 your customs Mailets/Matchers.
+You can use it to add your custom Mailets/Matchers.
diff --git a/dockerfiles/run/guice/jpa-smtp/destination/glowroot/admin.json b/server/container/guice/jpa-smtp/src/main/glowroot/admin.json
similarity index 100%
rename from dockerfiles/run/guice/jpa-smtp/destination/glowroot/admin.json
rename to server/container/guice/jpa-smtp/src/main/glowroot/admin.json
diff --git a/server/container/guice/jpa-smtp/src/main/glowroot/plugins/imap.json b/server/container/guice/jpa-smtp/src/main/glowroot/plugins/imap.json
new file mode 100644
index 0000000..d27904f
--- /dev/null
+++ b/server/container/guice/jpa-smtp/src/main/glowroot/plugins/imap.json
@@ -0,0 +1,19 @@
+{
+ "name": "IMAP Plugin",
+ "id": "imap",
+ "instrumentation": [
+ {
+ "className": "org.apache.james.imap.processor.base.AbstractChainedProcessor",
+ "methodName": "doProcess",
+ "methodParameterTypes": [
+ ".."
+ ],
+ "captureKind": "transaction",
+ "transactionType": "IMAP",
+ "transactionNameTemplate": "IMAP processor : {{this.class.name}}",
+ "alreadyInTransactionBehavior": "capture-trace-entry",
+ "traceEntryMessageTemplate": "{{this.class.name}}.{{methodName}}",
+ "timerName": "imapProcessor"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/server/container/guice/jpa-smtp/src/main/glowroot/plugins/jmap.json b/server/container/guice/jpa-smtp/src/main/glowroot/plugins/jmap.json
new file mode 100644
index 0000000..9afce4b
--- /dev/null
+++ b/server/container/guice/jpa-smtp/src/main/glowroot/plugins/jmap.json
@@ -0,0 +1,19 @@
+{
+ "name": "JMAP Plugin",
+ "id": "jmap",
+ "instrumentation": [
+ {
+ "className": "org.apache.james.jmap.draft.methods.Method",
+ "methodName": "processToStream",
+ "methodParameterTypes": [
+ ".."
+ ],
+ "captureKind": "transaction",
+ "transactionType": "JMAP",
+ "transactionNameTemplate": "JMAP method : {{this.class.name}}",
+ "alreadyInTransactionBehavior": "capture-trace-entry",
+ "traceEntryMessageTemplate": "{{this.class.name}}.{{methodName}}",
+ "timerName": "jmapMethod"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/server/container/guice/jpa-smtp/src/main/glowroot/plugins/mailboxListener.json b/server/container/guice/jpa-smtp/src/main/glowroot/plugins/mailboxListener.json
new file mode 100644
index 0000000..54a55ac
--- /dev/null
+++ b/server/container/guice/jpa-smtp/src/main/glowroot/plugins/mailboxListener.json
@@ -0,0 +1,19 @@
+{
+ "name": "MailboxListener Plugin",
+ "id": "mailboxListener",
+ "instrumentation": [
+ {
+ "className": "org.apache.james.mailbox.events.MailboxListener",
+ "methodName": "event",
+ "methodParameterTypes": [
+ ".."
+ ],
+ "captureKind": "transaction",
+ "transactionType": "MailboxListener",
+ "transactionNameTemplate": "MailboxListener : {{this.class.name}}",
+ "alreadyInTransactionBehavior": "capture-trace-entry",
+ "traceEntryMessageTemplate": "{{this.class.name}}.{{methodName}}",
+ "timerName": "mailboxListener"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/dockerfiles/run/guice/jpa-smtp/destination/glowroot/plugins/smtp.json b/server/container/guice/jpa-smtp/src/main/glowroot/plugins/smtp.json
similarity index 100%
rename from dockerfiles/run/guice/jpa-smtp/destination/glowroot/plugins/smtp.json
rename to server/container/guice/jpa-smtp/src/main/glowroot/plugins/smtp.json
diff --git a/dockerfiles/run/guice/jpa-smtp/destination/glowroot/plugins/spooler.json b/server/container/guice/jpa-smtp/src/main/glowroot/plugins/spooler.json
similarity index 100%
rename from dockerfiles/run/guice/jpa-smtp/destination/glowroot/plugins/spooler.json
rename to server/container/guice/jpa-smtp/src/main/glowroot/plugins/spooler.json
diff --git a/dockerfiles/run/guice/jpa-smtp/destination/glowroot/plugins/task.json b/server/container/guice/jpa-smtp/src/main/glowroot/plugins/task.json
similarity index 100%
rename from dockerfiles/run/guice/jpa-smtp/destination/glowroot/plugins/task.json
rename to server/container/guice/jpa-smtp/src/main/glowroot/plugins/task.json
diff --git a/server/container/guice/jpa-smtp/src/main/scripts/james-cli b/server/container/guice/jpa-smtp/src/main/scripts/james-cli
new file mode 100755
index 0000000..19a73b6
--- /dev/null
+++ b/server/container/guice/jpa-smtp/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