Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

james-extendable-server #21

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,18 @@ spotless {
subprojects {

ext {
// jamesVersion = '3.4.0'
jamesVersion = '3.6.0-SNAPSHOT'
}

repositories {
// First look for local Apache James dependencies. We can publish code changes locally and work with them
// See caveats https://docs.gradle.org/current/userguide/declaring_repositories.html#sec:case-for-maven-local
// Maybe avoid mavenLocal and use a directory with jars.
mavenLocal()

// Next look into snapshots and staging
// https://infra.apache.org/repository-faq.html

maven { url "https://repository.apache.org/content/groups/public/" }
maven { url "https://repository.apache.org/content/groups/staging/" }
maven { url "https://repository.apache.org/content/groups/snapshots/" }
// maven { url "https://repository.apache.org/content/groups/public/" }
// maven { url "https://repository.apache.org/content/groups/staging/" }
// maven { url "https://repository.apache.org/content/groups/snapshots/" }

mavenCentral()
jcenter()
// jcenter()
}
}
84 changes: 84 additions & 0 deletions conf/elasticsearch.properties.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# 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.

# This template file can be used as example for James Server configuration
# DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS

# Configuration file for ElasticSearch

# Read https://james.apache.org/server/config-elasticsearch.html for further details

elasticsearch.masterHost=elasticsearch
elasticsearch.port=9200

# Optional. Only http or https are accepted, default is http
# elasticsearch.hostScheme=http

# Optional, default is `default`
# Choosing the SSL check strategy when using https scheme
# default: Use the default SSL TrustStore of the system.
# ignore: Ignore SSL Validation check (not recommended).
# override: Override the SSL Context to use a custom TrustStore containing ES server's certificate.
# elasticsearch.hostScheme.https.sslValidationStrategy=default

# Optional. Required when using 'https' scheme and 'override' sslValidationStrategy
# Configure Elasticsearch rest client to use this trustStore file to recognize nginx's ssl certificate.
# You need to specify both trustStorePath and trustStorePassword
# elasticsearch.hostScheme.https.trustStorePath=/file/to/trust/keystore.jks

# Optional. Required when using 'https' scheme and 'override' sslValidationStrategy
# Configure Elasticsearch rest client to use this trustStore file with the specified password.
# You need to specify both trustStorePath and trustStorePassword
# elasticsearch.hostScheme.https.trustStorePassword=myJKSPassword

# Optional. default is `default`
# Configure Elasticsearch rest client to use host name verifier during SSL handshake
# default: using the default hostname verifier provided by apache http client.
# accept_any_hostname: accept any hostname (not recommended).
# elasticsearch.hostScheme.https.hostNameVerifier=default

# Optional.
# Basic auth username to access elasticsearch.
# Ignore elasticsearch.user and elasticsearch.password to not be using authentication (default behaviour).
# Otherwise, you need to specify both properties.
# elasticsearch.user=elasticsearch

# Optional.
# Basic auth password to access elasticsearch.
# Ignore elasticsearch.user and elasticsearch.password to not be using authentication (default behaviour).
# Otherwise, you need to specify both properties.
# elasticsearch.password=secret

# You can alternatively provide a list of hosts following this format :
# elasticsearch.hosts=host1:9200,host2:9200
# elasticsearch.clusterName=cluster

elasticsearch.nb.shards=5
elasticsearch.nb.replica=1
elasticsearch.index.waitForActiveShards=1
elasticsearch.retryConnection.maxRetries=7
elasticsearch.retryConnection.minDelay=3000
# Index or not attachments (default value: true)
elasticsearch.indexAttachments=true

# Reports for metrics into ElasticSearch
# Defaults to elasticsearch.masterHost : on which server to publish metrics
elasticsearch.http.host=elasticsearch
elasticsearch.http.port=9200
elasticsearch.metrics.reports.enabled=true
elasticsearch.metrics.reports.period=30
elasticsearch.metrics.reports.index=james-metrics
File renamed without changes.
1 change: 1 addition & 0 deletions james-extendable-server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/var/
55 changes: 55 additions & 0 deletions james-extendable-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
################################################################################
# Dockerfile for the James Extendable Server
#
# See: [link]
#
################################################################################

# some global args

ARG install_prefix="/opt/apache-james"

# Stage 1 - unpack james
FROM adoptopenjdk:11-jre-hotspot as unpack

ARG install_prefix

COPY james-cli/build/distributions/james-cli.tar /tmp/james-cli.tar
COPY james-extendable-server/build/distributions/james-extendable-server.tar /tmp/james-server.tar

RUN mkdir -p "${install_prefix}" \
&& tar -xvf /tmp/james-cli.tar --directory "${install_prefix}" \
&& tar -xvf /tmp/james-server.tar --directory "${install_prefix}" \
&& apt-get update && apt-get install -y tree && tree "${install_prefix}"

# Stage 2 Apache James Server and CLI
FROM adoptopenjdk:11-jre-hotspot as james_server_and_cli

ARG install_prefix

# Include as desired:
#
# 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
#

EXPOSE 465 143 8000

COPY --from=unpack $install_prefix ${install_prefix}

# We are going to mount the configuraton as a volume
# COPY conf ${install_prefix}/james-server/conf

WORKDIR ${install_prefix}

# Add start scripts to path
ENV PATH="${PATH}:${install_prefix}/james-extendable-server/bin:${install_prefix}/james-cli/bin"


ENTRYPOINT ["james-cli"]
CMD ["-help"]
27 changes: 27 additions & 0 deletions james-extendable-server/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
plugins {
id 'java'
id "application"
}

java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

dependencies {
implementation "com.google.inject:guice:4.2.2"
implementation "org.apache.james:james-server-jpa-guice:${jamesVersion}"
implementation "org.apache.james:james-server-guice-smtp:${jamesVersion}"
implementation project(":james-mailets")
}

def jamesMainClass = 'net.leangen.james.ExtendableServer'

application {
mainClass = jamesMainClass
def thisProjectDir = "${project.rootDir}/james-extendable-server"
println("Dir:" + thisProjectDir)
def workingDir = "${thisProjectDir}"
def configFile = "${workingDir}/conf/logback.xml"
applicationDefaultJvmArgs = ["-Dlogback.configurationFile=${configFile}", "-Dworking.directory=${workingDir}"]
}
27 changes: 27 additions & 0 deletions james-extendable-server/conf/imapserver.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<imapservers>

<imapserver enabled="true">

<jmxName>imapserver</jmxName>

<!--+
| Use 143 when running in Docker.
| Else use 9143 when running locally (for example in debug mode)
+-->
<!--bind>0.0.0.0:143</bind-->
<bind>0.0.0.0:9143</bind>

<connectionBacklog>200</connectionBacklog>

<tls socketTLS="false" startTLS="false">
<keystore>file://conf/keystore</keystore>
<secret>yoursecret</secret>
<provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
</tls>

<connectionLimit>0</connectionLimit>
<connectionLimitPerIP>0</connectionLimitPerIP>

</imapserver>

</imapservers>
7 changes: 7 additions & 0 deletions james-extendable-server/conf/james-database.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
database.driverClassName=org.apache.derby.jdbc.EmbeddedDriver
database.url=jdbc:derby:var/store/derby;create=true
derby.stream.error.file=logs/derby.log
database.username=app
database.password=app
vendorAdapter.database=DERBY
openjpa.streaming=false
80 changes: 80 additions & 0 deletions james-extendable-server/conf/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--+
| This is the configuration file required by the Logback logging system.
|
| You should normally not need to edit this file. Please do not remove it or
| make any changes unless you know what you are doing.
|
| Information about the Logback system can be found at http://logback.qos.ch/.
|
| Apache James uses the Logback system to output system logs. We have configured
| logback to provide minimal information for Operators to help understand the
| state of a running James Server.
|
| Additionally, we have configured Logback to output more detailed diagnostic
| information to a file located in logs/james.log. This output may come in
| handy if you run into any issues and request help from James Developers.
+-->
<configuration>

<!--+
| NOTE: I do not know what this is for! (dml)
+-->
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
<resetJUL>true</resetJUL>
</contextListener>

<!--+
| This entry suppresses logback (self) output.
+-->
<statusListener class="ch.qos.logback.core.status.NopStatusListener" />

<!--+
| Log minimal output to the console for the Operator.
+-->
<appender name="OPERATOR_CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} %highlight([%-5level]) %logger{15} - %msg%n%rEx</pattern>
<immediateFlush>false</immediateFlush>
</encoder>
</appender>

<!--+
| Log diagnostic output to file for Developers who may eventually provide support.
+-->
<appender name="DIAGNOSTIC_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>logs/james.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>logs/james.%i.log.tar.gz</fileNamePattern>
<minIndex>1</minIndex>
<maxIndex>3</maxIndex>
</rollingPolicy>

<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>100MB</maxFileSize>
</triggeringPolicy>

<encoder>
<pattern>%d{HH:mm:ss.SSS} [%-5level] %logger{15} - %msg%n%rEx</pattern>
<immediateFlush>false</immediateFlush>
</encoder>
</appender>

<!--+
| Set the default root logger level to DEBUG for diagnostic output.
+-->
<root level="WARN">
<appender-ref ref="DIAGNOSTIC_FILE" />
</root>

<!--+
| Package-specific levels for Operator output.
+-->
<logger name="org.apache.james" level="INFO" additivity="false">
<appender-ref ref="DIAGNOSTIC_FILE" />
</logger>
<logger name="openjpa" level="NONE" additivity="false">
<appender-ref ref="OPERATOR_CONSOLE" />
</logger>

</configuration>
Loading