JAMES-2058 Add new page on the website to configure Spring JPA with Postgres


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/be37b9c0
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/be37b9c0
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/be37b9c0

Branch: refs/heads/master
Commit: be37b9c0c1d6eb50df4ea06761b9b8013a7b6b0d
Parents: 53d7536
Author: quynhn <qngu...@linagora.com>
Authored: Thu Jun 15 17:58:37 2017 +0700
Committer: benwa <btell...@linagora.com>
Committed: Wed Jun 21 14:59:04 2017 +0700

----------------------------------------------------------------------
 src/site/site.xml                               |   1 +
 .../xdoc/server/config-spring-jpa-postgres.xml  | 109 +++++++++++++++++++
 2 files changed, 110 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/be37b9c0/src/site/site.xml
----------------------------------------------------------------------
diff --git a/src/site/site.xml b/src/site/site.xml
index b73abec..9b7fd05 100644
--- a/src/site/site.xml
+++ b/src/site/site.xml
@@ -134,6 +134,7 @@
                         <item name="Guice" href="/server/config-guice.html" />
                         <item name="ElasticSearch" 
href="/server/config-elasticsearch.html" />
                         <item name="Cassandra" 
href="/server/config-cassandra.html" />
+                        <item name="Spring JPA Postgres" 
href="/server/config-spring-jpa-postgres.html" />
                         <item name="Quota" href="/server/config-quota.html" />
                         <item name="Events" href="/server/config-events.html" 
/>
                     </item>

http://git-wip-us.apache.org/repos/asf/james-project/blob/be37b9c0/src/site/xdoc/server/config-spring-jpa-postgres.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/server/config-spring-jpa-postgres.xml 
b/src/site/xdoc/server/config-spring-jpa-postgres.xml
new file mode 100644
index 0000000..d88824a
--- /dev/null
+++ b/src/site/xdoc/server/config-spring-jpa-postgres.xml
@@ -0,0 +1,109 @@
+<?xml version="1.0"?>
+<!--
+  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.    
+-->
+<document>
+
+ <properties>
+  <title>Apache James Server 3 - Spring JPA With Postgres Configuration</title>
+ </properties>
+
+<body>
+
+
+    <section name="Introduction">
+      <p>Consult <a 
href="http://james.apache.org/server/config-system.html";>System 
Configuration</a> to get template, some examples and hints for the 
configuration with JPA.</p>
+    </section>
+
+    <section name="Current Supported Relational Database">
+      <p>James supports Derby as a default database, you do not need to do any 
additional configuration if you are using Derby</p>
+    </section>
+
+    <section name="Spring JPA With Postgres Configuration">
+      <p>If you wish to use Postgres as a database, please follow those steps 
to configure it</p>
+      <subsection name="Step 1: Create database on Postgres">
+
+        <p>You need to install Postgres or run Postgres with Docker</p>
+
+        <p>Example to install it on Debian:</p>
+        <source>
+          sudo apt-get update && sudo apt-get install postgresql-9.4 
postgresql-client-9.4
+        </source>
+        <p>Example to pull and launch Postgres on docker</p>
+        <source>
+          docker run --detach --name postgres library/postgres
+        </source>
+        <p>Postgres does not create database on the fly so you need to create 
the database manually if it does not exist. Here is the command to perform this 
action: </p>
+
+        <source>psql --username postgres --tuples-only --command "SELECT 1 
FROM pg_database WHERE dataname = 
'<strong><italic>database_name</italic></strong>'" \
+          | grep -q 1 || psql --username postgres --command "CREATE DATABASE 
<strong><italic>database_name</italic></strong>"</source>
+
+        <dl>
+          <dt><strong>database_name</strong></dt>
+          <dd>The name of database</dd>
+        </dl>
+
+      </subsection>
+
+      <subsection name="Step 2: Point to the database in configuration file">
+        <p>Change the content of <italic>james-database.properties</italic> 
and point to the 'database_name' created earlier</p>
+        <source>
+          database.driverClassName=org.postgresql.Driver
+          
database.url=jdbc:postgresql://<strong>ip_of_postgres</strong>/<strong>database_name</strong>
+          database.username=postgres
+          database.password=postgres
+
+          vendorAdapter.database=POSTGRESQL
+        </source>
+        <p>If you are using the James Spring docker image. You need to 
customise the configuration file of the docker container with those steps:</p>
+          <ul>
+            <li>Create a new james-database.properties file with above 
content</li>
+            <li>Then you can add the configuration file to docker container 
using --volume flag</li>
+              <source>
+                --volume 
path_to_folder_which_contain_configuration_file/james-database.properties:/root/james-server-app-3.0.0-RC2-SNAPSHOT/conf/james-database.properties
+              </source>
+          </ul>
+      </subsection>
+
+      <subsection name="Step 3: Copy driver class to the right place">
+        <p>Follow this link <a 
href="https://jdbc.postgresql.org/download.html";>Postgres Driver</a> to 
download the right version of the JDBC driver.</p>
+        <p>Copy that jar file to the <strong>conf/lib/</strong> folder of 
Spring James</p>
+        <p>If you are using the James Spring docker image, download the jar 
file then make it available on the classpath of your James instance using an 
additional docker volume: </p>
+        <source>
+          --volume 
path_to_folder_which_contain_jar_file/:/root/james-server-app-3.0.0-RC2-SNAPSHOT/conf/lib/
+        </source>
+      </subsection>
+
+      <subsection name="Step 4: Restart James">
+        <p>Follow the guide on <a 
href="http://james.apache.org/server/install.html";>Restart and Testing</a> to 
restart James</p>
+
+        <p>If you are using the James Spring docker image, launch James docker 
or just stop and start docker container again if it ran. </p>
+
+        <p>Example to launch James Spring docker image with the volume</p>
+        <source>
+          docker run --volume 
path_to_folder_which_contain_configuration_file/james-database.properties:/root/james-server-app-3.0.0-RC2-SNAPSHOT/conf/james-database.properties
 \
+          --volume 
path_to_folder_which_contain_jar_file/:/root/james-server-app-3.0.0-RC2-SNAPSHOT/conf/lib/
 \
+          --hostname localhost --publish "25:25" --publish "110:110" --publish 
"143:143" --publish "465:465" --publish "587:587" --publish "993:993" \
+          --name james_run linagora/james-jpa-spring
+        </source>
+      </subsection>
+    </section>
+
+</body>
+
+</document>


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

Reply via email to