james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [james-project] 06/07: JAMES-2867 Using Jib for dockerization process
Date Tue, 03 Sep 2019 10:30:03 GMT
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 f88efe6adf1e9e61d55157d18e26790f71c5957a
Author: Rene Cordier <rcordier@linagora.com>
AuthorDate: Mon Aug 26 16:24:52 2019 +0700

    JAMES-2867 Using Jib for dockerization process
---
 server/mailet/mock-smtp-server/Dockerfile  | 11 ------
 server/mailet/mock-smtp-server/README.adoc | 12 +++----
 server/mailet/mock-smtp-server/pom.xml     | 56 ++++++++++++++++++------------
 3 files changed, 39 insertions(+), 40 deletions(-)

diff --git a/server/mailet/mock-smtp-server/Dockerfile b/server/mailet/mock-smtp-server/Dockerfile
deleted file mode 100644
index c32d51b..0000000
--- a/server/mailet/mock-smtp-server/Dockerfile
+++ /dev/null
@@ -1,11 +0,0 @@
-FROM openjdk:8u222-jre
-
-# Ports that are used:
-#
-# 25   SMTP without authentication
-# 8000 Web Admin interface
-EXPOSE 25 8000
-
-COPY target/mock-smtp-server.jar /root/mock-smtp-server.jar
-
-ENTRYPOINT [ "sh", "-c", "java -jar /root/mock-smtp-server.jar" ]
diff --git a/server/mailet/mock-smtp-server/README.adoc b/server/mailet/mock-smtp-server/README.adoc
index b38ad98..04ad791 100644
--- a/server/mailet/mock-smtp-server/README.adoc
+++ b/server/mailet/mock-smtp-server/README.adoc
@@ -5,19 +5,19 @@ This is our custom made Mock SMTP server that we use for some of our tests
in Ja
 
 == Dockerized Mock SMTP server
 
-Start by compiling the module:
+Compile and build the image into a tarball with maven:
 
-    $ mvn clean install
+    $ mvn package
 
 *Note* : You can add the option '-DskipTests' if you want to skip tests
 
-Then build the docker image:
+After Jib created the image, you can load it into Docker with:
 
-    $ docker build -t james/mock-smtp-server .
+    $ docker load --input target/jib-mock-smtp-server.tar
 
-And run it:
+Then run it with:
 
-    $ docker run --rm -p 25:25 -p 8000:8000 james/mock-smtp-server
+    $ docker run --rm -p 25:25 -p 8000:8000 linagora/mock-smtp-server
 
 Where ports:
 
diff --git a/server/mailet/mock-smtp-server/pom.xml b/server/mailet/mock-smtp-server/pom.xml
index 7dc9bde..dc97c15 100644
--- a/server/mailet/mock-smtp-server/pom.xml
+++ b/server/mailet/mock-smtp-server/pom.xml
@@ -123,42 +123,52 @@
     <build>
         <plugins>
             <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-dependency-plugin</artifactId>
+                <groupId>com.google.cloud.tools</groupId>
+                <artifactId>jib-maven-plugin</artifactId>
+                <version>1.5.0</version>
+                <configuration>
+                    <from>
+                        <image>openjdk:8u222-jre</image>
+                    </from>
+                    <to>
+                        <image>linagora/mock-smtp-server</image>
+                        <tags>
+                            <tag>latest</tag>
+                        </tags>
+                    </to>
+                    <container>
+                        <mainClass>org.apache.james.mock.smtp.server.MockSMTPServerMain</mainClass>
+                        <creationTime>USE_CURRENT_TIMESTAMP</creationTime>
+                        <ports>
+                            <port>25</port>
+                            <port>8000</port>
+                        </ports>
+                    </container>
+                </configuration>
                 <executions>
                     <execution>
-                        <id>copy-dependencies</id>
+                        <id>docker packaging</id>
+                        <phase>package</phase>
                         <goals>
-                            <goal>copy-dependencies</goal>
+                            <goal>buildTar</goal>
                         </goals>
-                        <phase>package</phase>
-                        <configuration>
-                            <includeScope>compile</includeScope>
-                            <includeScope>runtime</includeScope>
-                            <outputDirectory>${project.build.directory}/${project.artifactId}.lib</outputDirectory>
-                        </configuration>
                     </execution>
                 </executions>
             </plugin>
             <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-jar-plugin</artifactId>
+                <groupId>com.coderplus.maven.plugins</groupId>
+                <artifactId>copy-rename-maven-plugin</artifactId>
+                <version>1.0</version>
                 <executions>
                     <execution>
-                        <id>default-jar</id>
+                        <id>copy-file</id>
+                        <phase>package</phase>
                         <goals>
-                            <goal>jar</goal>
+                            <goal>rename</goal>
                         </goals>
                         <configuration>
-                            <finalName>${project.artifactId}</finalName>
-                            <archive>
-                                <manifest>
-                                    <addClasspath>true</addClasspath>
-                                    <classpathPrefix>${project.artifactId}.lib/</classpathPrefix>
-                                    <mainClass>org.apache.james.mock.smtp.server.MockSMTPServerMain</mainClass>
-                                    <useUniqueVersions>false</useUniqueVersions>
-                                </manifest>
-                            </archive>
+                            <sourceFile>${basedir}/target/jib-image.tar</sourceFile>
+                            <destinationFile>${basedir}/target/jib-mock-smtp-server.tar</destinationFile>
                         </configuration>
                     </execution>
                 </executions>


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message