xwiki: switch to PostgreSQL and remove custom Hibernate override

Config: set database.type=postgres; use image tag lts-<dbtype>-tomcat; make DB_TYPE templated; derive database_type from app config.

Cleanup: delete hibernate.cfg.xml template and volume mounts; remove XWIKI_HOST_HIBERNATE_PATH; stop rendering hibernate.cfg.xml.

web-svc-cdn: run_once task fix.

Context: troubleshooting on 2025-09-12. Conversation link: https://chatgpt.com/share/68c3978e-77cc-800f-beda-19220f70855f
This commit is contained in:
2025-09-12 05:46:45 +02:00
parent cce33373ba
commit 07b7c6484f
8 changed files with 8 additions and 33 deletions

View File

@@ -5,9 +5,10 @@ docker:
enabled: false enabled: false
database: database:
enabled: true enabled: true
type: postgres
xwiki: xwiki:
image: xwiki image: xwiki
version: stable-mariadb-tomcat version: lts-<< defaults_applications[web-app-xwiki].docker.services.database.type >>-tomcat
name: xwiki name: xwiki
backup: backup:
no_stop_required: true no_stop_required: true

View File

@@ -16,12 +16,6 @@
dest: "{{ XWIKI_HOST_PROPERTIES_PATH }}" dest: "{{ XWIKI_HOST_PROPERTIES_PATH }}"
notify: docker compose up notify: docker compose up
- name: "Render hibernate.cfg.xml"
template:
src: "hibernate.cfg.xml.j2"
dest: "{{ XWIKI_HOST_HIBERNATE_PATH }}"
notify: docker compose up
- name: "flush docker compose for '{{ application_id }}'" - name: "flush docker compose for '{{ application_id }}'"
meta: flush_handlers meta: flush_handlers

View File

@@ -11,8 +11,6 @@
volumes: volumes:
- "{{ XWIKI_HOST_CONF_PATH }}:/usr/local/xwiki/xwiki.cfg" - "{{ XWIKI_HOST_CONF_PATH }}:/usr/local/xwiki/xwiki.cfg"
- "{{ XWIKI_HOST_PROPERTIES_PATH }}:/usr/local/xwiki/xwiki.properties" - "{{ XWIKI_HOST_PROPERTIES_PATH }}:/usr/local/xwiki/xwiki.properties"
- "{{ XWIKI_HOST_HIBERNATE_PATH }}:/usr/local/xwiki/hibernate.cfg.xml"
- "{{ XWIKI_HOST_HIBERNATE_PATH }}:/usr/local/tomcat/webapps/ROOT/WEB-INF/hibernate.cfg.xml"
- 'data:/usr/local/xwiki' - 'data:/usr/local/xwiki'
{% include 'roles/docker-container/templates/healthcheck/curl.yml.j2' %} {% include 'roles/docker-container/templates/healthcheck/curl.yml.j2' %}
{% include 'roles/docker-container/templates/base.yml.j2' %} {% include 'roles/docker-container/templates/base.yml.j2' %}

View File

@@ -3,3 +3,4 @@ DB_PASSWORD="{{ database_password }}"
DB_HOST="{{ database_host }}" DB_HOST="{{ database_host }}"
DB_PORT="{{ database_port }}" DB_PORT="{{ database_port }}"
DB_DATABASE="{{ database_name }}" DB_DATABASE="{{ database_name }}"
DB_TYPE="{{ 'mariadb' if database_type == 'mariadb' else 'postgresql' }}"

View File

@@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- deine bestehenden DB-Props (Driver, URL, User, Pass) -->
<property name="hibernate.connection.driver_class">org.mariadb.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mariadb://{{ database_host }}:{{ database_port }}/{{ database_name }}?useUnicode=true&amp;characterEncoding=UTF-8</property>
<property name="hibernate.connection.username">{{ database_username }}</property>
<property name="hibernate.connection.password">{{ database_password }}</property>
<!-- DBCP: leichte Validierung statt Treiber-isValid / Diagnose -->
<property name="hibernate.dbcp.testOnBorrow">true</property>
<property name="hibernate.dbcp.testWhileIdle">true</property>
<property name="hibernate.dbcp.validationQuery">SELECT 1</property>
<property name="hibernate.dbcp.validationQueryTimeout">5</property>
<property name="hibernate.dbcp.timeBetweenEvictionRunsMillis">30000</property>
<property name="hibernate.dbcp.minEvictableIdleTimeMillis">60000</property>
</session-factory>
</hibernate-configuration>

View File

@@ -1,6 +1,7 @@
# General # General
application_id: "web-app-xwiki" application_id: "web-app-xwiki"
database_type: "mariadb" database_type: "{{ applications | get_app_conf(application_id, 'docker.services.database.type') }}"
container_port: 8080 container_port: 8080
container_hostname: "{{ domains | get_domain(application_id) }}" container_hostname: "{{ domains | get_domain(application_id) }}"
@@ -14,7 +15,6 @@ XWIKI_HOSTNAME: "{{ container_hostname }}"
## Paths ## Paths
XWIKI_HOST_CONF_PATH: "{{ [docker_compose.directories.config, 'xwiki.cfg'] | path_join }}" XWIKI_HOST_CONF_PATH: "{{ [docker_compose.directories.config, 'xwiki.cfg'] | path_join }}"
XWIKI_HOST_PROPERTIES_PATH: "{{ [docker_compose.directories.config, 'xwiki.properties'] | path_join }}" XWIKI_HOST_PROPERTIES_PATH: "{{ [docker_compose.directories.config, 'xwiki.properties'] | path_join }}"
XWIKI_HOST_HIBERNATE_PATH: "{{ [docker_compose.directories.config, 'hibernate.cfg.xml'] | path_join }}"
## Docker ## Docker
XWIKI_IMAGE_CUSTOM: "xwiki_custom" XWIKI_IMAGE_CUSTOM: "xwiki_custom"

View File

@@ -15,4 +15,6 @@
template: template:
src: "nginx.conf.j2" src: "nginx.conf.j2"
dest: "{{ CDN_NGINX_PATH }}" dest: "{{ CDN_NGINX_PATH }}"
notify: restart openresty notify: restart openresty
- include_tasks: utils/run_once.yml

View File

@@ -1,6 +1,5 @@
- block: - block:
- include_tasks: 01_core.yml - include_tasks: 01_core.yml
- include_tasks: utils/run_once.yml
when: run_once_web_svc_cdn is not defined when: run_once_web_svc_cdn is not defined
- include_tasks: "{{ playbook_dir }}/tasks/utils/load_handlers.yml" - include_tasks: "{{ playbook_dir }}/tasks/utils/load_handlers.yml"