[
  {
    "path": ".github/renovate.json5",
    "content": "/*\n * See the NOTICE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n {\n  \"$schema\": \"https://docs.renovatebot.com/renovate-schema.json\",\n  \"extends\": [\n    \"config:base\"\n  ]\n}\n"
  },
  {
    "path": ".github/workflows/gradlew-check.yml",
    "content": "## See the NOTICE file distributed with this work for additional\n## information regarding copyright ownership.\n##\n## This is free software; you can redistribute it and/or modify it\n## under the terms of the GNU Lesser General Public License as\n## published by the Free Software Foundation; either version 2.1 of\n## the License, or (at your option) any later version.\n##\n## This software is distributed in the hope that it will be useful,\n## but WITHOUT ANY WARRANTY; without even the implied warranty of\n## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n## Lesser General Public License for more details.\n##\n## You should have received a copy of the GNU Lesser General Public\n## License along with this software; if not, write to the Free\n## Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n## 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n##\n## The goal of this action is to help developers automatically detect missing updates to files derived from templates.\n## It works by running gradlew after each commit.\n## If this results in files being updated, it means that gradlew should have been run and its output should have been\n## added to the commit.\n## The action then ends with an error.\nname: Gradlew Check\n\non:\n  push:\n    branches: [ master ]\n\njobs:\n  gradlew-check:\n    runs-on: ubuntu-latest\n\n    steps:\n      - name: Checkout code\n        uses: actions/checkout@v4\n\n      - name: Set up JDK\n        uses: actions/setup-java@v4\n        with:\n          distribution: 'temurin'\n          java-version: '21'\n\n      - name: Run Gradle\n        run: ./gradlew\n\n      - name: Check for changed files\n        run: |\n          if [[ -n $(git status --porcelain) ]]; then\n            echo \"Error: Files were modified by Gradle build\"\n            echo \"Changed files:\"\n            git status --porcelain\n            git diff\n            exit 1\n          else\n            echo \"Success: No files were modified\"\n          fi"
  },
  {
    "path": ".gitignore",
    "content": "# Build\ntarget\ntarget-eclipse\n\n# Gradle\n.gradle\n/build/\ngradle-app.setting\n!gradle-wrapper.jar\n.gradletasknamecache\n\n# IDEA\n*.iml\n*.ipr\n*.iws\n.idea\natlassian-ide-plugin.xml\n\n# Eclipse\n.classpath\n.project\n.settings\n.checkstyle\n.fbprefs\nbin\n# Automatically generated by WTP\n**/src/main/java/META-INF/\n**/src/test/java/META-INF/\n**/src/META-INF/\n#PyDev\n.pydevproject\n\n# NetBeans\nnbproject\n\n# Other\n*.log.*\n*.log\n.sonar-ide.properties\n.clover\n*~\n"
  },
  {
    "path": "17/mariadb-tomcat/Dockerfile",
    "content": "# ---------------------------------------------------------------------------\n# See the NOTICE file distributed with this work for additional\n# information regarding copyright ownership.\n#\n# This is free software; you can redistribute it and/or modify it\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 2.1 of\n# the License, or (at your option) any later version.\n#\n# This software is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n# Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this software; if not, write to the Free\n# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n# 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n# ---------------------------------------------------------------------------\nFROM tomcat:10-jre21\n\n#    ____  ____  ____      ____  _   __        _\n#   |_  _||_  _||_  _|    |_  _|(_) [  |  _   (_)\n#     \\ \\  / /    \\ \\  /\\  / /  __   | | / ]  __\n#      > `' <      \\ \\/  \\/ /  [  |  | '' <  [  |\n#    _/ /'`\\ \\_     \\  /\\  /    | |  | |`\\ \\  | |\n#   |____||____|     \\/  \\/    [___][__|  \\_][___]\n\nLABEL org.opencontainers.image.authors='XWiki Development Team <committers@xwiki.org>'\nLABEL org.opencontainers.image.url='https://hub.docker.com/_/xwiki'\nLABEL org.opencontainers.image.documentation='https://hub.docker.com/_/xwiki'\nLABEL org.opencontainers.image.source='https://github.com/xwiki/xwiki-docker.git'\nLABEL org.opencontainers.image.vendor='xwiki.org'\nLABEL org.opencontainers.image.licenses='LGPL-2.1'\n\n# Note: when using docker-compose, the ENV values below are overridden from the .env file.\n\n# Install LibreOffice + other tools\n# Note that procps is required to get ps which is used by JODConverter to start LibreOffice\nRUN apt-get update && \\\n  apt-get --no-install-recommends -y install \\\n    curl \\\n    libreoffice \\\n    unzip \\\n    procps && \\\n  rm -rf /var/lib/apt/lists/*\n\n# Install XWiki as the ROOT webapp context in Tomcat\n# Create the Tomcat temporary directory\n# Configure the XWiki permanent directory\nENV XWIKI_VERSION=\"17.10.8\"\nENV XWIKI_URL_PREFIX \"https://maven.xwiki.org/releases/org/xwiki/platform/xwiki-platform-distribution-war/${XWIKI_VERSION}\"\nENV XWIKI_DOWNLOAD_SHA256 f5dfab908fddb6319e64897bb2fc41661dd5b5d8aafa455db72c8a794eaa5287\nRUN rm -rf /usr/local/tomcat/webapps/* && \\\n  mkdir -p /usr/local/tomcat/temp && \\\n  mkdir -p /usr/local/xwiki/data && \\\n  curl -fSL \"${XWIKI_URL_PREFIX}/xwiki-platform-distribution-war-${XWIKI_VERSION}.war\" -o xwiki.war && \\\n  echo \"$XWIKI_DOWNLOAD_SHA256 xwiki.war\" | sha256sum -c - && \\\n  unzip -d /usr/local/tomcat/webapps/ROOT xwiki.war && \\\n  rm -f xwiki.war\n\n# Copy the JDBC driver in the XWiki webapp\n# We take the database driver version from the Maven Central repository since we want to control the version \n# used and have it being consistent with what is tested in the CI.\nENV MARIADB_JDBC_VERSION=\"3.5.8\"\nENV MARIADB_JDBC_SHA256=\"6127dc7858047b3d4482899139640b0e2ab2b8abdeb708cfb8c011117771cddf\"\nENV MARIADB_JDBC_PREFIX=\"https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/${MARIADB_JDBC_VERSION}\"\nENV MARIADB_JDBC_ARTIFACT=\"mariadb-java-client-${MARIADB_JDBC_VERSION}.jar\"\nENV MARIADB_JDBC_TARGET=\"/usr/local/tomcat/webapps/ROOT/WEB-INF/lib/${MARIADB_JDBC_ARTIFACT}\"\nRUN curl -fSL \"${MARIADB_JDBC_PREFIX}/${MARIADB_JDBC_ARTIFACT}\" -o $MARIADB_JDBC_TARGET && \\\n  echo \"$MARIADB_JDBC_SHA256 $MARIADB_JDBC_TARGET\" | sha256sum -c -\n\n# Configure Tomcat. For example set the memory for the Tomcat JVM since the default value is too small for XWiki\nCOPY tomcat/setenv.sh /usr/local/tomcat/bin/\n\n# Setup the XWiki Hibernate configuration\nCOPY xwiki/hibernate.cfg.xml /usr/local/tomcat/webapps/ROOT/WEB-INF/hibernate.cfg.xml\n\n# Set a specific distribution id in XWiki for this docker packaging.\nRUN sed -i 's/<id>org.xwiki.platform:xwiki-platform-distribution-war/<id>org.xwiki.platform:xwiki-platform-distribution-docker/' \\\n  /usr/local/tomcat/webapps/ROOT/META-INF/extension.xed\n\n# Add scripts required to make changes to XWiki configuration files at execution time\n# Note: we don't run CHMOD since 1) it's not required since the executabe bit is already set in git and 2) running\n# CHMOD after a COPY will sometimes fail, depending on different host-specific factors (especially on AUFS).\nCOPY xwiki/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh\n\n# Make the XWiki directory (the permanent directory is included in it) persist on the host (so that it's not recreated\n# across runs)\nVOLUME /usr/local/xwiki\n\n# At this point the image is done and what remains below are the runtime configuration used by the user to configure\n# the container that will be created out of the image. Namely the user can override some environment variables with\n#   docker run -e \"var1=val1\" -e \"var2=val2\" ...\n# The supported environment variables that can be overridden are:\n# - DB_USER: the name of the user configured for XWiki in the DB. Default is \"xwiki\". This is used to configure\n#            xwiki's hibernate.cfg.xml file.\n# - DB_PASSWORD: the password for the user configured for XWiki in the DB. Default is \"xwiki\". This is used to\n#                configure xwiki's hibernate.cfg.xml file.\n# - DB_DATABASE: the name of the database to use. Default is \"xwiki\". This is used to configure xwiki's\n#                hibernate.cfg.xml file.\n# - DB_HOST: The name of the host (or docker container) containing the database. Default is \"db\". This is used to\n#            configure xwiki's hibernate.cfg.xml file.\n# - CONTEXT_PATH: The name of the context path under which XWiki will be deployed in Tomcat. If not specified then it'll\n#                 be deployed as ROOT.\n# - JDBC_PARAMS: Replaces the default JDBC parameters with the passed ones.\n\n# Example:\n#   docker run -it -e \"DB_USER=xwiki\" -e \"DB_PASSWORD=xwiki\" <imagename>\n\n# Starts XWiki by starting Tomcat. All options passed to \"docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]\"\n# are also passed to docker-entrypoint.sh. If \"xwiki\" is passed then XWiki will be configured the first time the\n# container executes and Tomcat will be started. If some other parameter is passed then it'll be executed to comply\n# with best practices defined at https://github.com/docker-library/official-images#consistency.\nENTRYPOINT [\"docker-entrypoint.sh\"]\nCMD [\"xwiki\"]\n"
  },
  {
    "path": "17/mariadb-tomcat/docker-compose.yml",
    "content": "# ---------------------------------------------------------------------------\n# See the NOTICE file distributed with this work for additional\n# information regarding copyright ownership.\n#\n# This is free software; you can redistribute it and/or modify it\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 2.1 of\n# the License, or (at your option) any later version.\n#\n# This software is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n# Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this software; if not, write to the Free\n# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n# 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n# ---------------------------------------------------------------------------\nversion: '2'\nnetworks:\n  bridge:\n    driver: bridge\nservices:\n  # The container that runs XWiki in Tomcat, with the appropriate JDBC driver (for mariadb).\n  web:\n    image: \"xwiki:${XWIKI_VERSION}-mariadb-tomcat\"\n    container_name: xwiki-mariadb-tomcat-web\n    depends_on:\n      - db\n    ports:\n      - \"8080:8080\"\n    # Default values defined in .env file.\n    # The DB_USER/DB_PASSWORD/DB_DATABASE/DB_HOST variables are used in the hibernate.cfg.xml file.\n    environment:\n      - XWIKI_VERSION=${XWIKI_VERSION}\n      - DB_USER=${DB_USER}\n      - DB_PASSWORD=${DB_PASSWORD}\n      - DB_DATABASE=${DB_DATABASE}\n      - DB_HOST=xwiki-mariadb-db\n    # Provide a name instead of an auto-generated id for xwiki data (the permanent directory in included in it)\n    # configured in the Dockerfile, to make it simpler to identify in 'docker volume ls'.\n    volumes:\n      - xwiki-data:/usr/local/xwiki\n    networks:\n      - bridge\n  # The container that runs the database (mariadb)\n  db:\n    image: \"mariadb:12\"\n    container_name: xwiki-mariadb-db\n    # - Provide a name instead of an auto-generated id for the mariadb data, to make it simpler to identify in\n    # 'docker volume ls'\n    # - Provide a SQL script to be executed when the db image starts (to set permissions to create subwikis)\n    volumes:\n      - mariadb-data:/var/lib/mysql\n      - ./init.sql:/docker-entrypoint-initdb.d/init.sql\n\n    # Configure the MariaDB database and create a user with provided name/password.\n    # See https://hub.docker.com/_/mariadb/ for more details.\n    # Default values defined in .env file.\n    environment:\n      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}\n      - MYSQL_USER=${DB_USER}\n      - MYSQL_PASSWORD=${DB_PASSWORD}\n      - MYSQL_DATABASE=${DB_DATABASE}\n\n    # Pass arguments to configure the database\n    command:\n      - \"--character-set-server=utf8mb4\"\n      - \"--collation-server=utf8mb4_bin\"\n      - \"--explicit-defaults-for-timestamp=1\"\n    networks:\n      - bridge\nvolumes:\n  mariadb-data: {}\n  xwiki-data: {}\n"
  },
  {
    "path": "17/mariadb-tomcat/mariadb/init.sql",
    "content": "grant all privileges on *.* to xwiki@'%'"
  },
  {
    "path": "17/mariadb-tomcat/tomcat/setenv.sh",
    "content": "#!/bin/bash\n# ---------------------------------------------------------------------------\n# See the NOTICE file distributed with this work for additional\n# information regarding copyright ownership.\n#\n# This is free software; you can redistribute it and/or modify it\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 2.1 of\n# the License, or (at your option) any later version.\n#\n# This software is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n# Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this software; if not, write to the Free\n# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n# 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n# ---------------------------------------------------------------------------\n\n# We're making the following changes to the default:\n# * Adding more memory (default is 512MB which is not enough for XWiki)\n# * By default, Tomcat does not allow the usage of encoded slash '%2F' and backslash '%5C' in URLs, as noted in\n#   https://tomcat.apache.org/security-6.html#Fixed_in_Apache_Tomcat_6.0.10. We want to allow for them as it's useful to\n#   be able to have '/' and '' in wiki page names.\n# * On some system /dev/random is slow to init leading to a slow Tomcat and thus Xwiki startup.\n\n# Users can override these values by setting the JAVA_OPTS environment variable. For example:\n# -e JAVA_OPTS=\"-Xmx2048m\"\n\nXMX=\"-Xmx1024m\"\nALLOW_ENCODED_SLASH=\"-Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true\"\nALLOW_BACKSLASH=\"-Dorg.apache.catalina.connector.CoyoteAdapter.ALLOW_BACKSLASH=true\"\nSECURERANDOM=\"-Djava.security.egd=file:/dev/./urandom\"\n\nif [[ ! -z \"$JAVA_OPTS\" ]]; then\n  if [[ ! $JAVA_OPTS =~ .*-Xmx[0-9]+.* ]]; then\n    JAVA_OPTS=\"$JAVA_OPTS $XMX\"\n  fi\n  if [[ ! $JAVA_OPTS =~ .*ALLOW_ENCODED_SLASH.* ]]; then\n    JAVA_OPTS=\"$JAVA_OPTS $ALLOW_ENCODED_SLASH\"\n  fi\n  if [[ ! $JAVA_OPTS =~ .*ALLOW_BACKSLASH.* ]]; then\n    JAVA_OPTS=\"$JAVA_OPTS $ALLOW_BACKSLASH\"\n  fi\n  if [[ ! $JAVA_OPTS =~ .*java\\.security\\.egd.* ]]; then\n    JAVA_OPTS=\"$JAVA_OPTS $SECURERANDOM\"\n  fi\nelse\n  JAVA_OPTS=\"$XMX $ALLOW_ENCODED_SLASH $ALLOW_BACKSLASH $SECURERANDOM\"\nfi\n\nexport JAVA_OPTS\n"
  },
  {
    "path": "17/mariadb-tomcat/xwiki/docker-entrypoint.sh",
    "content": "#!/bin/bash\n# ---------------------------------------------------------------------------\n# See the NOTICE file distributed with this work for additional\n# information regarding copyright ownership.\n#\n# This is free software; you can redistribute it and/or modify it\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 2.1 of\n# the License, or (at your option) any later version.\n#\n# This software is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n# Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this software; if not, write to the Free\n# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n# 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n# ---------------------------------------------------------------------------\n\nset -e\n\nfunction first_start() {\n  configure\n  touch /usr/local/tomcat/webapps/$CONTEXT_PATH/.first_start_completed\n}\n\nfunction other_starts() {\n  mkdir -p /usr/local/xwiki/data\n  restoreConfigurationFile 'hibernate.cfg.xml'\n  restoreConfigurationFile 'xwiki.cfg'\n  restoreConfigurationFile 'xwiki.properties'\n}\n\n# $1 - the path to xwiki.[cfg|properties]\n# $2 - the setting/property to set\n# $3 - the new value\nfunction xwiki_replace() {\n  # Don't use \"sed -i\" as it creates a temporary file and perform a rename (thus changing the inode of the initial file)\n  # which makes it fail if you map the initial file as a Docker volume mount.\n  sed s~\"\\#\\? \\?$2 \\?=.*\"~\"$2=$3\"~g \"$1\" > \"$1.old\"\n  cp \"$1.old\" \"$1\"\n  rm \"$1.old\"\n}\n\n# $1 - the setting/property to set\n# $2 - the new value\nfunction xwiki_set_cfg() {\n  xwiki_replace /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/xwiki.cfg \"$1\" \"$2\"\n}\n\n# $1 - the setting/property to set\n# $2 - the new value\nfunction xwiki_set_properties() {\n  xwiki_replace /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/xwiki.properties \"$1\" \"$2\"\n}\n\n# usage: file_env VAR [DEFAULT]\n#    ie: file_env 'XYZ_DB_PASSWORD' 'example'\n# (will allow for \"$XYZ_DB_PASSWORD_FILE\" to fill in the value of\n#  \"$XYZ_DB_PASSWORD\" from a file, especially for Docker's secrets feature)\nfile_env() {\n  local var=\"$1\"\n  local fileVar=\"${var}_FILE\"\n  local def=\"${2:-}\"\n  if [ \"${!var:-}\" ] && [ \"${!fileVar:-}\" ]; then\n    echo >&2 \"error: both $var and $fileVar are set (but are exclusive)\"\n    exit 1\n  fi\n  local val=\"$def\"\n  if [ \"${!var:-}\" ]; then\n    val=\"${!var}\"\n  elif [ \"${!fileVar:-}\" ]; then\n    val=\"$(< \"${!fileVar}\")\"\n  fi\n  export \"$var\"=\"$val\"\n  unset \"$fileVar\"\n}\n\n# Allows to use sed but with user input which can contain special sed characters such as \\, / or &.\n# $1 - the text to search for\n# $2 - the replacement text\n# $3 - the file in which to do the search/replace\nfunction safesed {\n  # Don't use \"sed -i\" as it creates a temporary file and perform a rename (thus changing the inode of the initial file)\n  # which makes it fail if you map the initial file as a Docker volume mount.\n  sed \"s/$(echo $1 | sed -e 's/\\([[\\/.*]\\|\\]\\)/\\\\&/g')/$(echo $2 | sed -e 's/[\\/&]/\\\\&/g')/g\" \"$3\" > \"$3.old\"\n  cp \"$3.old\" \"$3\"\n  rm \"$3.old\"\n}\n\n# $1 - the config file name found in WEB-INF (e.g. \"xwiki.cfg\")\nfunction saveConfigurationFile() {\n  if [ -f \"/usr/local/xwiki/data/$1\" ]; then\n     echo \"  Reusing existing config file $1...\"\n     cp \"/usr/local/xwiki/data/$1\" \"/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1\"\n  fi\n}\n\n# $1 - the config file name to restore in WEB-INF (e.g. \"xwiki.cfg\")\nfunction restoreConfigurationFile() {\n  if [ -f \"/usr/local/xwiki/data/$1\" ]; then\n     echo \"  Synchronizing config file $1...\"\n     cp \"/usr/local/xwiki/data/$1\" \"/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1\"\n  fi\n}\n\nfunction configure() {\n  echo 'Configuring XWiki...'\n\n  echo 'Setting environment variables'\n  file_env 'DB_USER' 'xwiki'\n  file_env 'DB_PASSWORD' 'xwiki'\n  file_env 'DB_HOST' 'db'\n  file_env 'DB_DATABASE' 'xwiki'\n  file_env 'INDEX_HOST' 'localhost'\n  file_env 'INDEX_PORT' '8983'\n  file_env 'JDBC_PARAMS' '?useSSL=false'\n\n  echo \"  Deploying XWiki in the '$CONTEXT_PATH' context\"\n  if [ \"$CONTEXT_PATH\" == \"ROOT\" ]; then\n    xwiki_set_cfg 'xwiki.webapppath' ''\n  else\n    mkdir -p -v /usr/local/tomcat/webapps/$CONTEXT_PATH\n    cp -a --update=none /usr/local/tomcat/webapps/ROOT/.  /usr/local/tomcat/webapps/$CONTEXT_PATH/\n  fi\n\n  echo 'Replacing environment variables in files'\n  safesed \"replaceuser\" $DB_USER /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/hibernate.cfg.xml\n  safesed \"replacepassword\" $DB_PASSWORD /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/hibernate.cfg.xml\n  safesed \"replacecontainer\" $DB_HOST /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/hibernate.cfg.xml\n  safesed \"replacedatabase\" $DB_DATABASE /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/hibernate.cfg.xml\n  safesed \"replacejdbcparams\" $JDBC_PARAMS /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/hibernate.cfg.xml\n\n  # Set any non-default main wiki database name in the xwiki.cfg file.\n  if [ \"$DB_DATABASE\" != \"xwiki\" ]; then\n    xwiki_set_cfg \"xwiki.db\" $DB_DATABASE\n  fi\n\n  echo '  Setting permanent directory...'\n  xwiki_set_properties 'environment.permanentDirectory' '/usr/local/xwiki/data'\n  echo '  Configure libreoffice...'\n  xwiki_set_properties 'openoffice.autoStart' 'true'\n\n  if [ $INDEX_HOST != 'localhost' ]; then\n    echo '  Configuring remote Solr Index'\n    xwiki_set_properties 'solr.type' 'remote'\n    xwiki_set_properties 'solr.remote.url' \"http://$INDEX_HOST:$INDEX_PORT/solr/xwiki\"\n  fi\n\n  # If the files already exist then copy them to the XWiki's WEB-INF directory.\n  mkdir -p /usr/local/xwiki/data\n  saveConfigurationFile 'hibernate.cfg.xml'\n  saveConfigurationFile 'xwiki.cfg'\n  saveConfigurationFile 'xwiki.properties'\n}\n\n# This if will check if the first argument is a flag but only works if all arguments require a hyphenated flag\n# -v; -SL; -f arg; etc will work, but not arg1 arg2\nif [ \"${1:0:1}\" = '-' ]; then\n    set -- xwiki \"$@\"\nfi\n\n# Check for the expected command\nif [ \"$1\" = 'xwiki' ]; then\n  file_env 'CONTEXT_PATH' 'ROOT'\n  if [[ ! -f /usr/local/tomcat/webapps/$CONTEXT_PATH/.first_start_completed ]]; then\n    first_start\n  else\n    other_starts\n  fi\n  shift\n  set -- catalina.sh run \"$@\"\nfi\n\n# Else default to run whatever the user wanted like \"bash\"\nexec \"$@\"\n"
  },
  {
    "path": "17/mariadb-tomcat/xwiki/hibernate.cfg.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<!--\n * See the NOTICE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n-->\n\n<!DOCTYPE hibernate-configuration PUBLIC\n  \"-//Hibernate/Hibernate Configuration DTD//EN\"\n  \"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd\">\n<hibernate-configuration>\n  <session-factory>\n\n    <!-- Please refer to the installation guide on\n         https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Installation/ for configuring your\n         database. You'll need to do 2 things:\n         1) Copy your database driver JAR in WEB-INF/lib or in some shared lib directory\n         2) Uncomment the properties below for your specific DB (and comment the default\n            database configuration if it doesn't match your DB)\n    -->\n\n    <!-- Generic parameters common to all Databases -->\n\n    <property name=\"show_sql\">false</property>\n    <property name=\"use_outer_join\">true</property>\n\n    <!-- Without it, some queries fail in MS SQL. XWiki doesn't need scrollable result sets, anyway. -->\n    <property name=\"jdbc.use_scrollable_resultset\">false</property>\n\n    <!-- DBCP Connection Pooling configuration. Only some properties are shown. All available properties can be found\n         at https://commons.apache.org/proper/commons-dbcp/configuration.html\n    -->\n    <property name=\"dbcp.defaultAutoCommit\">false</property>\n    <property name=\"dbcp.maxTotal\">50</property>\n    <property name=\"dbcp.maxIdle\">5</property>\n    <property name=\"dbcp.maxWaitMillis\">30000</property>\n    <property name=\"connection.provider_class\">com.xpn.xwiki.store.DBCPConnectionProvider</property>\n\n    <!-- Setting \"dbcp.poolPreparedStatements\" to true and \"dbcp.maxOpenPreparedStatements\" will tell DBCP to cache\n         Prepared Statements (it's off by default). Note that for backward compatibility the \"dbcp.ps.maxActive\" is also\n         supported and when set it'll set \"dbcp.poolPreparedStatements\" to true and \"dbcp.maxOpenPreparedStatements\" to\n         value of \"dbcp.ps.maxActive\".\n\n         Note 1: When using HSQLDB for example, it's important to NOT cache prepared statements because HSQLDB\n         Prepared Statements (PS) contain the schema on which they were initially created and thus when switching\n         schema if the same PS is reused it'll execute on the wrong schema! Since HSQLDB does internally cache\n         prepared statement there's no performance loss by not caching Prepared Statements at the DBCP level.\n         See https://jira.xwiki.org/browse/XWIKI-1740.\n         Thus we recommend not turning on this configuration for HSQLDB unless you know what you're doing :)\n\n         Note 2: The same applies to PostGreSQL.\n    -->\n\n    <!-- BoneCP Connection Pooling configuration.\n    <property name=\"bonecp.idleMaxAgeInMinutes\">240</property>\n    <property name=\"bonecp.idleConnectionTestPeriodInMinutes\">60</property>\n    <property name=\"bonecp.partitionCount\">3</property>\n    <property name=\"bonecp.acquireIncrement\">10</property>\n    <property name=\"bonecp.maxConnectionsPerPartition\">60</property>\n    <property name=\"bonecp.minConnectionsPerPartition\">20</property>\n    <property name=\"bonecp.statementsCacheSize\">50</property>\n    <property name=\"bonecp.releaseHelperThreads\">3</property>\n    <property name=\"connection.provider_class\">com.xpn.xwiki.store.DBCPConnectionProvider</property>\n    -->\n\n    <!-- MariaDB configuration.\n         Notes:\n           - If you want the main wiki database to be different than \"xwiki\"\n             you will also have to set the property xwiki.db in xwiki.cfg file\n    -->\n    <property name=\"connection.url\">jdbc:mariadb://replacecontainer/replacedatabasereplacejdbcparams</property>\n    <property name=\"connection.username\">replaceuser</property>\n    <property name=\"connection.password\">replacepassword</property>\n    <property name=\"connection.driver_class\">org.mariadb.jdbc.Driver</property>\n    <property name=\"dbcp.poolPreparedStatements\">true</property>\n    <property name=\"dbcp.maxOpenPreparedStatements\">20</property>\n\n    <property name=\"hibernate.connection.charSet\">UTF-8</property>\n    <property name=\"hibernate.connection.useUnicode\">true</property>\n    <property name=\"hibernate.connection.characterEncoding\">utf8</property>\n\n    <mapping resource=\"xwiki.hbm.xml\"/>\n    <mapping resource=\"feeds.hbm.xml\"/>\n    <mapping resource=\"instance.hbm.xml\"/>\n    <mapping resource=\"notification-filter-preferences.hbm.xml\"/>\n    <mapping resource=\"mailsender.hbm.xml\"/>\n  </session-factory>\n</hibernate-configuration>\n"
  },
  {
    "path": "17/mysql-tomcat/Dockerfile",
    "content": "# ---------------------------------------------------------------------------\n# See the NOTICE file distributed with this work for additional\n# information regarding copyright ownership.\n#\n# This is free software; you can redistribute it and/or modify it\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 2.1 of\n# the License, or (at your option) any later version.\n#\n# This software is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n# Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this software; if not, write to the Free\n# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n# 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n# ---------------------------------------------------------------------------\nFROM tomcat:10-jre21\n\n#    ____  ____  ____      ____  _   __        _\n#   |_  _||_  _||_  _|    |_  _|(_) [  |  _   (_)\n#     \\ \\  / /    \\ \\  /\\  / /  __   | | / ]  __\n#      > `' <      \\ \\/  \\/ /  [  |  | '' <  [  |\n#    _/ /'`\\ \\_     \\  /\\  /    | |  | |`\\ \\  | |\n#   |____||____|     \\/  \\/    [___][__|  \\_][___]\n\nLABEL org.opencontainers.image.authors='XWiki Development Team <committers@xwiki.org>'\nLABEL org.opencontainers.image.url='https://hub.docker.com/_/xwiki'\nLABEL org.opencontainers.image.documentation='https://hub.docker.com/_/xwiki'\nLABEL org.opencontainers.image.source='https://github.com/xwiki/xwiki-docker.git'\nLABEL org.opencontainers.image.vendor='xwiki.org'\nLABEL org.opencontainers.image.licenses='LGPL-2.1'\n\n# Note: when using docker-compose, the ENV values below are overridden from the .env file.\n\n# Install LibreOffice + other tools\n# Note that procps is required to get ps which is used by JODConverter to start LibreOffice\nRUN apt-get update && \\\n  apt-get --no-install-recommends -y install \\\n    curl \\\n    libreoffice \\\n    unzip \\\n    procps && \\\n  rm -rf /var/lib/apt/lists/*\n\n# Install XWiki as the ROOT webapp context in Tomcat\n# Create the Tomcat temporary directory\n# Configure the XWiki permanent directory\nENV XWIKI_VERSION=\"17.10.8\"\nENV XWIKI_URL_PREFIX \"https://maven.xwiki.org/releases/org/xwiki/platform/xwiki-platform-distribution-war/${XWIKI_VERSION}\"\nENV XWIKI_DOWNLOAD_SHA256 f5dfab908fddb6319e64897bb2fc41661dd5b5d8aafa455db72c8a794eaa5287\nRUN rm -rf /usr/local/tomcat/webapps/* && \\\n  mkdir -p /usr/local/tomcat/temp && \\\n  mkdir -p /usr/local/xwiki/data && \\\n  curl -fSL \"${XWIKI_URL_PREFIX}/xwiki-platform-distribution-war-${XWIKI_VERSION}.war\" -o xwiki.war && \\\n  echo \"$XWIKI_DOWNLOAD_SHA256 xwiki.war\" | sha256sum -c - && \\\n  unzip -d /usr/local/tomcat/webapps/ROOT xwiki.war && \\\n  rm -f xwiki.war\n\n# Copy the JDBC driver in the XWiki webapp\n# We take the database driver version from the Maven Central repository since we want to control the version \n# used and have it being consistent with what is tested in the CI.\nENV MYSQL_JDBC_VERSION=\"9.7.0\"\nENV MYSQL_JDBC_SHA256=\"0353648eaa1c91e0f4020c959abf756bc866ffd583df22ae6b6f6e0cbd43eb44\"\nENV MYSQL_JDBC_PREFIX=\"https://repo1.maven.org/maven2/com/mysql/mysql-connector-j/${MYSQL_JDBC_VERSION}\"\nENV MYSQL_JDBC_ARTIFACT=\"mysql-connector-j-${MYSQL_JDBC_VERSION}.jar\"\nENV MYSQL_JDBC_TARGET=\"/usr/local/tomcat/webapps/ROOT/WEB-INF/lib/${MYSQL_JDBC_ARTIFACT}\"\nRUN curl -fSL \"${MYSQL_JDBC_PREFIX}/${MYSQL_JDBC_ARTIFACT}\" -o $MYSQL_JDBC_TARGET && \\\n  echo \"$MYSQL_JDBC_SHA256 $MYSQL_JDBC_TARGET\" | sha256sum -c -\n\n# Configure Tomcat. For example set the memory for the Tomcat JVM since the default value is too small for XWiki\nCOPY tomcat/setenv.sh /usr/local/tomcat/bin/\n\n# Setup the XWiki Hibernate configuration\nCOPY xwiki/hibernate.cfg.xml /usr/local/tomcat/webapps/ROOT/WEB-INF/hibernate.cfg.xml\n\n# Set a specific distribution id in XWiki for this docker packaging.\nRUN sed -i 's/<id>org.xwiki.platform:xwiki-platform-distribution-war/<id>org.xwiki.platform:xwiki-platform-distribution-docker/' \\\n  /usr/local/tomcat/webapps/ROOT/META-INF/extension.xed\n\n# Add scripts required to make changes to XWiki configuration files at execution time\n# Note: we don't run CHMOD since 1) it's not required since the executabe bit is already set in git and 2) running\n# CHMOD after a COPY will sometimes fail, depending on different host-specific factors (especially on AUFS).\nCOPY xwiki/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh\n\n# Make the XWiki directory (the permanent directory is included in it) persist on the host (so that it's not recreated\n# across runs)\nVOLUME /usr/local/xwiki\n\n# At this point the image is done and what remains below are the runtime configuration used by the user to configure\n# the container that will be created out of the image. Namely the user can override some environment variables with\n#   docker run -e \"var1=val1\" -e \"var2=val2\" ...\n# The supported environment variables that can be overridden are:\n# - DB_USER: the name of the user configured for XWiki in the DB. Default is \"xwiki\". This is used to configure\n#            xwiki's hibernate.cfg.xml file.\n# - DB_PASSWORD: the password for the user configured for XWiki in the DB. Default is \"xwiki\". This is used to\n#                configure xwiki's hibernate.cfg.xml file.\n# - DB_DATABASE: the name of the database to use. Default is \"xwiki\". This is used to configure xwiki's\n#                hibernate.cfg.xml file.\n# - DB_HOST: The name of the host (or docker container) containing the database. Default is \"db\". This is used to\n#            configure xwiki's hibernate.cfg.xml file.\n# - CONTEXT_PATH: The name of the context path under which XWiki will be deployed in Tomcat. If not specified then it'll\n#                 be deployed as ROOT.\n# - JDBC_PARAMS: Replaces the default JDBC parameters with the passed ones.\n\n# Example:\n#   docker run -it -e \"DB_USER=xwiki\" -e \"DB_PASSWORD=xwiki\" <imagename>\n\n# Starts XWiki by starting Tomcat. All options passed to \"docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]\"\n# are also passed to docker-entrypoint.sh. If \"xwiki\" is passed then XWiki will be configured the first time the\n# container executes and Tomcat will be started. If some other parameter is passed then it'll be executed to comply\n# with best practices defined at https://github.com/docker-library/official-images#consistency.\nENTRYPOINT [\"docker-entrypoint.sh\"]\nCMD [\"xwiki\"]\n"
  },
  {
    "path": "17/mysql-tomcat/docker-compose.yml",
    "content": "# ---------------------------------------------------------------------------\n# See the NOTICE file distributed with this work for additional\n# information regarding copyright ownership.\n#\n# This is free software; you can redistribute it and/or modify it\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 2.1 of\n# the License, or (at your option) any later version.\n#\n# This software is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n# Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this software; if not, write to the Free\n# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n# 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n# ---------------------------------------------------------------------------\nversion: '2'\nnetworks:\n  bridge:\n    driver: bridge\nservices:\n  # The container that runs XWiki in Tomcat, with the appropriate JDBC driver (for mysql).\n  web:\n    image: \"xwiki:${XWIKI_VERSION}-mysql-tomcat\"\n    container_name: xwiki-mysql-tomcat-web\n    depends_on:\n      - db\n    ports:\n      - \"8080:8080\"\n    # Default values defined in .env file.\n    # The DB_USER/DB_PASSWORD/DB_DATABASE/DB_HOST variables are used in the hibernate.cfg.xml file.\n    environment:\n      - XWIKI_VERSION=${XWIKI_VERSION}\n      - DB_USER=${DB_USER}\n      - DB_PASSWORD=${DB_PASSWORD}\n      - DB_DATABASE=${DB_DATABASE}\n      - DB_HOST=xwiki-mysql-db\n    # Provide a name instead of an auto-generated id for xwiki data (the permanent directory in included in it)\n    # configured in the Dockerfile, to make it simpler to identify in 'docker volume ls'.\n    volumes:\n      - xwiki-data:/usr/local/xwiki\n    networks:\n      - bridge\n  # The container that runs the database (mysql)\n  db:\n    image: \"mysql:9\"\n    container_name: xwiki-mysql-db\n    # - Provide a name instead of an auto-generated id for the mysql data, to make it simpler to identify in\n    # 'docker volume ls'\n    # - Provide a SQL script to be executed when the db image starts (to set permissions to create subwikis)\n    volumes:\n      - mysql-data:/var/lib/mysql\n      - ./init.sql:/docker-entrypoint-initdb.d/init.sql\n\n    # Configure the MySQL database and create a user with provided name/password.\n    # See https://hub.docker.com/_/mysql/ for more details.\n    # Default values defined in .env file.\n    environment:\n      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}\n      - MYSQL_USER=${DB_USER}\n      - MYSQL_PASSWORD=${DB_PASSWORD}\n      - MYSQL_DATABASE=${DB_DATABASE}\n\n    # Pass arguments to configure the database\n    command:\n      - \"--character-set-server=utf8mb4\"\n      - \"--collation-server=utf8mb4_bin\"\n      - \"--explicit-defaults-for-timestamp=1\"\n    networks:\n      - bridge\nvolumes:\n  mysql-data: {}\n  xwiki-data: {}\n"
  },
  {
    "path": "17/mysql-tomcat/mysql/init.sql",
    "content": "grant all privileges on *.* to xwiki@'%'"
  },
  {
    "path": "17/mysql-tomcat/tomcat/setenv.sh",
    "content": "#!/bin/bash\n# ---------------------------------------------------------------------------\n# See the NOTICE file distributed with this work for additional\n# information regarding copyright ownership.\n#\n# This is free software; you can redistribute it and/or modify it\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 2.1 of\n# the License, or (at your option) any later version.\n#\n# This software is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n# Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this software; if not, write to the Free\n# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n# 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n# ---------------------------------------------------------------------------\n\n# We're making the following changes to the default:\n# * Adding more memory (default is 512MB which is not enough for XWiki)\n# * By default, Tomcat does not allow the usage of encoded slash '%2F' and backslash '%5C' in URLs, as noted in\n#   https://tomcat.apache.org/security-6.html#Fixed_in_Apache_Tomcat_6.0.10. We want to allow for them as it's useful to\n#   be able to have '/' and '' in wiki page names.\n# * On some system /dev/random is slow to init leading to a slow Tomcat and thus Xwiki startup.\n\n# Users can override these values by setting the JAVA_OPTS environment variable. For example:\n# -e JAVA_OPTS=\"-Xmx2048m\"\n\nXMX=\"-Xmx1024m\"\nALLOW_ENCODED_SLASH=\"-Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true\"\nALLOW_BACKSLASH=\"-Dorg.apache.catalina.connector.CoyoteAdapter.ALLOW_BACKSLASH=true\"\nSECURERANDOM=\"-Djava.security.egd=file:/dev/./urandom\"\n\nif [[ ! -z \"$JAVA_OPTS\" ]]; then\n  if [[ ! $JAVA_OPTS =~ .*-Xmx[0-9]+.* ]]; then\n    JAVA_OPTS=\"$JAVA_OPTS $XMX\"\n  fi\n  if [[ ! $JAVA_OPTS =~ .*ALLOW_ENCODED_SLASH.* ]]; then\n    JAVA_OPTS=\"$JAVA_OPTS $ALLOW_ENCODED_SLASH\"\n  fi\n  if [[ ! $JAVA_OPTS =~ .*ALLOW_BACKSLASH.* ]]; then\n    JAVA_OPTS=\"$JAVA_OPTS $ALLOW_BACKSLASH\"\n  fi\n  if [[ ! $JAVA_OPTS =~ .*java\\.security\\.egd.* ]]; then\n    JAVA_OPTS=\"$JAVA_OPTS $SECURERANDOM\"\n  fi\nelse\n  JAVA_OPTS=\"$XMX $ALLOW_ENCODED_SLASH $ALLOW_BACKSLASH $SECURERANDOM\"\nfi\n\nexport JAVA_OPTS\n"
  },
  {
    "path": "17/mysql-tomcat/xwiki/docker-entrypoint.sh",
    "content": "#!/bin/bash\n# ---------------------------------------------------------------------------\n# See the NOTICE file distributed with this work for additional\n# information regarding copyright ownership.\n#\n# This is free software; you can redistribute it and/or modify it\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 2.1 of\n# the License, or (at your option) any later version.\n#\n# This software is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n# Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this software; if not, write to the Free\n# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n# 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n# ---------------------------------------------------------------------------\n\nset -e\n\nfunction first_start() {\n  configure\n  touch /usr/local/tomcat/webapps/$CONTEXT_PATH/.first_start_completed\n}\n\nfunction other_starts() {\n  mkdir -p /usr/local/xwiki/data\n  restoreConfigurationFile 'hibernate.cfg.xml'\n  restoreConfigurationFile 'xwiki.cfg'\n  restoreConfigurationFile 'xwiki.properties'\n}\n\n# $1 - the path to xwiki.[cfg|properties]\n# $2 - the setting/property to set\n# $3 - the new value\nfunction xwiki_replace() {\n  # Don't use \"sed -i\" as it creates a temporary file and perform a rename (thus changing the inode of the initial file)\n  # which makes it fail if you map the initial file as a Docker volume mount.\n  sed s~\"\\#\\? \\?$2 \\?=.*\"~\"$2=$3\"~g \"$1\" > \"$1.old\"\n  cp \"$1.old\" \"$1\"\n  rm \"$1.old\"\n}\n\n# $1 - the setting/property to set\n# $2 - the new value\nfunction xwiki_set_cfg() {\n  xwiki_replace /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/xwiki.cfg \"$1\" \"$2\"\n}\n\n# $1 - the setting/property to set\n# $2 - the new value\nfunction xwiki_set_properties() {\n  xwiki_replace /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/xwiki.properties \"$1\" \"$2\"\n}\n\n# usage: file_env VAR [DEFAULT]\n#    ie: file_env 'XYZ_DB_PASSWORD' 'example'\n# (will allow for \"$XYZ_DB_PASSWORD_FILE\" to fill in the value of\n#  \"$XYZ_DB_PASSWORD\" from a file, especially for Docker's secrets feature)\nfile_env() {\n  local var=\"$1\"\n  local fileVar=\"${var}_FILE\"\n  local def=\"${2:-}\"\n  if [ \"${!var:-}\" ] && [ \"${!fileVar:-}\" ]; then\n    echo >&2 \"error: both $var and $fileVar are set (but are exclusive)\"\n    exit 1\n  fi\n  local val=\"$def\"\n  if [ \"${!var:-}\" ]; then\n    val=\"${!var}\"\n  elif [ \"${!fileVar:-}\" ]; then\n    val=\"$(< \"${!fileVar}\")\"\n  fi\n  export \"$var\"=\"$val\"\n  unset \"$fileVar\"\n}\n\n# Allows to use sed but with user input which can contain special sed characters such as \\, / or &.\n# $1 - the text to search for\n# $2 - the replacement text\n# $3 - the file in which to do the search/replace\nfunction safesed {\n  # Don't use \"sed -i\" as it creates a temporary file and perform a rename (thus changing the inode of the initial file)\n  # which makes it fail if you map the initial file as a Docker volume mount.\n  sed \"s/$(echo $1 | sed -e 's/\\([[\\/.*]\\|\\]\\)/\\\\&/g')/$(echo $2 | sed -e 's/[\\/&]/\\\\&/g')/g\" \"$3\" > \"$3.old\"\n  cp \"$3.old\" \"$3\"\n  rm \"$3.old\"\n}\n\n# $1 - the config file name found in WEB-INF (e.g. \"xwiki.cfg\")\nfunction saveConfigurationFile() {\n  if [ -f \"/usr/local/xwiki/data/$1\" ]; then\n     echo \"  Reusing existing config file $1...\"\n     cp \"/usr/local/xwiki/data/$1\" \"/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1\"\n  fi\n}\n\n# $1 - the config file name to restore in WEB-INF (e.g. \"xwiki.cfg\")\nfunction restoreConfigurationFile() {\n  if [ -f \"/usr/local/xwiki/data/$1\" ]; then\n     echo \"  Synchronizing config file $1...\"\n     cp \"/usr/local/xwiki/data/$1\" \"/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1\"\n  fi\n}\n\nfunction configure() {\n  echo 'Configuring XWiki...'\n\n  echo 'Setting environment variables'\n  file_env 'DB_USER' 'xwiki'\n  file_env 'DB_PASSWORD' 'xwiki'\n  file_env 'DB_HOST' 'db'\n  file_env 'DB_DATABASE' 'xwiki'\n  file_env 'INDEX_HOST' 'localhost'\n  file_env 'INDEX_PORT' '8983'\n  file_env 'JDBC_PARAMS' '?useSSL=false&amp;connectionTimeZone=LOCAL&amp;allowPublicKeyRetrieval=true'\n\n  echo \"  Deploying XWiki in the '$CONTEXT_PATH' context\"\n  if [ \"$CONTEXT_PATH\" == \"ROOT\" ]; then\n    xwiki_set_cfg 'xwiki.webapppath' ''\n  else\n    mkdir -p -v /usr/local/tomcat/webapps/$CONTEXT_PATH\n    cp -a --update=none /usr/local/tomcat/webapps/ROOT/.  /usr/local/tomcat/webapps/$CONTEXT_PATH/\n  fi\n\n  echo 'Replacing environment variables in files'\n  safesed \"replaceuser\" $DB_USER /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/hibernate.cfg.xml\n  safesed \"replacepassword\" $DB_PASSWORD /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/hibernate.cfg.xml\n  safesed \"replacecontainer\" $DB_HOST /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/hibernate.cfg.xml\n  safesed \"replacedatabase\" $DB_DATABASE /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/hibernate.cfg.xml\n  safesed \"replacejdbcparams\" $JDBC_PARAMS /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/hibernate.cfg.xml\n\n  # Set any non-default main wiki database name in the xwiki.cfg file.\n  if [ \"$DB_DATABASE\" != \"xwiki\" ]; then\n    xwiki_set_cfg \"xwiki.db\" $DB_DATABASE\n  fi\n\n  echo '  Setting permanent directory...'\n  xwiki_set_properties 'environment.permanentDirectory' '/usr/local/xwiki/data'\n  echo '  Configure libreoffice...'\n  xwiki_set_properties 'openoffice.autoStart' 'true'\n\n  if [ $INDEX_HOST != 'localhost' ]; then\n    echo '  Configuring remote Solr Index'\n    xwiki_set_properties 'solr.type' 'remote'\n    xwiki_set_properties 'solr.remote.url' \"http://$INDEX_HOST:$INDEX_PORT/solr/xwiki\"\n  fi\n\n  # If the files already exist then copy them to the XWiki's WEB-INF directory.\n  mkdir -p /usr/local/xwiki/data\n  saveConfigurationFile 'hibernate.cfg.xml'\n  saveConfigurationFile 'xwiki.cfg'\n  saveConfigurationFile 'xwiki.properties'\n}\n\n# This if will check if the first argument is a flag but only works if all arguments require a hyphenated flag\n# -v; -SL; -f arg; etc will work, but not arg1 arg2\nif [ \"${1:0:1}\" = '-' ]; then\n    set -- xwiki \"$@\"\nfi\n\n# Check for the expected command\nif [ \"$1\" = 'xwiki' ]; then\n  file_env 'CONTEXT_PATH' 'ROOT'\n  if [[ ! -f /usr/local/tomcat/webapps/$CONTEXT_PATH/.first_start_completed ]]; then\n    first_start\n  else\n    other_starts\n  fi\n  shift\n  set -- catalina.sh run \"$@\"\nfi\n\n# Else default to run whatever the user wanted like \"bash\"\nexec \"$@\"\n"
  },
  {
    "path": "17/mysql-tomcat/xwiki/hibernate.cfg.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<!--\n * See the NOTICE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n-->\n\n<!DOCTYPE hibernate-configuration PUBLIC\n  \"-//Hibernate/Hibernate Configuration DTD//EN\"\n  \"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd\">\n<hibernate-configuration>\n  <session-factory>\n\n    <!-- Please refer to the installation guide on\n         https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Installation/ for configuring your\n         database. You'll need to do 2 things:\n         1) Copy your database driver JAR in WEB-INF/lib or in some shared lib directory\n         2) Uncomment the properties below for your specific DB (and comment the default\n            database configuration if it doesn't match your DB)\n    -->\n\n    <!-- Generic parameters common to all Databases -->\n\n    <property name=\"show_sql\">false</property>\n    <property name=\"use_outer_join\">true</property>\n\n    <!-- Without it, some queries fail in MS SQL. XWiki doesn't need scrollable result sets, anyway. -->\n    <property name=\"jdbc.use_scrollable_resultset\">false</property>\n\n    <!-- DBCP Connection Pooling configuration. Only some properties are shown. All available properties can be found\n         at https://commons.apache.org/proper/commons-dbcp/configuration.html\n    -->\n    <property name=\"dbcp.defaultAutoCommit\">false</property>\n    <property name=\"dbcp.maxTotal\">50</property>\n    <property name=\"dbcp.maxIdle\">5</property>\n    <property name=\"dbcp.maxWaitMillis\">30000</property>\n    <property name=\"connection.provider_class\">com.xpn.xwiki.store.DBCPConnectionProvider</property>\n\n    <!-- Setting \"dbcp.poolPreparedStatements\" to true and \"dbcp.maxOpenPreparedStatements\" will tell DBCP to cache\n         Prepared Statements (it's off by default). Note that for backward compatibility the \"dbcp.ps.maxActive\" is also\n         supported and when set it'll set \"dbcp.poolPreparedStatements\" to true and \"dbcp.maxOpenPreparedStatements\" to\n         value of \"dbcp.ps.maxActive\".\n\n         Note 1: When using HSQLDB for example, it's important to NOT cache prepared statements because HSQLDB\n         Prepared Statements (PS) contain the schema on which they were initially created and thus when switching\n         schema if the same PS is reused it'll execute on the wrong schema! Since HSQLDB does internally cache\n         prepared statement there's no performance loss by not caching Prepared Statements at the DBCP level.\n         See https://jira.xwiki.org/browse/XWIKI-1740.\n         Thus we recommend not turning on this configuration for HSQLDB unless you know what you're doing :)\n\n         Note 2: The same applies to PostGreSQL.\n    -->\n\n    <!-- BoneCP Connection Pooling configuration.\n    <property name=\"bonecp.idleMaxAgeInMinutes\">240</property>\n    <property name=\"bonecp.idleConnectionTestPeriodInMinutes\">60</property>\n    <property name=\"bonecp.partitionCount\">3</property>\n    <property name=\"bonecp.acquireIncrement\">10</property>\n    <property name=\"bonecp.maxConnectionsPerPartition\">60</property>\n    <property name=\"bonecp.minConnectionsPerPartition\">20</property>\n    <property name=\"bonecp.statementsCacheSize\">50</property>\n    <property name=\"bonecp.releaseHelperThreads\">3</property>\n    <property name=\"connection.provider_class\">com.xpn.xwiki.store.DBCPConnectionProvider</property>\n    -->\n\n    <!-- MySQL configuration.\n         Notes:\n           - If you want the main wiki database to be different than \"xwiki\"\n             you will also have to set the property xwiki.db in xwiki.cfg file\n           - Use the local timezone to work around a bug in the MySQL 8.x which often does not understand the server\n              timezone and crash\n    -->\n    <property name=\"connection.url\">jdbc:mysql://replacecontainer/replacedatabasereplacejdbcparams</property>\n    <property name=\"connection.username\">replaceuser</property>\n    <property name=\"connection.password\">replacepassword</property>\n    <property name=\"connection.driver_class\">com.mysql.cj.jdbc.Driver</property>\n    <property name=\"dbcp.poolPreparedStatements\">true</property>\n    <property name=\"dbcp.maxOpenPreparedStatements\">20</property>\n\n    <property name=\"hibernate.connection.charSet\">UTF-8</property>\n    <property name=\"hibernate.connection.useUnicode\">true</property>\n    <property name=\"hibernate.connection.characterEncoding\">utf8</property>\n\n    <mapping resource=\"xwiki.hbm.xml\"/>\n    <mapping resource=\"feeds.hbm.xml\"/>\n    <mapping resource=\"instance.hbm.xml\"/>\n    <mapping resource=\"notification-filter-preferences.hbm.xml\"/>\n    <mapping resource=\"mailsender.hbm.xml\"/>\n  </session-factory>\n</hibernate-configuration>\n"
  },
  {
    "path": "17/postgres-tomcat/Dockerfile",
    "content": "# ---------------------------------------------------------------------------\n# See the NOTICE file distributed with this work for additional\n# information regarding copyright ownership.\n#\n# This is free software; you can redistribute it and/or modify it\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 2.1 of\n# the License, or (at your option) any later version.\n#\n# This software is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n# Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this software; if not, write to the Free\n# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n# 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n# ---------------------------------------------------------------------------\nFROM tomcat:10-jre21\n\n#    ____  ____  ____      ____  _   __        _\n#   |_  _||_  _||_  _|    |_  _|(_) [  |  _   (_)\n#     \\ \\  / /    \\ \\  /\\  / /  __   | | / ]  __\n#      > `' <      \\ \\/  \\/ /  [  |  | '' <  [  |\n#    _/ /'`\\ \\_     \\  /\\  /    | |  | |`\\ \\  | |\n#   |____||____|     \\/  \\/    [___][__|  \\_][___]\n\nLABEL org.opencontainers.image.authors='XWiki Development Team <committers@xwiki.org>'\nLABEL org.opencontainers.image.url='https://hub.docker.com/_/xwiki'\nLABEL org.opencontainers.image.documentation='https://hub.docker.com/_/xwiki'\nLABEL org.opencontainers.image.source='https://github.com/xwiki/xwiki-docker.git'\nLABEL org.opencontainers.image.vendor='xwiki.org'\nLABEL org.opencontainers.image.licenses='LGPL-2.1'\n\n# Note: when using docker-compose, the ENV values below are overridden from the .env file.\n\n# Install LibreOffice + other tools\n# Note that procps is required to get ps which is used by JODConverter to start LibreOffice\nRUN apt-get update && \\\n  apt-get --no-install-recommends -y install \\\n    curl \\\n    libreoffice \\\n    unzip \\\n    procps && \\\n  rm -rf /var/lib/apt/lists/*\n\n# Install XWiki as the ROOT webapp context in Tomcat\n# Create the Tomcat temporary directory\n# Configure the XWiki permanent directory\nENV XWIKI_VERSION=\"17.10.8\"\nENV XWIKI_URL_PREFIX \"https://maven.xwiki.org/releases/org/xwiki/platform/xwiki-platform-distribution-war/${XWIKI_VERSION}\"\nENV XWIKI_DOWNLOAD_SHA256 f5dfab908fddb6319e64897bb2fc41661dd5b5d8aafa455db72c8a794eaa5287\nRUN rm -rf /usr/local/tomcat/webapps/* && \\\n  mkdir -p /usr/local/tomcat/temp && \\\n  mkdir -p /usr/local/xwiki/data && \\\n  curl -fSL \"${XWIKI_URL_PREFIX}/xwiki-platform-distribution-war-${XWIKI_VERSION}.war\" -o xwiki.war && \\\n  echo \"$XWIKI_DOWNLOAD_SHA256 xwiki.war\" | sha256sum -c - && \\\n  unzip -d /usr/local/tomcat/webapps/ROOT xwiki.war && \\\n  rm -f xwiki.war\n\n# Copy the JDBC driver in the XWiki webapp\n# We take the database driver version from the Maven Central repository since we want to control the version \n# used and have it being consistent with what is tested in the CI.\nENV POSTGRES_JDBC_VERSION=\"42.7.11\"\nENV POSTGRES_JDBC_SHA256=\"1981b31d3993c58702783c1cddf10a34e48c1f413d70ff1cb6def0a143484647\"\nENV POSTGRES_JDBC_PREFIX=\"https://repo1.maven.org/maven2/org/postgresql/postgresql/${POSTGRES_JDBC_VERSION}\"\nENV POSTGRES_JDBC_ARTIFACT=\"postgresql-${POSTGRES_JDBC_VERSION}.jar\"\nENV POSTGRES_JDBC_TARGET=\"/usr/local/tomcat/webapps/ROOT/WEB-INF/lib/${POSTGRES_JDBC_ARTIFACT}\"\nRUN curl -fSL \"${POSTGRES_JDBC_PREFIX}/${POSTGRES_JDBC_ARTIFACT}\" -o $POSTGRES_JDBC_TARGET && \\\n  echo \"$POSTGRES_JDBC_SHA256 $POSTGRES_JDBC_TARGET\" | sha256sum -c -\n\n# Configure Tomcat. For example set the memory for the Tomcat JVM since the default value is too small for XWiki\nCOPY tomcat/setenv.sh /usr/local/tomcat/bin/\n\n# Setup the XWiki Hibernate configuration\nCOPY xwiki/hibernate.cfg.xml /usr/local/tomcat/webapps/ROOT/WEB-INF/hibernate.cfg.xml\n\n# Set a specific distribution id in XWiki for this docker packaging.\nRUN sed -i 's/<id>org.xwiki.platform:xwiki-platform-distribution-war/<id>org.xwiki.platform:xwiki-platform-distribution-docker/' \\\n  /usr/local/tomcat/webapps/ROOT/META-INF/extension.xed\n\n# Add scripts required to make changes to XWiki configuration files at execution time\n# Note: we don't run CHMOD since 1) it's not required since the executabe bit is already set in git and 2) running\n# CHMOD after a COPY will sometimes fail, depending on different host-specific factors (especially on AUFS).\nCOPY xwiki/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh\n\n# Make the XWiki directory (the permanent directory is included in it) persist on the host (so that it's not recreated\n# across runs)\nVOLUME /usr/local/xwiki\n\n# At this point the image is done and what remains below are the runtime configuration used by the user to configure\n# the container that will be created out of the image. Namely the user can override some environment variables with\n#   docker run -e \"var1=val1\" -e \"var2=val2\" ...\n# The supported environment variables that can be overridden are:\n# - DB_USER: the name of the user configured for XWiki in the DB. Default is \"xwiki\". This is used to configure\n#            xwiki's hibernate.cfg.xml file.\n# - DB_PASSWORD: the password for the user configured for XWiki in the DB. Default is \"xwiki\". This is used to\n#                configure xwiki's hibernate.cfg.xml file.\n# - DB_DATABASE: the name of the database to use. Default is \"xwiki\". This is used to configure xwiki's\n#                hibernate.cfg.xml file.\n# - DB_HOST: The name of the host (or docker container) containing the database. Default is \"db\". This is used to\n#            configure xwiki's hibernate.cfg.xml file.\n# - CONTEXT_PATH: The name of the context path under which XWiki will be deployed in Tomcat. If not specified then it'll\n#                 be deployed as ROOT.\n# - JDBC_PARAMS: Replaces the default JDBC parameters with the passed ones.\n\n# Example:\n#   docker run -it -e \"DB_USER=xwiki\" -e \"DB_PASSWORD=xwiki\" <imagename>\n\n# Starts XWiki by starting Tomcat. All options passed to \"docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]\"\n# are also passed to docker-entrypoint.sh. If \"xwiki\" is passed then XWiki will be configured the first time the\n# container executes and Tomcat will be started. If some other parameter is passed then it'll be executed to comply\n# with best practices defined at https://github.com/docker-library/official-images#consistency.\nENTRYPOINT [\"docker-entrypoint.sh\"]\nCMD [\"xwiki\"]\n"
  },
  {
    "path": "17/postgres-tomcat/docker-compose.yml",
    "content": "# ---------------------------------------------------------------------------\n# See the NOTICE file distributed with this work for additional\n# information regarding copyright ownership.\n#\n# This is free software; you can redistribute it and/or modify it\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 2.1 of\n# the License, or (at your option) any later version.\n#\n# This software is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n# Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this software; if not, write to the Free\n# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n# 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n# ---------------------------------------------------------------------------\nversion: '2'\nnetworks:\n  bridge:\n    driver: bridge\nservices:\n  # The container that runs XWiki in Tomcat, with the appropriate JDBC driver (for postgres).\n  web:\n    image: \"xwiki:${XWIKI_VERSION}-postgres-tomcat\"\n    container_name: xwiki-postgres-tomcat-web\n    depends_on:\n      - db\n    ports:\n      - \"8080:8080\"\n    # Default values defined in .env file.\n    # The DB_USER/DB_PASSWORD/DB_DATABASE/DB_HOST variables are used in the hibernate.cfg.xml file.\n    environment:\n      - XWIKI_VERSION=${XWIKI_VERSION}\n      - DB_USER=${DB_USER}\n      - DB_PASSWORD=${DB_PASSWORD}\n      - DB_DATABASE=${DB_DATABASE}\n      - DB_HOST=xwiki-postgres-db\n    # Provide a name instead of an auto-generated id for xwiki data (the permanent directory in included in it)\n    # configured in the Dockerfile, to make it simpler to identify in 'docker volume ls'.\n    volumes:\n      - xwiki-data:/usr/local/xwiki\n    networks:\n      - bridge\n  # The container that runs the database (postgres)\n  db:\n    image: \"postgres:18\"\n    container_name: xwiki-postgres-db\n    volumes:\n      - postgres-data:/var/lib/postgresql\n    environment:\n      - POSTGRES_ROOT_PASSWORD=${POSTGRES_ROOT_PASSWORD}\n      - POSTGRES_PASSWORD=${DB_PASSWORD}\n      - POSTGRES_USER=${DB_USER}\n      - POSTGRES_DB=${DB_DATABASE}\n      - POSTGRES_INITDB_ARGS=--encoding=UTF8 --locale-provider=builtin --locale=C.UTF-8\n    networks:\n      - bridge\nvolumes:\n  postgres-data: {}\n  xwiki-data: {}\n"
  },
  {
    "path": "17/postgres-tomcat/tomcat/setenv.sh",
    "content": "#!/bin/bash\n# ---------------------------------------------------------------------------\n# See the NOTICE file distributed with this work for additional\n# information regarding copyright ownership.\n#\n# This is free software; you can redistribute it and/or modify it\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 2.1 of\n# the License, or (at your option) any later version.\n#\n# This software is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n# Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this software; if not, write to the Free\n# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n# 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n# ---------------------------------------------------------------------------\n\n# We're making the following changes to the default:\n# * Adding more memory (default is 512MB which is not enough for XWiki)\n# * By default, Tomcat does not allow the usage of encoded slash '%2F' and backslash '%5C' in URLs, as noted in\n#   https://tomcat.apache.org/security-6.html#Fixed_in_Apache_Tomcat_6.0.10. We want to allow for them as it's useful to\n#   be able to have '/' and '' in wiki page names.\n# * On some system /dev/random is slow to init leading to a slow Tomcat and thus Xwiki startup.\n\n# Users can override these values by setting the JAVA_OPTS environment variable. For example:\n# -e JAVA_OPTS=\"-Xmx2048m\"\n\nXMX=\"-Xmx1024m\"\nALLOW_ENCODED_SLASH=\"-Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true\"\nALLOW_BACKSLASH=\"-Dorg.apache.catalina.connector.CoyoteAdapter.ALLOW_BACKSLASH=true\"\nSECURERANDOM=\"-Djava.security.egd=file:/dev/./urandom\"\n\nif [[ ! -z \"$JAVA_OPTS\" ]]; then\n  if [[ ! $JAVA_OPTS =~ .*-Xmx[0-9]+.* ]]; then\n    JAVA_OPTS=\"$JAVA_OPTS $XMX\"\n  fi\n  if [[ ! $JAVA_OPTS =~ .*ALLOW_ENCODED_SLASH.* ]]; then\n    JAVA_OPTS=\"$JAVA_OPTS $ALLOW_ENCODED_SLASH\"\n  fi\n  if [[ ! $JAVA_OPTS =~ .*ALLOW_BACKSLASH.* ]]; then\n    JAVA_OPTS=\"$JAVA_OPTS $ALLOW_BACKSLASH\"\n  fi\n  if [[ ! $JAVA_OPTS =~ .*java\\.security\\.egd.* ]]; then\n    JAVA_OPTS=\"$JAVA_OPTS $SECURERANDOM\"\n  fi\nelse\n  JAVA_OPTS=\"$XMX $ALLOW_ENCODED_SLASH $ALLOW_BACKSLASH $SECURERANDOM\"\nfi\n\nexport JAVA_OPTS\n"
  },
  {
    "path": "17/postgres-tomcat/xwiki/docker-entrypoint.sh",
    "content": "#!/bin/bash\n# ---------------------------------------------------------------------------\n# See the NOTICE file distributed with this work for additional\n# information regarding copyright ownership.\n#\n# This is free software; you can redistribute it and/or modify it\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 2.1 of\n# the License, or (at your option) any later version.\n#\n# This software is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n# Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this software; if not, write to the Free\n# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n# 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n# ---------------------------------------------------------------------------\n\nset -e\n\nfunction first_start() {\n  configure\n  touch /usr/local/tomcat/webapps/$CONTEXT_PATH/.first_start_completed\n}\n\nfunction other_starts() {\n  mkdir -p /usr/local/xwiki/data\n  restoreConfigurationFile 'hibernate.cfg.xml'\n  restoreConfigurationFile 'xwiki.cfg'\n  restoreConfigurationFile 'xwiki.properties'\n}\n\n# $1 - the path to xwiki.[cfg|properties]\n# $2 - the setting/property to set\n# $3 - the new value\nfunction xwiki_replace() {\n  # Don't use \"sed -i\" as it creates a temporary file and perform a rename (thus changing the inode of the initial file)\n  # which makes it fail if you map the initial file as a Docker volume mount.\n  sed s~\"\\#\\? \\?$2 \\?=.*\"~\"$2=$3\"~g \"$1\" > \"$1.old\"\n  cp \"$1.old\" \"$1\"\n  rm \"$1.old\"\n}\n\n# $1 - the setting/property to set\n# $2 - the new value\nfunction xwiki_set_cfg() {\n  xwiki_replace /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/xwiki.cfg \"$1\" \"$2\"\n}\n\n# $1 - the setting/property to set\n# $2 - the new value\nfunction xwiki_set_properties() {\n  xwiki_replace /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/xwiki.properties \"$1\" \"$2\"\n}\n\n# usage: file_env VAR [DEFAULT]\n#    ie: file_env 'XYZ_DB_PASSWORD' 'example'\n# (will allow for \"$XYZ_DB_PASSWORD_FILE\" to fill in the value of\n#  \"$XYZ_DB_PASSWORD\" from a file, especially for Docker's secrets feature)\nfile_env() {\n  local var=\"$1\"\n  local fileVar=\"${var}_FILE\"\n  local def=\"${2:-}\"\n  if [ \"${!var:-}\" ] && [ \"${!fileVar:-}\" ]; then\n    echo >&2 \"error: both $var and $fileVar are set (but are exclusive)\"\n    exit 1\n  fi\n  local val=\"$def\"\n  if [ \"${!var:-}\" ]; then\n    val=\"${!var}\"\n  elif [ \"${!fileVar:-}\" ]; then\n    val=\"$(< \"${!fileVar}\")\"\n  fi\n  export \"$var\"=\"$val\"\n  unset \"$fileVar\"\n}\n\n# Allows to use sed but with user input which can contain special sed characters such as \\, / or &.\n# $1 - the text to search for\n# $2 - the replacement text\n# $3 - the file in which to do the search/replace\nfunction safesed {\n  # Don't use \"sed -i\" as it creates a temporary file and perform a rename (thus changing the inode of the initial file)\n  # which makes it fail if you map the initial file as a Docker volume mount.\n  sed \"s/$(echo $1 | sed -e 's/\\([[\\/.*]\\|\\]\\)/\\\\&/g')/$(echo $2 | sed -e 's/[\\/&]/\\\\&/g')/g\" \"$3\" > \"$3.old\"\n  cp \"$3.old\" \"$3\"\n  rm \"$3.old\"\n}\n\n# $1 - the config file name found in WEB-INF (e.g. \"xwiki.cfg\")\nfunction saveConfigurationFile() {\n  if [ -f \"/usr/local/xwiki/data/$1\" ]; then\n     echo \"  Reusing existing config file $1...\"\n     cp \"/usr/local/xwiki/data/$1\" \"/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1\"\n  fi\n}\n\n# $1 - the config file name to restore in WEB-INF (e.g. \"xwiki.cfg\")\nfunction restoreConfigurationFile() {\n  if [ -f \"/usr/local/xwiki/data/$1\" ]; then\n     echo \"  Synchronizing config file $1...\"\n     cp \"/usr/local/xwiki/data/$1\" \"/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1\"\n  fi\n}\n\nfunction configure() {\n  echo 'Configuring XWiki...'\n\n  echo 'Setting environment variables'\n  file_env 'DB_USER' 'xwiki'\n  file_env 'DB_PASSWORD' 'xwiki'\n  file_env 'DB_HOST' 'db'\n  file_env 'DB_DATABASE' 'xwiki'\n  file_env 'INDEX_HOST' 'localhost'\n  file_env 'INDEX_PORT' '8983'\n  file_env 'JDBC_PARAMS' '?'\n\n  echo \"  Deploying XWiki in the '$CONTEXT_PATH' context\"\n  if [ \"$CONTEXT_PATH\" == \"ROOT\" ]; then\n    xwiki_set_cfg 'xwiki.webapppath' ''\n  else\n    mkdir -p -v /usr/local/tomcat/webapps/$CONTEXT_PATH\n    cp -a --update=none /usr/local/tomcat/webapps/ROOT/.  /usr/local/tomcat/webapps/$CONTEXT_PATH/\n  fi\n\n  echo 'Replacing environment variables in files'\n  safesed \"replaceuser\" $DB_USER /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/hibernate.cfg.xml\n  safesed \"replacepassword\" $DB_PASSWORD /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/hibernate.cfg.xml\n  safesed \"replacecontainer\" $DB_HOST /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/hibernate.cfg.xml\n  safesed \"replacedatabase\" $DB_DATABASE /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/hibernate.cfg.xml\n  safesed \"replacejdbcparams\" $JDBC_PARAMS /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/hibernate.cfg.xml\n\n  \n\n  echo '  Setting permanent directory...'\n  xwiki_set_properties 'environment.permanentDirectory' '/usr/local/xwiki/data'\n  echo '  Configure libreoffice...'\n  xwiki_set_properties 'openoffice.autoStart' 'true'\n\n  if [ $INDEX_HOST != 'localhost' ]; then\n    echo '  Configuring remote Solr Index'\n    xwiki_set_properties 'solr.type' 'remote'\n    xwiki_set_properties 'solr.remote.url' \"http://$INDEX_HOST:$INDEX_PORT/solr/xwiki\"\n  fi\n\n  # If the files already exist then copy them to the XWiki's WEB-INF directory.\n  mkdir -p /usr/local/xwiki/data\n  saveConfigurationFile 'hibernate.cfg.xml'\n  saveConfigurationFile 'xwiki.cfg'\n  saveConfigurationFile 'xwiki.properties'\n}\n\n# This if will check if the first argument is a flag but only works if all arguments require a hyphenated flag\n# -v; -SL; -f arg; etc will work, but not arg1 arg2\nif [ \"${1:0:1}\" = '-' ]; then\n    set -- xwiki \"$@\"\nfi\n\n# Check for the expected command\nif [ \"$1\" = 'xwiki' ]; then\n  file_env 'CONTEXT_PATH' 'ROOT'\n  if [[ ! -f /usr/local/tomcat/webapps/$CONTEXT_PATH/.first_start_completed ]]; then\n    first_start\n  else\n    other_starts\n  fi\n  shift\n  set -- catalina.sh run \"$@\"\nfi\n\n# Else default to run whatever the user wanted like \"bash\"\nexec \"$@\"\n"
  },
  {
    "path": "17/postgres-tomcat/xwiki/hibernate.cfg.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<!--\n * See the NOTICE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n-->\n\n<!DOCTYPE hibernate-configuration PUBLIC\n  \"-//Hibernate/Hibernate Configuration DTD//EN\"\n  \"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd\">\n<hibernate-configuration>\n  <session-factory>\n\n    <!-- Please refer to the installation guide on\n         https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Installation/ for configuring your\n         database. You'll need to do 2 things:\n         1) Copy your database driver JAR in WEB-INF/lib or in some shared lib directory\n         2) Uncomment the properties below for your specific DB (and comment the default\n            database configuration if it doesn't match your DB)\n    -->\n\n    <!-- Generic parameters common to all Databases -->\n\n    <property name=\"show_sql\">false</property>\n    <property name=\"use_outer_join\">true</property>\n\n    <!-- Without it, some queries fail in MS SQL. XWiki doesn't need scrollable result sets, anyway. -->\n    <property name=\"jdbc.use_scrollable_resultset\">false</property>\n\n    <!-- DBCP Connection Pooling configuration. Only some properties are shown. All available properties can be found\n         at https://commons.apache.org/proper/commons-dbcp/configuration.html\n    -->\n    <property name=\"dbcp.defaultAutoCommit\">false</property>\n    <property name=\"dbcp.maxTotal\">50</property>\n    <property name=\"dbcp.maxIdle\">5</property>\n    <property name=\"dbcp.maxWaitMillis\">30000</property>\n    <property name=\"connection.provider_class\">com.xpn.xwiki.store.DBCPConnectionProvider</property>\n\n    <!-- Setting \"dbcp.poolPreparedStatements\" to true and \"dbcp.maxOpenPreparedStatements\" will tell DBCP to cache\n         Prepared Statements (it's off by default). Note that for backward compatibility the \"dbcp.ps.maxActive\" is also\n         supported and when set it'll set \"dbcp.poolPreparedStatements\" to true and \"dbcp.maxOpenPreparedStatements\" to\n         value of \"dbcp.ps.maxActive\".\n\n         Note 1: When using HSQLDB for example, it's important to NOT cache prepared statements because HSQLDB\n         Prepared Statements (PS) contain the schema on which they were initially created and thus when switching\n         schema if the same PS is reused it'll execute on the wrong schema! Since HSQLDB does internally cache\n         prepared statement there's no performance loss by not caching Prepared Statements at the DBCP level.\n         See https://jira.xwiki.org/browse/XWIKI-1740.\n         Thus we recommend not turning on this configuration for HSQLDB unless you know what you're doing :)\n\n         Note 2: The same applies to PostGreSQL.\n    -->\n\n    <!-- BoneCP Connection Pooling configuration.\n    <property name=\"bonecp.idleMaxAgeInMinutes\">240</property>\n    <property name=\"bonecp.idleConnectionTestPeriodInMinutes\">60</property>\n    <property name=\"bonecp.partitionCount\">3</property>\n    <property name=\"bonecp.acquireIncrement\">10</property>\n    <property name=\"bonecp.maxConnectionsPerPartition\">60</property>\n    <property name=\"bonecp.minConnectionsPerPartition\">20</property>\n    <property name=\"bonecp.statementsCacheSize\">50</property>\n    <property name=\"bonecp.releaseHelperThreads\">3</property>\n    <property name=\"connection.provider_class\">com.xpn.xwiki.store.DBCPConnectionProvider</property>\n    -->\n\n    <!-- PostgreSQL configuration.\n         Notes:\n           - \"jdbc.use_streams_for_binary\" needs to be set to \"false\",\n             see https://community.jboss.org/wiki/HibernateCoreMigrationGuide36\n           - \"xwiki.virtual_mode\" can be set to either \"schema\" or \"database\". Note that currently the database mode\n             doesn't support database creation (see https://jira.xwiki.org/browse/XWIKI-8753)\n           - if you want the main wiki database to be different than \"xwiki\" (or \"public\" in schema mode)\n             you will also have to set the property xwiki.db in xwiki.cfg file\n    -->\n    <property name=\"connection.url\">jdbc:postgresql://replacecontainer:5432/replacedatabasereplacejdbcparams</property>\n    <property name=\"connection.username\">replaceuser</property>\n    <property name=\"connection.password\">replacepassword</property>\n    <property name=\"connection.driver_class\">org.postgresql.Driver</property>\n    <property name=\"jdbc.use_streams_for_binary\">false</property>\n    <property name=\"xwiki.virtual_mode\">schema</property>\n\n    <property name=\"hibernate.connection.charSet\">UTF-8</property>\n    <property name=\"hibernate.connection.useUnicode\">true</property>\n    <property name=\"hibernate.connection.characterEncoding\">utf8</property>\n\n    <mapping resource=\"xwiki.postgresql.hbm.xml\"/>\n    <mapping resource=\"feeds.hbm.xml\"/>\n    <mapping resource=\"instance.hbm.xml\"/>\n    <mapping resource=\"notification-filter-preferences.hbm.xml\"/>\n    <mapping resource=\"mailsender.hbm.xml\"/>\n  </session-factory>\n</hibernate-configuration>\n"
  },
  {
    "path": "18/mariadb-tomcat/Dockerfile",
    "content": "# ---------------------------------------------------------------------------\n# See the NOTICE file distributed with this work for additional\n# information regarding copyright ownership.\n#\n# This is free software; you can redistribute it and/or modify it\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 2.1 of\n# the License, or (at your option) any later version.\n#\n# This software is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n# Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this software; if not, write to the Free\n# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n# 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n# ---------------------------------------------------------------------------\nFROM tomcat:10-jre21\n\n#    ____  ____  ____      ____  _   __        _\n#   |_  _||_  _||_  _|    |_  _|(_) [  |  _   (_)\n#     \\ \\  / /    \\ \\  /\\  / /  __   | | / ]  __\n#      > `' <      \\ \\/  \\/ /  [  |  | '' <  [  |\n#    _/ /'`\\ \\_     \\  /\\  /    | |  | |`\\ \\  | |\n#   |____||____|     \\/  \\/    [___][__|  \\_][___]\n\nLABEL org.opencontainers.image.authors='XWiki Development Team <committers@xwiki.org>'\nLABEL org.opencontainers.image.url='https://hub.docker.com/_/xwiki'\nLABEL org.opencontainers.image.documentation='https://hub.docker.com/_/xwiki'\nLABEL org.opencontainers.image.source='https://github.com/xwiki/xwiki-docker.git'\nLABEL org.opencontainers.image.vendor='xwiki.org'\nLABEL org.opencontainers.image.licenses='LGPL-2.1'\n\n# Note: when using docker-compose, the ENV values below are overridden from the .env file.\n\n# Install LibreOffice + other tools\n# Note that procps is required to get ps which is used by JODConverter to start LibreOffice\nRUN apt-get update && \\\n  apt-get --no-install-recommends -y install \\\n    curl \\\n    libreoffice \\\n    unzip \\\n    procps && \\\n  rm -rf /var/lib/apt/lists/*\n\n# Install XWiki as the ROOT webapp context in Tomcat\n# Create the Tomcat temporary directory\n# Configure the XWiki permanent directory\nENV XWIKI_VERSION=\"18.3.0\"\nENV XWIKI_URL_PREFIX \"https://maven.xwiki.org/releases/org/xwiki/platform/xwiki-platform-distribution-war/${XWIKI_VERSION}\"\nENV XWIKI_DOWNLOAD_SHA256 3a0594e4260bc832c8a42f9ea1d6f47d9da7c8ffb7bbe65b7c363e7e8308051a\nRUN rm -rf /usr/local/tomcat/webapps/* && \\\n  mkdir -p /usr/local/tomcat/temp && \\\n  mkdir -p /usr/local/xwiki/data && \\\n  curl -fSL \"${XWIKI_URL_PREFIX}/xwiki-platform-distribution-war-${XWIKI_VERSION}.war\" -o xwiki.war && \\\n  echo \"$XWIKI_DOWNLOAD_SHA256 xwiki.war\" | sha256sum -c - && \\\n  unzip -d /usr/local/tomcat/webapps/ROOT xwiki.war && \\\n  rm -f xwiki.war\n\n# Copy the JDBC driver in the XWiki webapp\n# We take the database driver version from the Maven Central repository since we want to control the version \n# used and have it being consistent with what is tested in the CI.\nENV MARIADB_JDBC_VERSION=\"3.5.8\"\nENV MARIADB_JDBC_SHA256=\"6127dc7858047b3d4482899139640b0e2ab2b8abdeb708cfb8c011117771cddf\"\nENV MARIADB_JDBC_PREFIX=\"https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/${MARIADB_JDBC_VERSION}\"\nENV MARIADB_JDBC_ARTIFACT=\"mariadb-java-client-${MARIADB_JDBC_VERSION}.jar\"\nENV MARIADB_JDBC_TARGET=\"/usr/local/tomcat/webapps/ROOT/WEB-INF/lib/${MARIADB_JDBC_ARTIFACT}\"\nRUN curl -fSL \"${MARIADB_JDBC_PREFIX}/${MARIADB_JDBC_ARTIFACT}\" -o $MARIADB_JDBC_TARGET && \\\n  echo \"$MARIADB_JDBC_SHA256 $MARIADB_JDBC_TARGET\" | sha256sum -c -\n\n# Configure Tomcat. For example set the memory for the Tomcat JVM since the default value is too small for XWiki\nCOPY tomcat/setenv.sh /usr/local/tomcat/bin/\n\n# Setup the XWiki Hibernate configuration\nCOPY xwiki/hibernate.cfg.xml /usr/local/tomcat/webapps/ROOT/WEB-INF/hibernate.cfg.xml\n\n# Set a specific distribution id in XWiki for this docker packaging.\nRUN sed -i 's/<id>org.xwiki.platform:xwiki-platform-distribution-war/<id>org.xwiki.platform:xwiki-platform-distribution-docker/' \\\n  /usr/local/tomcat/webapps/ROOT/META-INF/extension.xed\n\n# Add scripts required to make changes to XWiki configuration files at execution time\n# Note: we don't run CHMOD since 1) it's not required since the executabe bit is already set in git and 2) running\n# CHMOD after a COPY will sometimes fail, depending on different host-specific factors (especially on AUFS).\nCOPY xwiki/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh\n\n# Make the XWiki directory (the permanent directory is included in it) persist on the host (so that it's not recreated\n# across runs)\nVOLUME /usr/local/xwiki\n\n# At this point the image is done and what remains below are the runtime configuration used by the user to configure\n# the container that will be created out of the image. Namely the user can override some environment variables with\n#   docker run -e \"var1=val1\" -e \"var2=val2\" ...\n# The supported environment variables that can be overridden are:\n# - DB_USER: the name of the user configured for XWiki in the DB. Default is \"xwiki\". This is used to configure\n#            xwiki's hibernate.cfg.xml file.\n# - DB_PASSWORD: the password for the user configured for XWiki in the DB. Default is \"xwiki\". This is used to\n#                configure xwiki's hibernate.cfg.xml file.\n# - DB_DATABASE: the name of the database to use. Default is \"xwiki\". This is used to configure xwiki's\n#                hibernate.cfg.xml file.\n# - DB_HOST: The name of the host (or docker container) containing the database. Default is \"db\". This is used to\n#            configure xwiki's hibernate.cfg.xml file.\n# - CONTEXT_PATH: The name of the context path under which XWiki will be deployed in Tomcat. If not specified then it'll\n#                 be deployed as ROOT.\n# - JDBC_PARAMS: Replaces the default JDBC parameters with the passed ones.\n\n# Example:\n#   docker run -it -e \"DB_USER=xwiki\" -e \"DB_PASSWORD=xwiki\" <imagename>\n\n# Starts XWiki by starting Tomcat. All options passed to \"docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]\"\n# are also passed to docker-entrypoint.sh. If \"xwiki\" is passed then XWiki will be configured the first time the\n# container executes and Tomcat will be started. If some other parameter is passed then it'll be executed to comply\n# with best practices defined at https://github.com/docker-library/official-images#consistency.\nENTRYPOINT [\"docker-entrypoint.sh\"]\nCMD [\"xwiki\"]\n"
  },
  {
    "path": "18/mariadb-tomcat/docker-compose.yml",
    "content": "# ---------------------------------------------------------------------------\n# See the NOTICE file distributed with this work for additional\n# information regarding copyright ownership.\n#\n# This is free software; you can redistribute it and/or modify it\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 2.1 of\n# the License, or (at your option) any later version.\n#\n# This software is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n# Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this software; if not, write to the Free\n# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n# 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n# ---------------------------------------------------------------------------\nversion: '2'\nnetworks:\n  bridge:\n    driver: bridge\nservices:\n  # The container that runs XWiki in Tomcat, with the appropriate JDBC driver (for mariadb).\n  web:\n    image: \"xwiki:${XWIKI_VERSION}-mariadb-tomcat\"\n    container_name: xwiki-mariadb-tomcat-web\n    depends_on:\n      - db\n    ports:\n      - \"8080:8080\"\n    # Default values defined in .env file.\n    # The DB_USER/DB_PASSWORD/DB_DATABASE/DB_HOST variables are used in the hibernate.cfg.xml file.\n    environment:\n      - XWIKI_VERSION=${XWIKI_VERSION}\n      - DB_USER=${DB_USER}\n      - DB_PASSWORD=${DB_PASSWORD}\n      - DB_DATABASE=${DB_DATABASE}\n      - DB_HOST=xwiki-mariadb-db\n    # Provide a name instead of an auto-generated id for xwiki data (the permanent directory in included in it)\n    # configured in the Dockerfile, to make it simpler to identify in 'docker volume ls'.\n    volumes:\n      - xwiki-data:/usr/local/xwiki\n    networks:\n      - bridge\n  # The container that runs the database (mariadb)\n  db:\n    image: \"mariadb:12\"\n    container_name: xwiki-mariadb-db\n    # - Provide a name instead of an auto-generated id for the mariadb data, to make it simpler to identify in\n    # 'docker volume ls'\n    # - Provide a SQL script to be executed when the db image starts (to set permissions to create subwikis)\n    volumes:\n      - mariadb-data:/var/lib/mysql\n      - ./init.sql:/docker-entrypoint-initdb.d/init.sql\n\n    # Configure the MariaDB database and create a user with provided name/password.\n    # See https://hub.docker.com/_/mariadb/ for more details.\n    # Default values defined in .env file.\n    environment:\n      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}\n      - MYSQL_USER=${DB_USER}\n      - MYSQL_PASSWORD=${DB_PASSWORD}\n      - MYSQL_DATABASE=${DB_DATABASE}\n\n    # Pass arguments to configure the database\n    command:\n      - \"--character-set-server=utf8mb4\"\n      - \"--collation-server=utf8mb4_bin\"\n      - \"--explicit-defaults-for-timestamp=1\"\n    networks:\n      - bridge\nvolumes:\n  mariadb-data: {}\n  xwiki-data: {}\n"
  },
  {
    "path": "18/mariadb-tomcat/mariadb/init.sql",
    "content": "grant all privileges on *.* to xwiki@'%'"
  },
  {
    "path": "18/mariadb-tomcat/tomcat/setenv.sh",
    "content": "#!/bin/bash\n# ---------------------------------------------------------------------------\n# See the NOTICE file distributed with this work for additional\n# information regarding copyright ownership.\n#\n# This is free software; you can redistribute it and/or modify it\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 2.1 of\n# the License, or (at your option) any later version.\n#\n# This software is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n# Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this software; if not, write to the Free\n# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n# 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n# ---------------------------------------------------------------------------\n\n# We're making the following changes to the default:\n# * Adding more memory (default is 512MB which is not enough for XWiki)\n# * By default, Tomcat does not allow the usage of encoded slash '%2F' and backslash '%5C' in URLs, as noted in\n#   https://tomcat.apache.org/security-6.html#Fixed_in_Apache_Tomcat_6.0.10. We want to allow for them as it's useful to\n#   be able to have '/' and '' in wiki page names.\n# * On some system /dev/random is slow to init leading to a slow Tomcat and thus Xwiki startup.\n\n# Users can override these values by setting the JAVA_OPTS environment variable. For example:\n# -e JAVA_OPTS=\"-Xmx2048m\"\n\nXMX=\"-Xmx1024m\"\nALLOW_ENCODED_SLASH=\"-Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true\"\nALLOW_BACKSLASH=\"-Dorg.apache.catalina.connector.CoyoteAdapter.ALLOW_BACKSLASH=true\"\nSECURERANDOM=\"-Djava.security.egd=file:/dev/./urandom\"\n\nif [[ ! -z \"$JAVA_OPTS\" ]]; then\n  if [[ ! $JAVA_OPTS =~ .*-Xmx[0-9]+.* ]]; then\n    JAVA_OPTS=\"$JAVA_OPTS $XMX\"\n  fi\n  if [[ ! $JAVA_OPTS =~ .*ALLOW_ENCODED_SLASH.* ]]; then\n    JAVA_OPTS=\"$JAVA_OPTS $ALLOW_ENCODED_SLASH\"\n  fi\n  if [[ ! $JAVA_OPTS =~ .*ALLOW_BACKSLASH.* ]]; then\n    JAVA_OPTS=\"$JAVA_OPTS $ALLOW_BACKSLASH\"\n  fi\n  if [[ ! $JAVA_OPTS =~ .*java\\.security\\.egd.* ]]; then\n    JAVA_OPTS=\"$JAVA_OPTS $SECURERANDOM\"\n  fi\nelse\n  JAVA_OPTS=\"$XMX $ALLOW_ENCODED_SLASH $ALLOW_BACKSLASH $SECURERANDOM\"\nfi\n\nexport JAVA_OPTS\n"
  },
  {
    "path": "18/mariadb-tomcat/xwiki/docker-entrypoint.sh",
    "content": "#!/bin/bash\n# ---------------------------------------------------------------------------\n# See the NOTICE file distributed with this work for additional\n# information regarding copyright ownership.\n#\n# This is free software; you can redistribute it and/or modify it\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 2.1 of\n# the License, or (at your option) any later version.\n#\n# This software is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n# Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this software; if not, write to the Free\n# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n# 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n# ---------------------------------------------------------------------------\n\nset -e\n\nfunction first_start() {\n  configure\n  touch /usr/local/tomcat/webapps/$CONTEXT_PATH/.first_start_completed\n}\n\nfunction other_starts() {\n  mkdir -p /usr/local/xwiki/data\n  restoreConfigurationFile 'hibernate.cfg.xml'\n  restoreConfigurationFile 'xwiki.cfg'\n  restoreConfigurationFile 'xwiki.properties'\n}\n\n# $1 - the path to xwiki.[cfg|properties]\n# $2 - the setting/property to set\n# $3 - the new value\nfunction xwiki_replace() {\n  # Don't use \"sed -i\" as it creates a temporary file and perform a rename (thus changing the inode of the initial file)\n  # which makes it fail if you map the initial file as a Docker volume mount.\n  sed s~\"\\#\\? \\?$2 \\?=.*\"~\"$2=$3\"~g \"$1\" > \"$1.old\"\n  cp \"$1.old\" \"$1\"\n  rm \"$1.old\"\n}\n\n# $1 - the setting/property to set\n# $2 - the new value\nfunction xwiki_set_cfg() {\n  xwiki_replace /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/xwiki.cfg \"$1\" \"$2\"\n}\n\n# $1 - the setting/property to set\n# $2 - the new value\nfunction xwiki_set_properties() {\n  xwiki_replace /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/xwiki.properties \"$1\" \"$2\"\n}\n\n# usage: file_env VAR [DEFAULT]\n#    ie: file_env 'XYZ_DB_PASSWORD' 'example'\n# (will allow for \"$XYZ_DB_PASSWORD_FILE\" to fill in the value of\n#  \"$XYZ_DB_PASSWORD\" from a file, especially for Docker's secrets feature)\nfile_env() {\n  local var=\"$1\"\n  local fileVar=\"${var}_FILE\"\n  local def=\"${2:-}\"\n  if [ \"${!var:-}\" ] && [ \"${!fileVar:-}\" ]; then\n    echo >&2 \"error: both $var and $fileVar are set (but are exclusive)\"\n    exit 1\n  fi\n  local val=\"$def\"\n  if [ \"${!var:-}\" ]; then\n    val=\"${!var}\"\n  elif [ \"${!fileVar:-}\" ]; then\n    val=\"$(< \"${!fileVar}\")\"\n  fi\n  export \"$var\"=\"$val\"\n  unset \"$fileVar\"\n}\n\n# Allows to use sed but with user input which can contain special sed characters such as \\, / or &.\n# $1 - the text to search for\n# $2 - the replacement text\n# $3 - the file in which to do the search/replace\nfunction safesed {\n  # Don't use \"sed -i\" as it creates a temporary file and perform a rename (thus changing the inode of the initial file)\n  # which makes it fail if you map the initial file as a Docker volume mount.\n  sed \"s/$(echo $1 | sed -e 's/\\([[\\/.*]\\|\\]\\)/\\\\&/g')/$(echo $2 | sed -e 's/[\\/&]/\\\\&/g')/g\" \"$3\" > \"$3.old\"\n  cp \"$3.old\" \"$3\"\n  rm \"$3.old\"\n}\n\n# $1 - the config file name found in WEB-INF (e.g. \"xwiki.cfg\")\nfunction saveConfigurationFile() {\n  if [ -f \"/usr/local/xwiki/data/$1\" ]; then\n     echo \"  Reusing existing config file $1...\"\n     cp \"/usr/local/xwiki/data/$1\" \"/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1\"\n  fi\n}\n\n# $1 - the config file name to restore in WEB-INF (e.g. \"xwiki.cfg\")\nfunction restoreConfigurationFile() {\n  if [ -f \"/usr/local/xwiki/data/$1\" ]; then\n     echo \"  Synchronizing config file $1...\"\n     cp \"/usr/local/xwiki/data/$1\" \"/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1\"\n  fi\n}\n\nfunction configure() {\n  echo 'Configuring XWiki...'\n\n  echo 'Setting environment variables'\n  file_env 'DB_USER' 'xwiki'\n  file_env 'DB_PASSWORD' 'xwiki'\n  file_env 'DB_HOST' 'db'\n  file_env 'DB_DATABASE' 'xwiki'\n  file_env 'INDEX_HOST' 'localhost'\n  file_env 'INDEX_PORT' '8983'\n  file_env 'JDBC_PARAMS' '?useSSL=false'\n\n  echo \"  Deploying XWiki in the '$CONTEXT_PATH' context\"\n  if [ \"$CONTEXT_PATH\" == \"ROOT\" ]; then\n    xwiki_set_cfg 'xwiki.webapppath' ''\n  else\n    mkdir -p -v /usr/local/tomcat/webapps/$CONTEXT_PATH\n    cp -a --update=none /usr/local/tomcat/webapps/ROOT/.  /usr/local/tomcat/webapps/$CONTEXT_PATH/\n  fi\n\n  echo 'Replacing environment variables in files'\n  safesed \"replaceuser\" $DB_USER /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/hibernate.cfg.xml\n  safesed \"replacepassword\" $DB_PASSWORD /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/hibernate.cfg.xml\n  safesed \"replacecontainer\" $DB_HOST /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/hibernate.cfg.xml\n  safesed \"replacedatabase\" $DB_DATABASE /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/hibernate.cfg.xml\n  safesed \"replacejdbcparams\" $JDBC_PARAMS /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/hibernate.cfg.xml\n\n  # Set any non-default main wiki database name in the xwiki.cfg file.\n  if [ \"$DB_DATABASE\" != \"xwiki\" ]; then\n    xwiki_set_cfg \"xwiki.db\" $DB_DATABASE\n  fi\n\n  echo '  Setting permanent directory...'\n  xwiki_set_properties 'environment.permanentDirectory' '/usr/local/xwiki/data'\n  echo '  Configure libreoffice...'\n  xwiki_set_properties 'openoffice.autoStart' 'true'\n\n  if [ $INDEX_HOST != 'localhost' ]; then\n    echo '  Configuring remote Solr Index'\n    xwiki_set_properties 'solr.type' 'remote'\n    xwiki_set_properties 'solr.remote.url' \"http://$INDEX_HOST:$INDEX_PORT/solr/xwiki\"\n  fi\n\n  # If the files already exist then copy them to the XWiki's WEB-INF directory.\n  mkdir -p /usr/local/xwiki/data\n  saveConfigurationFile 'hibernate.cfg.xml'\n  saveConfigurationFile 'xwiki.cfg'\n  saveConfigurationFile 'xwiki.properties'\n}\n\n# This if will check if the first argument is a flag but only works if all arguments require a hyphenated flag\n# -v; -SL; -f arg; etc will work, but not arg1 arg2\nif [ \"${1:0:1}\" = '-' ]; then\n    set -- xwiki \"$@\"\nfi\n\n# Check for the expected command\nif [ \"$1\" = 'xwiki' ]; then\n  file_env 'CONTEXT_PATH' 'ROOT'\n  if [[ ! -f /usr/local/tomcat/webapps/$CONTEXT_PATH/.first_start_completed ]]; then\n    first_start\n  else\n    other_starts\n  fi\n  shift\n  set -- catalina.sh run \"$@\"\nfi\n\n# Else default to run whatever the user wanted like \"bash\"\nexec \"$@\"\n"
  },
  {
    "path": "18/mariadb-tomcat/xwiki/hibernate.cfg.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<!--\n * See the NOTICE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n-->\n\n<!DOCTYPE hibernate-configuration PUBLIC\n  \"-//Hibernate/Hibernate Configuration DTD//EN\"\n  \"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd\">\n<hibernate-configuration>\n  <session-factory>\n\n    <!-- Please refer to the installation guide on\n         https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Installation/ for configuring your\n         database. You'll need to do 2 things:\n         1) Copy your database driver JAR in WEB-INF/lib or in some shared lib directory\n         2) Uncomment the properties below for your specific DB (and comment the default\n            database configuration if it doesn't match your DB)\n    -->\n\n    <!-- Generic parameters common to all Databases -->\n\n    <property name=\"show_sql\">false</property>\n    <property name=\"use_outer_join\">true</property>\n\n    <!-- Without it, some queries fail in MS SQL. XWiki doesn't need scrollable result sets, anyway. -->\n    <property name=\"jdbc.use_scrollable_resultset\">false</property>\n\n    <!-- DBCP Connection Pooling configuration. Only some properties are shown. All available properties can be found\n         at https://commons.apache.org/proper/commons-dbcp/configuration.html\n    -->\n    <property name=\"dbcp.defaultAutoCommit\">false</property>\n    <property name=\"dbcp.maxTotal\">50</property>\n    <property name=\"dbcp.maxIdle\">5</property>\n    <property name=\"dbcp.maxWaitMillis\">30000</property>\n    <property name=\"connection.provider_class\">com.xpn.xwiki.store.DBCPConnectionProvider</property>\n\n    <!-- Setting \"dbcp.poolPreparedStatements\" to true and \"dbcp.maxOpenPreparedStatements\" will tell DBCP to cache\n         Prepared Statements (it's off by default). Note that for backward compatibility the \"dbcp.ps.maxActive\" is also\n         supported and when set it'll set \"dbcp.poolPreparedStatements\" to true and \"dbcp.maxOpenPreparedStatements\" to\n         value of \"dbcp.ps.maxActive\".\n\n         Note 1: When using HSQLDB for example, it's important to NOT cache prepared statements because HSQLDB\n         Prepared Statements (PS) contain the schema on which they were initially created and thus when switching\n         schema if the same PS is reused it'll execute on the wrong schema! Since HSQLDB does internally cache\n         prepared statement there's no performance loss by not caching Prepared Statements at the DBCP level.\n         See https://jira.xwiki.org/browse/XWIKI-1740.\n         Thus we recommend not turning on this configuration for HSQLDB unless you know what you're doing :)\n\n         Note 2: The same applies to PostGreSQL.\n    -->\n\n    <!-- BoneCP Connection Pooling configuration.\n    <property name=\"bonecp.idleMaxAgeInMinutes\">240</property>\n    <property name=\"bonecp.idleConnectionTestPeriodInMinutes\">60</property>\n    <property name=\"bonecp.partitionCount\">3</property>\n    <property name=\"bonecp.acquireIncrement\">10</property>\n    <property name=\"bonecp.maxConnectionsPerPartition\">60</property>\n    <property name=\"bonecp.minConnectionsPerPartition\">20</property>\n    <property name=\"bonecp.statementsCacheSize\">50</property>\n    <property name=\"bonecp.releaseHelperThreads\">3</property>\n    <property name=\"connection.provider_class\">com.xpn.xwiki.store.DBCPConnectionProvider</property>\n    -->\n\n    <!-- MariaDB configuration.\n         Notes:\n           - If you want the main wiki database to be different than \"xwiki\"\n             you will also have to set the property xwiki.db in xwiki.cfg file\n    -->\n    <property name=\"connection.url\">jdbc:mariadb://replacecontainer/replacedatabasereplacejdbcparams</property>\n    <property name=\"connection.username\">replaceuser</property>\n    <property name=\"connection.password\">replacepassword</property>\n    <property name=\"connection.driver_class\">org.mariadb.jdbc.Driver</property>\n    <property name=\"dbcp.poolPreparedStatements\">true</property>\n    <property name=\"dbcp.maxOpenPreparedStatements\">20</property>\n\n    <property name=\"hibernate.connection.charSet\">UTF-8</property>\n    <property name=\"hibernate.connection.useUnicode\">true</property>\n    <property name=\"hibernate.connection.characterEncoding\">utf8</property>\n\n    <mapping resource=\"xwiki.hbm.xml\"/>\n    <mapping resource=\"feeds.hbm.xml\"/>\n    <mapping resource=\"instance.hbm.xml\"/>\n    <mapping resource=\"notification-filter-preferences.hbm.xml\"/>\n    <mapping resource=\"mailsender.hbm.xml\"/>\n  </session-factory>\n</hibernate-configuration>\n"
  },
  {
    "path": "18/mysql-tomcat/Dockerfile",
    "content": "# ---------------------------------------------------------------------------\n# See the NOTICE file distributed with this work for additional\n# information regarding copyright ownership.\n#\n# This is free software; you can redistribute it and/or modify it\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 2.1 of\n# the License, or (at your option) any later version.\n#\n# This software is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n# Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this software; if not, write to the Free\n# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n# 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n# ---------------------------------------------------------------------------\nFROM tomcat:10-jre21\n\n#    ____  ____  ____      ____  _   __        _\n#   |_  _||_  _||_  _|    |_  _|(_) [  |  _   (_)\n#     \\ \\  / /    \\ \\  /\\  / /  __   | | / ]  __\n#      > `' <      \\ \\/  \\/ /  [  |  | '' <  [  |\n#    _/ /'`\\ \\_     \\  /\\  /    | |  | |`\\ \\  | |\n#   |____||____|     \\/  \\/    [___][__|  \\_][___]\n\nLABEL org.opencontainers.image.authors='XWiki Development Team <committers@xwiki.org>'\nLABEL org.opencontainers.image.url='https://hub.docker.com/_/xwiki'\nLABEL org.opencontainers.image.documentation='https://hub.docker.com/_/xwiki'\nLABEL org.opencontainers.image.source='https://github.com/xwiki/xwiki-docker.git'\nLABEL org.opencontainers.image.vendor='xwiki.org'\nLABEL org.opencontainers.image.licenses='LGPL-2.1'\n\n# Note: when using docker-compose, the ENV values below are overridden from the .env file.\n\n# Install LibreOffice + other tools\n# Note that procps is required to get ps which is used by JODConverter to start LibreOffice\nRUN apt-get update && \\\n  apt-get --no-install-recommends -y install \\\n    curl \\\n    libreoffice \\\n    unzip \\\n    procps && \\\n  rm -rf /var/lib/apt/lists/*\n\n# Install XWiki as the ROOT webapp context in Tomcat\n# Create the Tomcat temporary directory\n# Configure the XWiki permanent directory\nENV XWIKI_VERSION=\"18.3.0\"\nENV XWIKI_URL_PREFIX \"https://maven.xwiki.org/releases/org/xwiki/platform/xwiki-platform-distribution-war/${XWIKI_VERSION}\"\nENV XWIKI_DOWNLOAD_SHA256 3a0594e4260bc832c8a42f9ea1d6f47d9da7c8ffb7bbe65b7c363e7e8308051a\nRUN rm -rf /usr/local/tomcat/webapps/* && \\\n  mkdir -p /usr/local/tomcat/temp && \\\n  mkdir -p /usr/local/xwiki/data && \\\n  curl -fSL \"${XWIKI_URL_PREFIX}/xwiki-platform-distribution-war-${XWIKI_VERSION}.war\" -o xwiki.war && \\\n  echo \"$XWIKI_DOWNLOAD_SHA256 xwiki.war\" | sha256sum -c - && \\\n  unzip -d /usr/local/tomcat/webapps/ROOT xwiki.war && \\\n  rm -f xwiki.war\n\n# Copy the JDBC driver in the XWiki webapp\n# We take the database driver version from the Maven Central repository since we want to control the version \n# used and have it being consistent with what is tested in the CI.\nENV MYSQL_JDBC_VERSION=\"9.7.0\"\nENV MYSQL_JDBC_SHA256=\"0353648eaa1c91e0f4020c959abf756bc866ffd583df22ae6b6f6e0cbd43eb44\"\nENV MYSQL_JDBC_PREFIX=\"https://repo1.maven.org/maven2/com/mysql/mysql-connector-j/${MYSQL_JDBC_VERSION}\"\nENV MYSQL_JDBC_ARTIFACT=\"mysql-connector-j-${MYSQL_JDBC_VERSION}.jar\"\nENV MYSQL_JDBC_TARGET=\"/usr/local/tomcat/webapps/ROOT/WEB-INF/lib/${MYSQL_JDBC_ARTIFACT}\"\nRUN curl -fSL \"${MYSQL_JDBC_PREFIX}/${MYSQL_JDBC_ARTIFACT}\" -o $MYSQL_JDBC_TARGET && \\\n  echo \"$MYSQL_JDBC_SHA256 $MYSQL_JDBC_TARGET\" | sha256sum -c -\n\n# Configure Tomcat. For example set the memory for the Tomcat JVM since the default value is too small for XWiki\nCOPY tomcat/setenv.sh /usr/local/tomcat/bin/\n\n# Setup the XWiki Hibernate configuration\nCOPY xwiki/hibernate.cfg.xml /usr/local/tomcat/webapps/ROOT/WEB-INF/hibernate.cfg.xml\n\n# Set a specific distribution id in XWiki for this docker packaging.\nRUN sed -i 's/<id>org.xwiki.platform:xwiki-platform-distribution-war/<id>org.xwiki.platform:xwiki-platform-distribution-docker/' \\\n  /usr/local/tomcat/webapps/ROOT/META-INF/extension.xed\n\n# Add scripts required to make changes to XWiki configuration files at execution time\n# Note: we don't run CHMOD since 1) it's not required since the executabe bit is already set in git and 2) running\n# CHMOD after a COPY will sometimes fail, depending on different host-specific factors (especially on AUFS).\nCOPY xwiki/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh\n\n# Make the XWiki directory (the permanent directory is included in it) persist on the host (so that it's not recreated\n# across runs)\nVOLUME /usr/local/xwiki\n\n# At this point the image is done and what remains below are the runtime configuration used by the user to configure\n# the container that will be created out of the image. Namely the user can override some environment variables with\n#   docker run -e \"var1=val1\" -e \"var2=val2\" ...\n# The supported environment variables that can be overridden are:\n# - DB_USER: the name of the user configured for XWiki in the DB. Default is \"xwiki\". This is used to configure\n#            xwiki's hibernate.cfg.xml file.\n# - DB_PASSWORD: the password for the user configured for XWiki in the DB. Default is \"xwiki\". This is used to\n#                configure xwiki's hibernate.cfg.xml file.\n# - DB_DATABASE: the name of the database to use. Default is \"xwiki\". This is used to configure xwiki's\n#                hibernate.cfg.xml file.\n# - DB_HOST: The name of the host (or docker container) containing the database. Default is \"db\". This is used to\n#            configure xwiki's hibernate.cfg.xml file.\n# - CONTEXT_PATH: The name of the context path under which XWiki will be deployed in Tomcat. If not specified then it'll\n#                 be deployed as ROOT.\n# - JDBC_PARAMS: Replaces the default JDBC parameters with the passed ones.\n\n# Example:\n#   docker run -it -e \"DB_USER=xwiki\" -e \"DB_PASSWORD=xwiki\" <imagename>\n\n# Starts XWiki by starting Tomcat. All options passed to \"docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]\"\n# are also passed to docker-entrypoint.sh. If \"xwiki\" is passed then XWiki will be configured the first time the\n# container executes and Tomcat will be started. If some other parameter is passed then it'll be executed to comply\n# with best practices defined at https://github.com/docker-library/official-images#consistency.\nENTRYPOINT [\"docker-entrypoint.sh\"]\nCMD [\"xwiki\"]\n"
  },
  {
    "path": "18/mysql-tomcat/docker-compose.yml",
    "content": "# ---------------------------------------------------------------------------\n# See the NOTICE file distributed with this work for additional\n# information regarding copyright ownership.\n#\n# This is free software; you can redistribute it and/or modify it\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 2.1 of\n# the License, or (at your option) any later version.\n#\n# This software is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n# Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this software; if not, write to the Free\n# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n# 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n# ---------------------------------------------------------------------------\nversion: '2'\nnetworks:\n  bridge:\n    driver: bridge\nservices:\n  # The container that runs XWiki in Tomcat, with the appropriate JDBC driver (for mysql).\n  web:\n    image: \"xwiki:${XWIKI_VERSION}-mysql-tomcat\"\n    container_name: xwiki-mysql-tomcat-web\n    depends_on:\n      - db\n    ports:\n      - \"8080:8080\"\n    # Default values defined in .env file.\n    # The DB_USER/DB_PASSWORD/DB_DATABASE/DB_HOST variables are used in the hibernate.cfg.xml file.\n    environment:\n      - XWIKI_VERSION=${XWIKI_VERSION}\n      - DB_USER=${DB_USER}\n      - DB_PASSWORD=${DB_PASSWORD}\n      - DB_DATABASE=${DB_DATABASE}\n      - DB_HOST=xwiki-mysql-db\n    # Provide a name instead of an auto-generated id for xwiki data (the permanent directory in included in it)\n    # configured in the Dockerfile, to make it simpler to identify in 'docker volume ls'.\n    volumes:\n      - xwiki-data:/usr/local/xwiki\n    networks:\n      - bridge\n  # The container that runs the database (mysql)\n  db:\n    image: \"mysql:9\"\n    container_name: xwiki-mysql-db\n    # - Provide a name instead of an auto-generated id for the mysql data, to make it simpler to identify in\n    # 'docker volume ls'\n    # - Provide a SQL script to be executed when the db image starts (to set permissions to create subwikis)\n    volumes:\n      - mysql-data:/var/lib/mysql\n      - ./init.sql:/docker-entrypoint-initdb.d/init.sql\n\n    # Configure the MySQL database and create a user with provided name/password.\n    # See https://hub.docker.com/_/mysql/ for more details.\n    # Default values defined in .env file.\n    environment:\n      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}\n      - MYSQL_USER=${DB_USER}\n      - MYSQL_PASSWORD=${DB_PASSWORD}\n      - MYSQL_DATABASE=${DB_DATABASE}\n\n    # Pass arguments to configure the database\n    command:\n      - \"--character-set-server=utf8mb4\"\n      - \"--collation-server=utf8mb4_bin\"\n      - \"--explicit-defaults-for-timestamp=1\"\n    networks:\n      - bridge\nvolumes:\n  mysql-data: {}\n  xwiki-data: {}\n"
  },
  {
    "path": "18/mysql-tomcat/mysql/init.sql",
    "content": "grant all privileges on *.* to xwiki@'%'"
  },
  {
    "path": "18/mysql-tomcat/tomcat/setenv.sh",
    "content": "#!/bin/bash\n# ---------------------------------------------------------------------------\n# See the NOTICE file distributed with this work for additional\n# information regarding copyright ownership.\n#\n# This is free software; you can redistribute it and/or modify it\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 2.1 of\n# the License, or (at your option) any later version.\n#\n# This software is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n# Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this software; if not, write to the Free\n# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n# 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n# ---------------------------------------------------------------------------\n\n# We're making the following changes to the default:\n# * Adding more memory (default is 512MB which is not enough for XWiki)\n# * By default, Tomcat does not allow the usage of encoded slash '%2F' and backslash '%5C' in URLs, as noted in\n#   https://tomcat.apache.org/security-6.html#Fixed_in_Apache_Tomcat_6.0.10. We want to allow for them as it's useful to\n#   be able to have '/' and '' in wiki page names.\n# * On some system /dev/random is slow to init leading to a slow Tomcat and thus Xwiki startup.\n\n# Users can override these values by setting the JAVA_OPTS environment variable. For example:\n# -e JAVA_OPTS=\"-Xmx2048m\"\n\nXMX=\"-Xmx1024m\"\nALLOW_ENCODED_SLASH=\"-Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true\"\nALLOW_BACKSLASH=\"-Dorg.apache.catalina.connector.CoyoteAdapter.ALLOW_BACKSLASH=true\"\nSECURERANDOM=\"-Djava.security.egd=file:/dev/./urandom\"\n\nif [[ ! -z \"$JAVA_OPTS\" ]]; then\n  if [[ ! $JAVA_OPTS =~ .*-Xmx[0-9]+.* ]]; then\n    JAVA_OPTS=\"$JAVA_OPTS $XMX\"\n  fi\n  if [[ ! $JAVA_OPTS =~ .*ALLOW_ENCODED_SLASH.* ]]; then\n    JAVA_OPTS=\"$JAVA_OPTS $ALLOW_ENCODED_SLASH\"\n  fi\n  if [[ ! $JAVA_OPTS =~ .*ALLOW_BACKSLASH.* ]]; then\n    JAVA_OPTS=\"$JAVA_OPTS $ALLOW_BACKSLASH\"\n  fi\n  if [[ ! $JAVA_OPTS =~ .*java\\.security\\.egd.* ]]; then\n    JAVA_OPTS=\"$JAVA_OPTS $SECURERANDOM\"\n  fi\nelse\n  JAVA_OPTS=\"$XMX $ALLOW_ENCODED_SLASH $ALLOW_BACKSLASH $SECURERANDOM\"\nfi\n\nexport JAVA_OPTS\n"
  },
  {
    "path": "18/mysql-tomcat/xwiki/docker-entrypoint.sh",
    "content": "#!/bin/bash\n# ---------------------------------------------------------------------------\n# See the NOTICE file distributed with this work for additional\n# information regarding copyright ownership.\n#\n# This is free software; you can redistribute it and/or modify it\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 2.1 of\n# the License, or (at your option) any later version.\n#\n# This software is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n# Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this software; if not, write to the Free\n# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n# 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n# ---------------------------------------------------------------------------\n\nset -e\n\nfunction first_start() {\n  configure\n  touch /usr/local/tomcat/webapps/$CONTEXT_PATH/.first_start_completed\n}\n\nfunction other_starts() {\n  mkdir -p /usr/local/xwiki/data\n  restoreConfigurationFile 'hibernate.cfg.xml'\n  restoreConfigurationFile 'xwiki.cfg'\n  restoreConfigurationFile 'xwiki.properties'\n}\n\n# $1 - the path to xwiki.[cfg|properties]\n# $2 - the setting/property to set\n# $3 - the new value\nfunction xwiki_replace() {\n  # Don't use \"sed -i\" as it creates a temporary file and perform a rename (thus changing the inode of the initial file)\n  # which makes it fail if you map the initial file as a Docker volume mount.\n  sed s~\"\\#\\? \\?$2 \\?=.*\"~\"$2=$3\"~g \"$1\" > \"$1.old\"\n  cp \"$1.old\" \"$1\"\n  rm \"$1.old\"\n}\n\n# $1 - the setting/property to set\n# $2 - the new value\nfunction xwiki_set_cfg() {\n  xwiki_replace /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/xwiki.cfg \"$1\" \"$2\"\n}\n\n# $1 - the setting/property to set\n# $2 - the new value\nfunction xwiki_set_properties() {\n  xwiki_replace /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/xwiki.properties \"$1\" \"$2\"\n}\n\n# usage: file_env VAR [DEFAULT]\n#    ie: file_env 'XYZ_DB_PASSWORD' 'example'\n# (will allow for \"$XYZ_DB_PASSWORD_FILE\" to fill in the value of\n#  \"$XYZ_DB_PASSWORD\" from a file, especially for Docker's secrets feature)\nfile_env() {\n  local var=\"$1\"\n  local fileVar=\"${var}_FILE\"\n  local def=\"${2:-}\"\n  if [ \"${!var:-}\" ] && [ \"${!fileVar:-}\" ]; then\n    echo >&2 \"error: both $var and $fileVar are set (but are exclusive)\"\n    exit 1\n  fi\n  local val=\"$def\"\n  if [ \"${!var:-}\" ]; then\n    val=\"${!var}\"\n  elif [ \"${!fileVar:-}\" ]; then\n    val=\"$(< \"${!fileVar}\")\"\n  fi\n  export \"$var\"=\"$val\"\n  unset \"$fileVar\"\n}\n\n# Allows to use sed but with user input which can contain special sed characters such as \\, / or &.\n# $1 - the text to search for\n# $2 - the replacement text\n# $3 - the file in which to do the search/replace\nfunction safesed {\n  # Don't use \"sed -i\" as it creates a temporary file and perform a rename (thus changing the inode of the initial file)\n  # which makes it fail if you map the initial file as a Docker volume mount.\n  sed \"s/$(echo $1 | sed -e 's/\\([[\\/.*]\\|\\]\\)/\\\\&/g')/$(echo $2 | sed -e 's/[\\/&]/\\\\&/g')/g\" \"$3\" > \"$3.old\"\n  cp \"$3.old\" \"$3\"\n  rm \"$3.old\"\n}\n\n# $1 - the config file name found in WEB-INF (e.g. \"xwiki.cfg\")\nfunction saveConfigurationFile() {\n  if [ -f \"/usr/local/xwiki/data/$1\" ]; then\n     echo \"  Reusing existing config file $1...\"\n     cp \"/usr/local/xwiki/data/$1\" \"/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1\"\n  fi\n}\n\n# $1 - the config file name to restore in WEB-INF (e.g. \"xwiki.cfg\")\nfunction restoreConfigurationFile() {\n  if [ -f \"/usr/local/xwiki/data/$1\" ]; then\n     echo \"  Synchronizing config file $1...\"\n     cp \"/usr/local/xwiki/data/$1\" \"/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1\"\n  fi\n}\n\nfunction configure() {\n  echo 'Configuring XWiki...'\n\n  echo 'Setting environment variables'\n  file_env 'DB_USER' 'xwiki'\n  file_env 'DB_PASSWORD' 'xwiki'\n  file_env 'DB_HOST' 'db'\n  file_env 'DB_DATABASE' 'xwiki'\n  file_env 'INDEX_HOST' 'localhost'\n  file_env 'INDEX_PORT' '8983'\n  file_env 'JDBC_PARAMS' '?useSSL=false&amp;connectionTimeZone=LOCAL&amp;allowPublicKeyRetrieval=true'\n\n  echo \"  Deploying XWiki in the '$CONTEXT_PATH' context\"\n  if [ \"$CONTEXT_PATH\" == \"ROOT\" ]; then\n    xwiki_set_cfg 'xwiki.webapppath' ''\n  else\n    mkdir -p -v /usr/local/tomcat/webapps/$CONTEXT_PATH\n    cp -a --update=none /usr/local/tomcat/webapps/ROOT/.  /usr/local/tomcat/webapps/$CONTEXT_PATH/\n  fi\n\n  echo 'Replacing environment variables in files'\n  safesed \"replaceuser\" $DB_USER /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/hibernate.cfg.xml\n  safesed \"replacepassword\" $DB_PASSWORD /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/hibernate.cfg.xml\n  safesed \"replacecontainer\" $DB_HOST /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/hibernate.cfg.xml\n  safesed \"replacedatabase\" $DB_DATABASE /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/hibernate.cfg.xml\n  safesed \"replacejdbcparams\" $JDBC_PARAMS /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/hibernate.cfg.xml\n\n  # Set any non-default main wiki database name in the xwiki.cfg file.\n  if [ \"$DB_DATABASE\" != \"xwiki\" ]; then\n    xwiki_set_cfg \"xwiki.db\" $DB_DATABASE\n  fi\n\n  echo '  Setting permanent directory...'\n  xwiki_set_properties 'environment.permanentDirectory' '/usr/local/xwiki/data'\n  echo '  Configure libreoffice...'\n  xwiki_set_properties 'openoffice.autoStart' 'true'\n\n  if [ $INDEX_HOST != 'localhost' ]; then\n    echo '  Configuring remote Solr Index'\n    xwiki_set_properties 'solr.type' 'remote'\n    xwiki_set_properties 'solr.remote.url' \"http://$INDEX_HOST:$INDEX_PORT/solr/xwiki\"\n  fi\n\n  # If the files already exist then copy them to the XWiki's WEB-INF directory.\n  mkdir -p /usr/local/xwiki/data\n  saveConfigurationFile 'hibernate.cfg.xml'\n  saveConfigurationFile 'xwiki.cfg'\n  saveConfigurationFile 'xwiki.properties'\n}\n\n# This if will check if the first argument is a flag but only works if all arguments require a hyphenated flag\n# -v; -SL; -f arg; etc will work, but not arg1 arg2\nif [ \"${1:0:1}\" = '-' ]; then\n    set -- xwiki \"$@\"\nfi\n\n# Check for the expected command\nif [ \"$1\" = 'xwiki' ]; then\n  file_env 'CONTEXT_PATH' 'ROOT'\n  if [[ ! -f /usr/local/tomcat/webapps/$CONTEXT_PATH/.first_start_completed ]]; then\n    first_start\n  else\n    other_starts\n  fi\n  shift\n  set -- catalina.sh run \"$@\"\nfi\n\n# Else default to run whatever the user wanted like \"bash\"\nexec \"$@\"\n"
  },
  {
    "path": "18/mysql-tomcat/xwiki/hibernate.cfg.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<!--\n * See the NOTICE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n-->\n\n<!DOCTYPE hibernate-configuration PUBLIC\n  \"-//Hibernate/Hibernate Configuration DTD//EN\"\n  \"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd\">\n<hibernate-configuration>\n  <session-factory>\n\n    <!-- Please refer to the installation guide on\n         https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Installation/ for configuring your\n         database. You'll need to do 2 things:\n         1) Copy your database driver JAR in WEB-INF/lib or in some shared lib directory\n         2) Uncomment the properties below for your specific DB (and comment the default\n            database configuration if it doesn't match your DB)\n    -->\n\n    <!-- Generic parameters common to all Databases -->\n\n    <property name=\"show_sql\">false</property>\n    <property name=\"use_outer_join\">true</property>\n\n    <!-- Without it, some queries fail in MS SQL. XWiki doesn't need scrollable result sets, anyway. -->\n    <property name=\"jdbc.use_scrollable_resultset\">false</property>\n\n    <!-- DBCP Connection Pooling configuration. Only some properties are shown. All available properties can be found\n         at https://commons.apache.org/proper/commons-dbcp/configuration.html\n    -->\n    <property name=\"dbcp.defaultAutoCommit\">false</property>\n    <property name=\"dbcp.maxTotal\">50</property>\n    <property name=\"dbcp.maxIdle\">5</property>\n    <property name=\"dbcp.maxWaitMillis\">30000</property>\n    <property name=\"connection.provider_class\">com.xpn.xwiki.store.DBCPConnectionProvider</property>\n\n    <!-- Setting \"dbcp.poolPreparedStatements\" to true and \"dbcp.maxOpenPreparedStatements\" will tell DBCP to cache\n         Prepared Statements (it's off by default). Note that for backward compatibility the \"dbcp.ps.maxActive\" is also\n         supported and when set it'll set \"dbcp.poolPreparedStatements\" to true and \"dbcp.maxOpenPreparedStatements\" to\n         value of \"dbcp.ps.maxActive\".\n\n         Note 1: When using HSQLDB for example, it's important to NOT cache prepared statements because HSQLDB\n         Prepared Statements (PS) contain the schema on which they were initially created and thus when switching\n         schema if the same PS is reused it'll execute on the wrong schema! Since HSQLDB does internally cache\n         prepared statement there's no performance loss by not caching Prepared Statements at the DBCP level.\n         See https://jira.xwiki.org/browse/XWIKI-1740.\n         Thus we recommend not turning on this configuration for HSQLDB unless you know what you're doing :)\n\n         Note 2: The same applies to PostGreSQL.\n    -->\n\n    <!-- BoneCP Connection Pooling configuration.\n    <property name=\"bonecp.idleMaxAgeInMinutes\">240</property>\n    <property name=\"bonecp.idleConnectionTestPeriodInMinutes\">60</property>\n    <property name=\"bonecp.partitionCount\">3</property>\n    <property name=\"bonecp.acquireIncrement\">10</property>\n    <property name=\"bonecp.maxConnectionsPerPartition\">60</property>\n    <property name=\"bonecp.minConnectionsPerPartition\">20</property>\n    <property name=\"bonecp.statementsCacheSize\">50</property>\n    <property name=\"bonecp.releaseHelperThreads\">3</property>\n    <property name=\"connection.provider_class\">com.xpn.xwiki.store.DBCPConnectionProvider</property>\n    -->\n\n    <!-- MySQL configuration.\n         Notes:\n           - If you want the main wiki database to be different than \"xwiki\"\n             you will also have to set the property xwiki.db in xwiki.cfg file\n           - Use the local timezone to work around a bug in the MySQL 8.x which often does not understand the server\n              timezone and crash\n    -->\n    <property name=\"connection.url\">jdbc:mysql://replacecontainer/replacedatabasereplacejdbcparams</property>\n    <property name=\"connection.username\">replaceuser</property>\n    <property name=\"connection.password\">replacepassword</property>\n    <property name=\"connection.driver_class\">com.mysql.cj.jdbc.Driver</property>\n    <property name=\"dbcp.poolPreparedStatements\">true</property>\n    <property name=\"dbcp.maxOpenPreparedStatements\">20</property>\n\n    <property name=\"hibernate.connection.charSet\">UTF-8</property>\n    <property name=\"hibernate.connection.useUnicode\">true</property>\n    <property name=\"hibernate.connection.characterEncoding\">utf8</property>\n\n    <mapping resource=\"xwiki.hbm.xml\"/>\n    <mapping resource=\"feeds.hbm.xml\"/>\n    <mapping resource=\"instance.hbm.xml\"/>\n    <mapping resource=\"notification-filter-preferences.hbm.xml\"/>\n    <mapping resource=\"mailsender.hbm.xml\"/>\n  </session-factory>\n</hibernate-configuration>\n"
  },
  {
    "path": "18/postgres-tomcat/Dockerfile",
    "content": "# ---------------------------------------------------------------------------\n# See the NOTICE file distributed with this work for additional\n# information regarding copyright ownership.\n#\n# This is free software; you can redistribute it and/or modify it\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 2.1 of\n# the License, or (at your option) any later version.\n#\n# This software is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n# Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this software; if not, write to the Free\n# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n# 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n# ---------------------------------------------------------------------------\nFROM tomcat:10-jre21\n\n#    ____  ____  ____      ____  _   __        _\n#   |_  _||_  _||_  _|    |_  _|(_) [  |  _   (_)\n#     \\ \\  / /    \\ \\  /\\  / /  __   | | / ]  __\n#      > `' <      \\ \\/  \\/ /  [  |  | '' <  [  |\n#    _/ /'`\\ \\_     \\  /\\  /    | |  | |`\\ \\  | |\n#   |____||____|     \\/  \\/    [___][__|  \\_][___]\n\nLABEL org.opencontainers.image.authors='XWiki Development Team <committers@xwiki.org>'\nLABEL org.opencontainers.image.url='https://hub.docker.com/_/xwiki'\nLABEL org.opencontainers.image.documentation='https://hub.docker.com/_/xwiki'\nLABEL org.opencontainers.image.source='https://github.com/xwiki/xwiki-docker.git'\nLABEL org.opencontainers.image.vendor='xwiki.org'\nLABEL org.opencontainers.image.licenses='LGPL-2.1'\n\n# Note: when using docker-compose, the ENV values below are overridden from the .env file.\n\n# Install LibreOffice + other tools\n# Note that procps is required to get ps which is used by JODConverter to start LibreOffice\nRUN apt-get update && \\\n  apt-get --no-install-recommends -y install \\\n    curl \\\n    libreoffice \\\n    unzip \\\n    procps && \\\n  rm -rf /var/lib/apt/lists/*\n\n# Install XWiki as the ROOT webapp context in Tomcat\n# Create the Tomcat temporary directory\n# Configure the XWiki permanent directory\nENV XWIKI_VERSION=\"18.3.0\"\nENV XWIKI_URL_PREFIX \"https://maven.xwiki.org/releases/org/xwiki/platform/xwiki-platform-distribution-war/${XWIKI_VERSION}\"\nENV XWIKI_DOWNLOAD_SHA256 3a0594e4260bc832c8a42f9ea1d6f47d9da7c8ffb7bbe65b7c363e7e8308051a\nRUN rm -rf /usr/local/tomcat/webapps/* && \\\n  mkdir -p /usr/local/tomcat/temp && \\\n  mkdir -p /usr/local/xwiki/data && \\\n  curl -fSL \"${XWIKI_URL_PREFIX}/xwiki-platform-distribution-war-${XWIKI_VERSION}.war\" -o xwiki.war && \\\n  echo \"$XWIKI_DOWNLOAD_SHA256 xwiki.war\" | sha256sum -c - && \\\n  unzip -d /usr/local/tomcat/webapps/ROOT xwiki.war && \\\n  rm -f xwiki.war\n\n# Copy the JDBC driver in the XWiki webapp\n# We take the database driver version from the Maven Central repository since we want to control the version \n# used and have it being consistent with what is tested in the CI.\nENV POSTGRES_JDBC_VERSION=\"42.7.11\"\nENV POSTGRES_JDBC_SHA256=\"1981b31d3993c58702783c1cddf10a34e48c1f413d70ff1cb6def0a143484647\"\nENV POSTGRES_JDBC_PREFIX=\"https://repo1.maven.org/maven2/org/postgresql/postgresql/${POSTGRES_JDBC_VERSION}\"\nENV POSTGRES_JDBC_ARTIFACT=\"postgresql-${POSTGRES_JDBC_VERSION}.jar\"\nENV POSTGRES_JDBC_TARGET=\"/usr/local/tomcat/webapps/ROOT/WEB-INF/lib/${POSTGRES_JDBC_ARTIFACT}\"\nRUN curl -fSL \"${POSTGRES_JDBC_PREFIX}/${POSTGRES_JDBC_ARTIFACT}\" -o $POSTGRES_JDBC_TARGET && \\\n  echo \"$POSTGRES_JDBC_SHA256 $POSTGRES_JDBC_TARGET\" | sha256sum -c -\n\n# Configure Tomcat. For example set the memory for the Tomcat JVM since the default value is too small for XWiki\nCOPY tomcat/setenv.sh /usr/local/tomcat/bin/\n\n# Setup the XWiki Hibernate configuration\nCOPY xwiki/hibernate.cfg.xml /usr/local/tomcat/webapps/ROOT/WEB-INF/hibernate.cfg.xml\n\n# Set a specific distribution id in XWiki for this docker packaging.\nRUN sed -i 's/<id>org.xwiki.platform:xwiki-platform-distribution-war/<id>org.xwiki.platform:xwiki-platform-distribution-docker/' \\\n  /usr/local/tomcat/webapps/ROOT/META-INF/extension.xed\n\n# Add scripts required to make changes to XWiki configuration files at execution time\n# Note: we don't run CHMOD since 1) it's not required since the executabe bit is already set in git and 2) running\n# CHMOD after a COPY will sometimes fail, depending on different host-specific factors (especially on AUFS).\nCOPY xwiki/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh\n\n# Make the XWiki directory (the permanent directory is included in it) persist on the host (so that it's not recreated\n# across runs)\nVOLUME /usr/local/xwiki\n\n# At this point the image is done and what remains below are the runtime configuration used by the user to configure\n# the container that will be created out of the image. Namely the user can override some environment variables with\n#   docker run -e \"var1=val1\" -e \"var2=val2\" ...\n# The supported environment variables that can be overridden are:\n# - DB_USER: the name of the user configured for XWiki in the DB. Default is \"xwiki\". This is used to configure\n#            xwiki's hibernate.cfg.xml file.\n# - DB_PASSWORD: the password for the user configured for XWiki in the DB. Default is \"xwiki\". This is used to\n#                configure xwiki's hibernate.cfg.xml file.\n# - DB_DATABASE: the name of the database to use. Default is \"xwiki\". This is used to configure xwiki's\n#                hibernate.cfg.xml file.\n# - DB_HOST: The name of the host (or docker container) containing the database. Default is \"db\". This is used to\n#            configure xwiki's hibernate.cfg.xml file.\n# - CONTEXT_PATH: The name of the context path under which XWiki will be deployed in Tomcat. If not specified then it'll\n#                 be deployed as ROOT.\n# - JDBC_PARAMS: Replaces the default JDBC parameters with the passed ones.\n\n# Example:\n#   docker run -it -e \"DB_USER=xwiki\" -e \"DB_PASSWORD=xwiki\" <imagename>\n\n# Starts XWiki by starting Tomcat. All options passed to \"docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]\"\n# are also passed to docker-entrypoint.sh. If \"xwiki\" is passed then XWiki will be configured the first time the\n# container executes and Tomcat will be started. If some other parameter is passed then it'll be executed to comply\n# with best practices defined at https://github.com/docker-library/official-images#consistency.\nENTRYPOINT [\"docker-entrypoint.sh\"]\nCMD [\"xwiki\"]\n"
  },
  {
    "path": "18/postgres-tomcat/docker-compose.yml",
    "content": "# ---------------------------------------------------------------------------\n# See the NOTICE file distributed with this work for additional\n# information regarding copyright ownership.\n#\n# This is free software; you can redistribute it and/or modify it\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 2.1 of\n# the License, or (at your option) any later version.\n#\n# This software is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n# Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this software; if not, write to the Free\n# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n# 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n# ---------------------------------------------------------------------------\nversion: '2'\nnetworks:\n  bridge:\n    driver: bridge\nservices:\n  # The container that runs XWiki in Tomcat, with the appropriate JDBC driver (for postgres).\n  web:\n    image: \"xwiki:${XWIKI_VERSION}-postgres-tomcat\"\n    container_name: xwiki-postgres-tomcat-web\n    depends_on:\n      - db\n    ports:\n      - \"8080:8080\"\n    # Default values defined in .env file.\n    # The DB_USER/DB_PASSWORD/DB_DATABASE/DB_HOST variables are used in the hibernate.cfg.xml file.\n    environment:\n      - XWIKI_VERSION=${XWIKI_VERSION}\n      - DB_USER=${DB_USER}\n      - DB_PASSWORD=${DB_PASSWORD}\n      - DB_DATABASE=${DB_DATABASE}\n      - DB_HOST=xwiki-postgres-db\n    # Provide a name instead of an auto-generated id for xwiki data (the permanent directory in included in it)\n    # configured in the Dockerfile, to make it simpler to identify in 'docker volume ls'.\n    volumes:\n      - xwiki-data:/usr/local/xwiki\n    networks:\n      - bridge\n  # The container that runs the database (postgres)\n  db:\n    image: \"postgres:18\"\n    container_name: xwiki-postgres-db\n    volumes:\n      - postgres-data:/var/lib/postgresql\n    environment:\n      - POSTGRES_ROOT_PASSWORD=${POSTGRES_ROOT_PASSWORD}\n      - POSTGRES_PASSWORD=${DB_PASSWORD}\n      - POSTGRES_USER=${DB_USER}\n      - POSTGRES_DB=${DB_DATABASE}\n      - POSTGRES_INITDB_ARGS=--encoding=UTF8 --locale-provider=builtin --locale=C.UTF-8\n    networks:\n      - bridge\nvolumes:\n  postgres-data: {}\n  xwiki-data: {}\n"
  },
  {
    "path": "18/postgres-tomcat/tomcat/setenv.sh",
    "content": "#!/bin/bash\n# ---------------------------------------------------------------------------\n# See the NOTICE file distributed with this work for additional\n# information regarding copyright ownership.\n#\n# This is free software; you can redistribute it and/or modify it\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 2.1 of\n# the License, or (at your option) any later version.\n#\n# This software is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n# Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this software; if not, write to the Free\n# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n# 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n# ---------------------------------------------------------------------------\n\n# We're making the following changes to the default:\n# * Adding more memory (default is 512MB which is not enough for XWiki)\n# * By default, Tomcat does not allow the usage of encoded slash '%2F' and backslash '%5C' in URLs, as noted in\n#   https://tomcat.apache.org/security-6.html#Fixed_in_Apache_Tomcat_6.0.10. We want to allow for them as it's useful to\n#   be able to have '/' and '' in wiki page names.\n# * On some system /dev/random is slow to init leading to a slow Tomcat and thus Xwiki startup.\n\n# Users can override these values by setting the JAVA_OPTS environment variable. For example:\n# -e JAVA_OPTS=\"-Xmx2048m\"\n\nXMX=\"-Xmx1024m\"\nALLOW_ENCODED_SLASH=\"-Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true\"\nALLOW_BACKSLASH=\"-Dorg.apache.catalina.connector.CoyoteAdapter.ALLOW_BACKSLASH=true\"\nSECURERANDOM=\"-Djava.security.egd=file:/dev/./urandom\"\n\nif [[ ! -z \"$JAVA_OPTS\" ]]; then\n  if [[ ! $JAVA_OPTS =~ .*-Xmx[0-9]+.* ]]; then\n    JAVA_OPTS=\"$JAVA_OPTS $XMX\"\n  fi\n  if [[ ! $JAVA_OPTS =~ .*ALLOW_ENCODED_SLASH.* ]]; then\n    JAVA_OPTS=\"$JAVA_OPTS $ALLOW_ENCODED_SLASH\"\n  fi\n  if [[ ! $JAVA_OPTS =~ .*ALLOW_BACKSLASH.* ]]; then\n    JAVA_OPTS=\"$JAVA_OPTS $ALLOW_BACKSLASH\"\n  fi\n  if [[ ! $JAVA_OPTS =~ .*java\\.security\\.egd.* ]]; then\n    JAVA_OPTS=\"$JAVA_OPTS $SECURERANDOM\"\n  fi\nelse\n  JAVA_OPTS=\"$XMX $ALLOW_ENCODED_SLASH $ALLOW_BACKSLASH $SECURERANDOM\"\nfi\n\nexport JAVA_OPTS\n"
  },
  {
    "path": "18/postgres-tomcat/xwiki/docker-entrypoint.sh",
    "content": "#!/bin/bash\n# ---------------------------------------------------------------------------\n# See the NOTICE file distributed with this work for additional\n# information regarding copyright ownership.\n#\n# This is free software; you can redistribute it and/or modify it\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 2.1 of\n# the License, or (at your option) any later version.\n#\n# This software is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n# Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this software; if not, write to the Free\n# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n# 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n# ---------------------------------------------------------------------------\n\nset -e\n\nfunction first_start() {\n  configure\n  touch /usr/local/tomcat/webapps/$CONTEXT_PATH/.first_start_completed\n}\n\nfunction other_starts() {\n  mkdir -p /usr/local/xwiki/data\n  restoreConfigurationFile 'hibernate.cfg.xml'\n  restoreConfigurationFile 'xwiki.cfg'\n  restoreConfigurationFile 'xwiki.properties'\n}\n\n# $1 - the path to xwiki.[cfg|properties]\n# $2 - the setting/property to set\n# $3 - the new value\nfunction xwiki_replace() {\n  # Don't use \"sed -i\" as it creates a temporary file and perform a rename (thus changing the inode of the initial file)\n  # which makes it fail if you map the initial file as a Docker volume mount.\n  sed s~\"\\#\\? \\?$2 \\?=.*\"~\"$2=$3\"~g \"$1\" > \"$1.old\"\n  cp \"$1.old\" \"$1\"\n  rm \"$1.old\"\n}\n\n# $1 - the setting/property to set\n# $2 - the new value\nfunction xwiki_set_cfg() {\n  xwiki_replace /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/xwiki.cfg \"$1\" \"$2\"\n}\n\n# $1 - the setting/property to set\n# $2 - the new value\nfunction xwiki_set_properties() {\n  xwiki_replace /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/xwiki.properties \"$1\" \"$2\"\n}\n\n# usage: file_env VAR [DEFAULT]\n#    ie: file_env 'XYZ_DB_PASSWORD' 'example'\n# (will allow for \"$XYZ_DB_PASSWORD_FILE\" to fill in the value of\n#  \"$XYZ_DB_PASSWORD\" from a file, especially for Docker's secrets feature)\nfile_env() {\n  local var=\"$1\"\n  local fileVar=\"${var}_FILE\"\n  local def=\"${2:-}\"\n  if [ \"${!var:-}\" ] && [ \"${!fileVar:-}\" ]; then\n    echo >&2 \"error: both $var and $fileVar are set (but are exclusive)\"\n    exit 1\n  fi\n  local val=\"$def\"\n  if [ \"${!var:-}\" ]; then\n    val=\"${!var}\"\n  elif [ \"${!fileVar:-}\" ]; then\n    val=\"$(< \"${!fileVar}\")\"\n  fi\n  export \"$var\"=\"$val\"\n  unset \"$fileVar\"\n}\n\n# Allows to use sed but with user input which can contain special sed characters such as \\, / or &.\n# $1 - the text to search for\n# $2 - the replacement text\n# $3 - the file in which to do the search/replace\nfunction safesed {\n  # Don't use \"sed -i\" as it creates a temporary file and perform a rename (thus changing the inode of the initial file)\n  # which makes it fail if you map the initial file as a Docker volume mount.\n  sed \"s/$(echo $1 | sed -e 's/\\([[\\/.*]\\|\\]\\)/\\\\&/g')/$(echo $2 | sed -e 's/[\\/&]/\\\\&/g')/g\" \"$3\" > \"$3.old\"\n  cp \"$3.old\" \"$3\"\n  rm \"$3.old\"\n}\n\n# $1 - the config file name found in WEB-INF (e.g. \"xwiki.cfg\")\nfunction saveConfigurationFile() {\n  if [ -f \"/usr/local/xwiki/data/$1\" ]; then\n     echo \"  Reusing existing config file $1...\"\n     cp \"/usr/local/xwiki/data/$1\" \"/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1\"\n  fi\n}\n\n# $1 - the config file name to restore in WEB-INF (e.g. \"xwiki.cfg\")\nfunction restoreConfigurationFile() {\n  if [ -f \"/usr/local/xwiki/data/$1\" ]; then\n     echo \"  Synchronizing config file $1...\"\n     cp \"/usr/local/xwiki/data/$1\" \"/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1\"\n  fi\n}\n\nfunction configure() {\n  echo 'Configuring XWiki...'\n\n  echo 'Setting environment variables'\n  file_env 'DB_USER' 'xwiki'\n  file_env 'DB_PASSWORD' 'xwiki'\n  file_env 'DB_HOST' 'db'\n  file_env 'DB_DATABASE' 'xwiki'\n  file_env 'INDEX_HOST' 'localhost'\n  file_env 'INDEX_PORT' '8983'\n  file_env 'JDBC_PARAMS' '?'\n\n  echo \"  Deploying XWiki in the '$CONTEXT_PATH' context\"\n  if [ \"$CONTEXT_PATH\" == \"ROOT\" ]; then\n    xwiki_set_cfg 'xwiki.webapppath' ''\n  else\n    mkdir -p -v /usr/local/tomcat/webapps/$CONTEXT_PATH\n    cp -a --update=none /usr/local/tomcat/webapps/ROOT/.  /usr/local/tomcat/webapps/$CONTEXT_PATH/\n  fi\n\n  echo 'Replacing environment variables in files'\n  safesed \"replaceuser\" $DB_USER /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/hibernate.cfg.xml\n  safesed \"replacepassword\" $DB_PASSWORD /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/hibernate.cfg.xml\n  safesed \"replacecontainer\" $DB_HOST /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/hibernate.cfg.xml\n  safesed \"replacedatabase\" $DB_DATABASE /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/hibernate.cfg.xml\n  safesed \"replacejdbcparams\" $JDBC_PARAMS /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/hibernate.cfg.xml\n\n  \n\n  echo '  Setting permanent directory...'\n  xwiki_set_properties 'environment.permanentDirectory' '/usr/local/xwiki/data'\n  echo '  Configure libreoffice...'\n  xwiki_set_properties 'openoffice.autoStart' 'true'\n\n  if [ $INDEX_HOST != 'localhost' ]; then\n    echo '  Configuring remote Solr Index'\n    xwiki_set_properties 'solr.type' 'remote'\n    xwiki_set_properties 'solr.remote.url' \"http://$INDEX_HOST:$INDEX_PORT/solr/xwiki\"\n  fi\n\n  # If the files already exist then copy them to the XWiki's WEB-INF directory.\n  mkdir -p /usr/local/xwiki/data\n  saveConfigurationFile 'hibernate.cfg.xml'\n  saveConfigurationFile 'xwiki.cfg'\n  saveConfigurationFile 'xwiki.properties'\n}\n\n# This if will check if the first argument is a flag but only works if all arguments require a hyphenated flag\n# -v; -SL; -f arg; etc will work, but not arg1 arg2\nif [ \"${1:0:1}\" = '-' ]; then\n    set -- xwiki \"$@\"\nfi\n\n# Check for the expected command\nif [ \"$1\" = 'xwiki' ]; then\n  file_env 'CONTEXT_PATH' 'ROOT'\n  if [[ ! -f /usr/local/tomcat/webapps/$CONTEXT_PATH/.first_start_completed ]]; then\n    first_start\n  else\n    other_starts\n  fi\n  shift\n  set -- catalina.sh run \"$@\"\nfi\n\n# Else default to run whatever the user wanted like \"bash\"\nexec \"$@\"\n"
  },
  {
    "path": "18/postgres-tomcat/xwiki/hibernate.cfg.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<!--\n * See the NOTICE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n-->\n\n<!DOCTYPE hibernate-configuration PUBLIC\n  \"-//Hibernate/Hibernate Configuration DTD//EN\"\n  \"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd\">\n<hibernate-configuration>\n  <session-factory>\n\n    <!-- Please refer to the installation guide on\n         https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Installation/ for configuring your\n         database. You'll need to do 2 things:\n         1) Copy your database driver JAR in WEB-INF/lib or in some shared lib directory\n         2) Uncomment the properties below for your specific DB (and comment the default\n            database configuration if it doesn't match your DB)\n    -->\n\n    <!-- Generic parameters common to all Databases -->\n\n    <property name=\"show_sql\">false</property>\n    <property name=\"use_outer_join\">true</property>\n\n    <!-- Without it, some queries fail in MS SQL. XWiki doesn't need scrollable result sets, anyway. -->\n    <property name=\"jdbc.use_scrollable_resultset\">false</property>\n\n    <!-- DBCP Connection Pooling configuration. Only some properties are shown. All available properties can be found\n         at https://commons.apache.org/proper/commons-dbcp/configuration.html\n    -->\n    <property name=\"dbcp.defaultAutoCommit\">false</property>\n    <property name=\"dbcp.maxTotal\">50</property>\n    <property name=\"dbcp.maxIdle\">5</property>\n    <property name=\"dbcp.maxWaitMillis\">30000</property>\n    <property name=\"connection.provider_class\">com.xpn.xwiki.store.DBCPConnectionProvider</property>\n\n    <!-- Setting \"dbcp.poolPreparedStatements\" to true and \"dbcp.maxOpenPreparedStatements\" will tell DBCP to cache\n         Prepared Statements (it's off by default). Note that for backward compatibility the \"dbcp.ps.maxActive\" is also\n         supported and when set it'll set \"dbcp.poolPreparedStatements\" to true and \"dbcp.maxOpenPreparedStatements\" to\n         value of \"dbcp.ps.maxActive\".\n\n         Note 1: When using HSQLDB for example, it's important to NOT cache prepared statements because HSQLDB\n         Prepared Statements (PS) contain the schema on which they were initially created and thus when switching\n         schema if the same PS is reused it'll execute on the wrong schema! Since HSQLDB does internally cache\n         prepared statement there's no performance loss by not caching Prepared Statements at the DBCP level.\n         See https://jira.xwiki.org/browse/XWIKI-1740.\n         Thus we recommend not turning on this configuration for HSQLDB unless you know what you're doing :)\n\n         Note 2: The same applies to PostGreSQL.\n    -->\n\n    <!-- BoneCP Connection Pooling configuration.\n    <property name=\"bonecp.idleMaxAgeInMinutes\">240</property>\n    <property name=\"bonecp.idleConnectionTestPeriodInMinutes\">60</property>\n    <property name=\"bonecp.partitionCount\">3</property>\n    <property name=\"bonecp.acquireIncrement\">10</property>\n    <property name=\"bonecp.maxConnectionsPerPartition\">60</property>\n    <property name=\"bonecp.minConnectionsPerPartition\">20</property>\n    <property name=\"bonecp.statementsCacheSize\">50</property>\n    <property name=\"bonecp.releaseHelperThreads\">3</property>\n    <property name=\"connection.provider_class\">com.xpn.xwiki.store.DBCPConnectionProvider</property>\n    -->\n\n    <!-- PostgreSQL configuration.\n         Notes:\n           - \"jdbc.use_streams_for_binary\" needs to be set to \"false\",\n             see https://community.jboss.org/wiki/HibernateCoreMigrationGuide36\n           - \"xwiki.virtual_mode\" can be set to either \"schema\" or \"database\". Note that currently the database mode\n             doesn't support database creation (see https://jira.xwiki.org/browse/XWIKI-8753)\n           - if you want the main wiki database to be different than \"xwiki\" (or \"public\" in schema mode)\n             you will also have to set the property xwiki.db in xwiki.cfg file\n    -->\n    <property name=\"connection.url\">jdbc:postgresql://replacecontainer:5432/replacedatabasereplacejdbcparams</property>\n    <property name=\"connection.username\">replaceuser</property>\n    <property name=\"connection.password\">replacepassword</property>\n    <property name=\"connection.driver_class\">org.postgresql.Driver</property>\n    <property name=\"jdbc.use_streams_for_binary\">false</property>\n    <property name=\"xwiki.virtual_mode\">schema</property>\n\n    <property name=\"hibernate.connection.charSet\">UTF-8</property>\n    <property name=\"hibernate.connection.useUnicode\">true</property>\n    <property name=\"hibernate.connection.characterEncoding\">utf8</property>\n\n    <mapping resource=\"xwiki.postgresql.hbm.xml\"/>\n    <mapping resource=\"feeds.hbm.xml\"/>\n    <mapping resource=\"instance.hbm.xml\"/>\n    <mapping resource=\"notification-filter-preferences.hbm.xml\"/>\n    <mapping resource=\"mailsender.hbm.xml\"/>\n  </session-factory>\n</hibernate-configuration>\n"
  },
  {
    "path": "LICENSE",
    "content": "                  GNU LESSER GENERAL PUBLIC LICENSE\n                       Version 2.1, February 1999\n\n Copyright (C) 1991, 1999 Free Software Foundation, Inc.\n 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n(This is the first released version of the Lesser GPL.  It also counts\n as the successor of the GNU Library Public License, version 2, hence\n the version number 2.1.)\n\n                            Preamble\n\n  The licenses for most software are designed to take away your\nfreedom to share and change it.  By contrast, the GNU General Public\nLicenses are intended to guarantee your freedom to share and change\nfree software--to make sure the software is free for all its users.\n\n  This license, the Lesser General Public License, applies to some\nspecially designated software packages--typically libraries--of the\nFree Software Foundation and other authors who decide to use it.  You\ncan use it too, but we suggest you first think carefully about whether\nthis license or the ordinary General Public License is the better\nstrategy to use in any particular case, based on the explanations below.\n\n  When we speak of free software, we are referring to freedom of use,\nnot price.  Our General Public Licenses are designed to make sure that\nyou have the freedom to distribute copies of free software (and charge\nfor this service if you wish); that you receive source code or can get\nit if you want it; that you can change the software and use pieces of\nit in new free programs; and that you are informed that you can do\nthese things.\n\n  To protect your rights, we need to make restrictions that forbid\ndistributors to deny you these rights or to ask you to surrender these\nrights.  These restrictions translate to certain responsibilities for\nyou if you distribute copies of the library or if you modify it.\n\n  For example, if you distribute copies of the library, whether gratis\nor for a fee, you must give the recipients all the rights that we gave\nyou.  You must make sure that they, too, receive or can get the source\ncode.  If you link other code with the library, you must provide\ncomplete object files to the recipients, so that they can relink them\nwith the library after making changes to the library and recompiling\nit.  And you must show them these terms so they know their rights.\n\n  We protect your rights with a two-step method: (1) we copyright the\nlibrary, and (2) we offer you this license, which gives you legal\npermission to copy, distribute and/or modify the library.\n\n  To protect each distributor, we want to make it very clear that\nthere is no warranty for the free library.  Also, if the library is\nmodified by someone else and passed on, the recipients should know\nthat what they have is not the original version, so that the original\nauthor's reputation will not be affected by problems that might be\nintroduced by others.\n\n  Finally, software patents pose a constant threat to the existence of\nany free program.  We wish to make sure that a company cannot\neffectively restrict the users of a free program by obtaining a\nrestrictive license from a patent holder.  Therefore, we insist that\nany patent license obtained for a version of the library must be\nconsistent with the full freedom of use specified in this license.\n\n  Most GNU software, including some libraries, is covered by the\nordinary GNU General Public License.  This license, the GNU Lesser\nGeneral Public License, applies to certain designated libraries, and\nis quite different from the ordinary General Public License.  We use\nthis license for certain libraries in order to permit linking those\nlibraries into non-free programs.\n\n  When a program is linked with a library, whether statically or using\na shared library, the combination of the two is legally speaking a\ncombined work, a derivative of the original library.  The ordinary\nGeneral Public License therefore permits such linking only if the\nentire combination fits its criteria of freedom.  The Lesser General\nPublic License permits more lax criteria for linking other code with\nthe library.\n\n  We call this license the \"Lesser\" General Public License because it\ndoes Less to protect the user's freedom than the ordinary General\nPublic License.  It also provides other free software developers Less\nof an advantage over competing non-free programs.  These disadvantages\nare the reason we use the ordinary General Public License for many\nlibraries.  However, the Lesser license provides advantages in certain\nspecial circumstances.\n\n  For example, on rare occasions, there may be a special need to\nencourage the widest possible use of a certain library, so that it becomes\na de-facto standard.  To achieve this, non-free programs must be\nallowed to use the library.  A more frequent case is that a free\nlibrary does the same job as widely used non-free libraries.  In this\ncase, there is little to gain by limiting the free library to free\nsoftware only, so we use the Lesser General Public License.\n\n  In other cases, permission to use a particular library in non-free\nprograms enables a greater number of people to use a large body of\nfree software.  For example, permission to use the GNU C Library in\nnon-free programs enables many more people to use the whole GNU\noperating system, as well as its variant, the GNU/Linux operating\nsystem.\n\n  Although the Lesser General Public License is Less protective of the\nusers' freedom, it does ensure that the user of a program that is\nlinked with the Library has the freedom and the wherewithal to run\nthat program using a modified version of the Library.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.  Pay close attention to the difference between a\n\"work based on the library\" and a \"work that uses the library\".  The\nformer contains code derived from the library, whereas the latter must\nbe combined with the library in order to run.\n\n                  GNU LESSER GENERAL PUBLIC LICENSE\n   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n\n  0. This License Agreement applies to any software library or other\nprogram which contains a notice placed by the copyright holder or\nother authorized party saying it may be distributed under the terms of\nthis Lesser General Public License (also called \"this License\").\nEach licensee is addressed as \"you\".\n\n  A \"library\" means a collection of software functions and/or data\nprepared so as to be conveniently linked with application programs\n(which use some of those functions and data) to form executables.\n\n  The \"Library\", below, refers to any such software library or work\nwhich has been distributed under these terms.  A \"work based on the\nLibrary\" means either the Library or any derivative work under\ncopyright law: that is to say, a work containing the Library or a\nportion of it, either verbatim or with modifications and/or translated\nstraightforwardly into another language.  (Hereinafter, translation is\nincluded without limitation in the term \"modification\".)\n\n  \"Source code\" for a work means the preferred form of the work for\nmaking modifications to it.  For a library, complete source code means\nall the source code for all modules it contains, plus any associated\ninterface definition files, plus the scripts used to control compilation\nand installation of the library.\n\n  Activities other than copying, distribution and modification are not\ncovered by this License; they are outside its scope.  The act of\nrunning a program using the Library is not restricted, and output from\nsuch a program is covered only if its contents constitute a work based\non the Library (independent of the use of the Library in a tool for\nwriting it).  Whether that is true depends on what the Library does\nand what the program that uses the Library does.\n\n  1. You may copy and distribute verbatim copies of the Library's\ncomplete source code as you receive it, in any medium, provided that\nyou conspicuously and appropriately publish on each copy an\nappropriate copyright notice and disclaimer of warranty; keep intact\nall the notices that refer to this License and to the absence of any\nwarranty; and distribute a copy of this License along with the\nLibrary.\n\n  You may charge a fee for the physical act of transferring a copy,\nand you may at your option offer warranty protection in exchange for a\nfee.\n\n  2. You may modify your copy or copies of the Library or any portion\nof it, thus forming a work based on the Library, and copy and\ndistribute such modifications or work under the terms of Section 1\nabove, provided that you also meet all of these conditions:\n\n    a) The modified work must itself be a software library.\n\n    b) You must cause the files modified to carry prominent notices\n    stating that you changed the files and the date of any change.\n\n    c) You must cause the whole of the work to be licensed at no\n    charge to all third parties under the terms of this License.\n\n    d) If a facility in the modified Library refers to a function or a\n    table of data to be supplied by an application program that uses\n    the facility, other than as an argument passed when the facility\n    is invoked, then you must make a good faith effort to ensure that,\n    in the event an application does not supply such function or\n    table, the facility still operates, and performs whatever part of\n    its purpose remains meaningful.\n\n    (For example, a function in a library to compute square roots has\n    a purpose that is entirely well-defined independent of the\n    application.  Therefore, Subsection 2d requires that any\n    application-supplied function or table used by this function must\n    be optional: if the application does not supply it, the square\n    root function must still compute square roots.)\n\nThese requirements apply to the modified work as a whole.  If\nidentifiable sections of that work are not derived from the Library,\nand can be reasonably considered independent and separate works in\nthemselves, then this License, and its terms, do not apply to those\nsections when you distribute them as separate works.  But when you\ndistribute the same sections as part of a whole which is a work based\non the Library, the distribution of the whole must be on the terms of\nthis License, whose permissions for other licensees extend to the\nentire whole, and thus to each and every part regardless of who wrote\nit.\n\nThus, it is not the intent of this section to claim rights or contest\nyour rights to work written entirely by you; rather, the intent is to\nexercise the right to control the distribution of derivative or\ncollective works based on the Library.\n\nIn addition, mere aggregation of another work not based on the Library\nwith the Library (or with a work based on the Library) on a volume of\na storage or distribution medium does not bring the other work under\nthe scope of this License.\n\n  3. You may opt to apply the terms of the ordinary GNU General Public\nLicense instead of this License to a given copy of the Library.  To do\nthis, you must alter all the notices that refer to this License, so\nthat they refer to the ordinary GNU General Public License, version 2,\ninstead of to this License.  (If a newer version than version 2 of the\nordinary GNU General Public License has appeared, then you can specify\nthat version instead if you wish.)  Do not make any other change in\nthese notices.\n\n  Once this change is made in a given copy, it is irreversible for\nthat copy, so the ordinary GNU General Public License applies to all\nsubsequent copies and derivative works made from that copy.\n\n  This option is useful when you wish to copy part of the code of\nthe Library into a program that is not a library.\n\n  4. You may copy and distribute the Library (or a portion or\nderivative of it, under Section 2) in object code or executable form\nunder the terms of Sections 1 and 2 above provided that you accompany\nit with the complete corresponding machine-readable source code, which\nmust be distributed under the terms of Sections 1 and 2 above on a\nmedium customarily used for software interchange.\n\n  If distribution of object code is made by offering access to copy\nfrom a designated place, then offering equivalent access to copy the\nsource code from the same place satisfies the requirement to\ndistribute the source code, even though third parties are not\ncompelled to copy the source along with the object code.\n\n  5. A program that contains no derivative of any portion of the\nLibrary, but is designed to work with the Library by being compiled or\nlinked with it, is called a \"work that uses the Library\".  Such a\nwork, in isolation, is not a derivative work of the Library, and\ntherefore falls outside the scope of this License.\n\n  However, linking a \"work that uses the Library\" with the Library\ncreates an executable that is a derivative of the Library (because it\ncontains portions of the Library), rather than a \"work that uses the\nlibrary\".  The executable is therefore covered by this License.\nSection 6 states terms for distribution of such executables.\n\n  When a \"work that uses the Library\" uses material from a header file\nthat is part of the Library, the object code for the work may be a\nderivative work of the Library even though the source code is not.\nWhether this is true is especially significant if the work can be\nlinked without the Library, or if the work is itself a library.  The\nthreshold for this to be true is not precisely defined by law.\n\n  If such an object file uses only numerical parameters, data\nstructure layouts and accessors, and small macros and small inline\nfunctions (ten lines or less in length), then the use of the object\nfile is unrestricted, regardless of whether it is legally a derivative\nwork.  (Executables containing this object code plus portions of the\nLibrary will still fall under Section 6.)\n\n  Otherwise, if the work is a derivative of the Library, you may\ndistribute the object code for the work under the terms of Section 6.\nAny executables containing that work also fall under Section 6,\nwhether or not they are linked directly with the Library itself.\n\n  6. As an exception to the Sections above, you may also combine or\nlink a \"work that uses the Library\" with the Library to produce a\nwork containing portions of the Library, and distribute that work\nunder terms of your choice, provided that the terms permit\nmodification of the work for the customer's own use and reverse\nengineering for debugging such modifications.\n\n  You must give prominent notice with each copy of the work that the\nLibrary is used in it and that the Library and its use are covered by\nthis License.  You must supply a copy of this License.  If the work\nduring execution displays copyright notices, you must include the\ncopyright notice for the Library among them, as well as a reference\ndirecting the user to the copy of this License.  Also, you must do one\nof these things:\n\n    a) Accompany the work with the complete corresponding\n    machine-readable source code for the Library including whatever\n    changes were used in the work (which must be distributed under\n    Sections 1 and 2 above); and, if the work is an executable linked\n    with the Library, with the complete machine-readable \"work that\n    uses the Library\", as object code and/or source code, so that the\n    user can modify the Library and then relink to produce a modified\n    executable containing the modified Library.  (It is understood\n    that the user who changes the contents of definitions files in the\n    Library will not necessarily be able to recompile the application\n    to use the modified definitions.)\n\n    b) Use a suitable shared library mechanism for linking with the\n    Library.  A suitable mechanism is one that (1) uses at run time a\n    copy of the library already present on the user's computer system,\n    rather than copying library functions into the executable, and (2)\n    will operate properly with a modified version of the library, if\n    the user installs one, as long as the modified version is\n    interface-compatible with the version that the work was made with.\n\n    c) Accompany the work with a written offer, valid for at\n    least three years, to give the same user the materials\n    specified in Subsection 6a, above, for a charge no more\n    than the cost of performing this distribution.\n\n    d) If distribution of the work is made by offering access to copy\n    from a designated place, offer equivalent access to copy the above\n    specified materials from the same place.\n\n    e) Verify that the user has already received a copy of these\n    materials or that you have already sent this user a copy.\n\n  For an executable, the required form of the \"work that uses the\nLibrary\" must include any data and utility programs needed for\nreproducing the executable from it.  However, as a special exception,\nthe materials to be distributed need not include anything that is\nnormally distributed (in either source or binary form) with the major\ncomponents (compiler, kernel, and so on) of the operating system on\nwhich the executable runs, unless that component itself accompanies\nthe executable.\n\n  It may happen that this requirement contradicts the license\nrestrictions of other proprietary libraries that do not normally\naccompany the operating system.  Such a contradiction means you cannot\nuse both them and the Library together in an executable that you\ndistribute.\n\n  7. You may place library facilities that are a work based on the\nLibrary side-by-side in a single library together with other library\nfacilities not covered by this License, and distribute such a combined\nlibrary, provided that the separate distribution of the work based on\nthe Library and of the other library facilities is otherwise\npermitted, and provided that you do these two things:\n\n    a) Accompany the combined library with a copy of the same work\n    based on the Library, uncombined with any other library\n    facilities.  This must be distributed under the terms of the\n    Sections above.\n\n    b) Give prominent notice with the combined library of the fact\n    that part of it is a work based on the Library, and explaining\n    where to find the accompanying uncombined form of the same work.\n\n  8. You may not copy, modify, sublicense, link with, or distribute\nthe Library except as expressly provided under this License.  Any\nattempt otherwise to copy, modify, sublicense, link with, or\ndistribute the Library is void, and will automatically terminate your\nrights under this License.  However, parties who have received copies,\nor rights, from you under this License will not have their licenses\nterminated so long as such parties remain in full compliance.\n\n  9. You are not required to accept this License, since you have not\nsigned it.  However, nothing else grants you permission to modify or\ndistribute the Library or its derivative works.  These actions are\nprohibited by law if you do not accept this License.  Therefore, by\nmodifying or distributing the Library (or any work based on the\nLibrary), you indicate your acceptance of this License to do so, and\nall its terms and conditions for copying, distributing or modifying\nthe Library or works based on it.\n\n  10. Each time you redistribute the Library (or any work based on the\nLibrary), the recipient automatically receives a license from the\noriginal licensor to copy, distribute, link with or modify the Library\nsubject to these terms and conditions.  You may not impose any further\nrestrictions on the recipients' exercise of the rights granted herein.\nYou are not responsible for enforcing compliance by third parties with\nthis License.\n\n  11. If, as a consequence of a court judgment or allegation of patent\ninfringement or for any other reason (not limited to patent issues),\nconditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot\ndistribute so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you\nmay not distribute the Library at all.  For example, if a patent\nlicense would not permit royalty-free redistribution of the Library by\nall those who receive copies directly or indirectly through you, then\nthe only way you could satisfy both it and this License would be to\nrefrain entirely from distribution of the Library.\n\nIf any portion of this section is held invalid or unenforceable under any\nparticular circumstance, the balance of the section is intended to apply,\nand the section as a whole is intended to apply in other circumstances.\n\nIt is not the purpose of this section to induce you to infringe any\npatents or other property right claims or to contest validity of any\nsuch claims; this section has the sole purpose of protecting the\nintegrity of the free software distribution system which is\nimplemented by public license practices.  Many people have made\ngenerous contributions to the wide range of software distributed\nthrough that system in reliance on consistent application of that\nsystem; it is up to the author/donor to decide if he or she is willing\nto distribute software through any other system and a licensee cannot\nimpose that choice.\n\nThis section is intended to make thoroughly clear what is believed to\nbe a consequence of the rest of this License.\n\n  12. If the distribution and/or use of the Library is restricted in\ncertain countries either by patents or by copyrighted interfaces, the\noriginal copyright holder who places the Library under this License may add\nan explicit geographical distribution limitation excluding those countries,\nso that distribution is permitted only in or among countries not thus\nexcluded.  In such case, this License incorporates the limitation as if\nwritten in the body of this License.\n\n  13. The Free Software Foundation may publish revised and/or new\nversions of the Lesser General Public License from time to time.\nSuch new versions will be similar in spirit to the present version,\nbut may differ in detail to address new problems or concerns.\n\nEach version is given a distinguishing version number.  If the Library\nspecifies a version number of this License which applies to it and\n\"any later version\", you have the option of following the terms and\nconditions either of that version or of any later version published by\nthe Free Software Foundation.  If the Library does not specify a\nlicense version number, you may choose any version ever published by\nthe Free Software Foundation.\n\n  14. If you wish to incorporate parts of the Library into other free\nprograms whose distribution conditions are incompatible with these,\nwrite to the author to ask for permission.  For software which is\ncopyrighted by the Free Software Foundation, write to the Free\nSoftware Foundation; we sometimes make exceptions for this.  Our\ndecision will be guided by the two goals of preserving the free status\nof all derivatives of our free software and of promoting the sharing\nand reuse of software generally.\n\n                            NO WARRANTY\n\n  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO\nWARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.\nEXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR\nOTHER PARTIES PROVIDE THE LIBRARY \"AS IS\" WITHOUT WARRANTY OF ANY\nKIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE\nLIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME\nTHE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN\nWRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY\nAND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU\nFOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR\nCONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE\nLIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING\nRENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A\nFAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF\nSUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\nDAMAGES.\n\n                     END OF TERMS AND CONDITIONS\n\n           How to Apply These Terms to Your New Libraries\n\n  If you develop a new library, and you want it to be of the greatest\npossible use to the public, we recommend making it free software that\neveryone can redistribute and change.  You can do so by permitting\nredistribution under these terms (or, alternatively, under the terms of the\nordinary General Public License).\n\n  To apply these terms, attach the following notices to the library.  It is\nsafest to attach them to the start of each source file to most effectively\nconvey the exclusion of warranty; and each file should have at least the\n\"copyright\" line and a pointer to where the full notice is found.\n\n    {description}\n    Copyright (C) {year} {fullname}\n\n    This library is free software; you can redistribute it and/or\n    modify it under the terms of the GNU Lesser General Public\n    License as published by the Free Software Foundation; either\n    version 2.1 of the License, or (at your option) any later version.\n\n    This library is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n    Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public\n    License along with this library; if not, write to the Free Software\n    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301\n    USA\n\nAlso add information on how to contact you by electronic and paper mail.\n\nYou should also get your employer (if you work as a programmer) or your\nschool, if any, to sign a \"copyright disclaimer\" for the library, if\nnecessary.  Here is a sample; alter the names:\n\n  Yoyodyne, Inc., hereby disclaims all copyright interest in the\n  library `Frob' (a library for tweaking knobs) written by James Random\n  Hacker.\n\n  {signature of Ty Coon}, 1 April 1990\n  Ty Coon, President of Vice\n\nThat's all there is to it!\n\n"
  },
  {
    "path": "README.md",
    "content": "# What is XWiki\n\n[XWiki](https://xwiki.org/) is a free and open source wiki software platform written in Java with a design emphasis on extensibility.\n\nSee the documentation of [XWiki.org](https://xwiki.org/) or [Wikipedia's article about XWiki](https://en.wikipedia.org/wiki/XWiki) to know more about XWiki.\n\n![logo](https://www.xwiki.org/xwiki/bin/download/Main/Logo/logo-xwikiorange.svg)\n\n# Table of contents\n\n<!-- Can be generated with pandoc -f gfm --toc -o readme-toc.md README.md -->\n\n- [Introduction](#introduction)\n- [How to use this image](#how-to-use-this-image)\n    -\t[Pulling an existing image](#pulling-an-existing-image)\n        -\t[Using `docker run`](#using-docker-run)\n        -\t[Using `docker-compose`](#using-docker-compose)\n        -\t[Using Docker Swarm](#using-docker-swarm)\n    -\t[Building](#building)\n- [Upgrading XWiki](#upgrading-xwiki)\n- [Details for the xwiki image](#details-for-the-xwiki-image)\n    -\t[Configuration Options](#configuration-options)\n    -\t[Passing JVM options](#passing-jvm-options)\n    -\t[Remote Debugging](#remote-debugging)\n    -\t[Configuration Files](#configuration-files)\n    -\t[Configuring Tomcat](#configuring-tomcat)\n    -\t[Miscellaneous](#miscellaneous)\n- [Using an external Solr service](#using-an-external-solr-service)\n    -\t[Preparing Solr container](#preparing-solr-container)\n    -\t[Example with `docker run`](#docker-run-example)\n    -\t[Example with `docker-compose`](#docker-compose-example)\n- [Troubleshooting](#troubleshooting)\n- [For Maintainers](#for-maintainers)\n    -\t[Update Docker Images](#update-docker-images)\n    -\t[Testing Docker Images](#testing-docker-images)\n    -\t[Clean Up](#clean-up)\n- [License](#license)\n- [Support](#support)\n- [Contribute](#contribute)\n- [Credits](#credits)\n\n# Introduction\n\nThe goal is to provide a production-ready XWiki system running in Docker. This is why:\n\n-\tThe OS is based on Debian and not on some smaller-footprint distribution like Alpine\n-\tSeveral containers are used with Docker Compose: one for the DB and another for XWiki + Servlet container. This provides the ability to run them on different machines for example. \n\n# How to use this image\n\nYou should first install [Docker](https://www.docker.com/) on your machine.\n\nThen, there are several options:\n\n1.\tPull the `xwiki` image from DockerHub.\n2.\tGet the [sources of this project](https://github.com/xwiki-contrib/docker-xwiki) and build them.\n\n## Pulling an existing image\n\nYou need to run 2 containers:\n\n-\tOne for the XWiki image\n-\tOne for the database image to which XWiki connects to\n\n### Using `docker run`\n\nStart by creating a dedicated docker network:\n\n```console\ndocker network create -d bridge xwiki-nw\n```\n\nThen run a container for the database and make sure it's configured to use an UTF8 encoding. The following databases are supported out of the box:\n\n-\tMySQL\n-\tMariaDB\n-\tPostgreSQL\n\n#### Starting MySQL\n\nWe will bind mount two local directories to be used by the MySQL container:\n-\tone to be used at database initialization to set permissions (see below), \n-\tanother to contain the data put by XWiki inside the MySQL database, so that when you stop and restart MySQL you don't find yourself without any data.\n\nFor example:\n-\t`/my/path/mysql-init`\n-\t`/my/path/mysql`\n\nYou need to make sure these directories exist, and then create a file under the `/my/path/mysql-init` directory (you can name it the way you want, for example `init.sql`), with the following content:\n\n```sql\ngrant all privileges on *.* to xwiki@'%'\n```\n\nThis will provide enough permissions for the `xwiki` user to create new schemas which is required to be able to create sub-wikis. \n\nNote: Make sure the directories you are mounting into the container are fully-qualified, and aren't relative paths.\n\n```console\ndocker run --net=xwiki-nw --name mysql-xwiki -v /my/path/mysql:/var/lib/mysql -v /my/path/mysql-init:/docker-entrypoint-initdb.d -e MYSQL_ROOT_PASSWORD=xwiki -e MYSQL_USER=xwiki -e MYSQL_PASSWORD=xwiki -e MYSQL_DATABASE=xwiki -d mysql:9.1 --character-set-server=utf8mb4 --collation-server=utf8mb4_bin --explicit-defaults-for-timestamp=1\n```\n\nYou should adapt the command line to use the passwords that you wish for the MySQL root password and for the `xwiki` user password (make sure to also change the GRANT command).\n\nNotes:\n\n-   The `explicit-defaults-for-timestamp` parameter was introduced in MySQL 5.6.6 and will thus work only for that version and beyond. If you are using an older MySQL version, please use the following instead:\n\n    ```console\n    docker run --net=xwiki-nw --name mysql-xwiki -v /my/path/mysql:/var/lib/mysql -v /my/path/mysql-init:/docker-entrypoint-initdb.d -e MYSQL_ROOT_PASSWORD=xwiki -e MYSQL_USER=xwiki -e MYSQL_PASSWORD=xwiki -e MYSQL_DATABASE=xwiki -d mysql:9.1 --character-set-server=utf8mb4 --collation-server=utf8mb4_bin\n    ```\n\n#### Starting MariaDB\n\nThis is exactly similar to starting MySQL and you should thus follow exactly the same steps as for MySQL. The only thing to change is the docker image for MariaDB: instead of `mysql:<tag>`, use `mariadb:<tag>`. For example: `mariadb:11.6`.\n\nFull command example:\n\n```console\ndocker run --net=xwiki-nw --name mysql-xwiki -v /my/path/mariadb:/var/lib/mysql -v /my/path/mariadb-init:/docker-entrypoint-initdb.d -e MYSQL_ROOT_PASSWORD=xwiki -e MYSQL_USER=xwiki -e MYSQL_PASSWORD=xwiki -e MYSQL_DATABASE=xwiki -d mariadb:11.6 --character-set-server=utf8mb4 --collation-server=utf8mb4_bin --explicit-defaults-for-timestamp=1\n```\n\n#### Starting PostgreSQL\n\nWe will bind mount a local directory to be used by the PostgreSQL container to contain the data put by XWiki inside the database, so that when you stop and restart PostgreSQL you don't find yourself without any data.  For example:\n\n-\t`/my/path/postgres`\n\nYou need to make sure this directory exists, before proceeding.\n\nNote Make sure the directory you specify is specified with the fully-qualified path, not a relative path.\n\nFor PostgreSQL < 17:\n\n```console\ndocker run --net=xwiki-nw --name postgres-xwiki -v /my/path/postgres:/var/lib/postgresql/data -e POSTGRES_ROOT_PASSWORD=xwiki -e POSTGRES_USER=xwiki -e POSTGRES_PASSWORD=xwiki -e POSTGRES_DB=xwiki -e \"POSTGRES_INITDB_ARGS=--encoding=UTF8 --locale-provider=builtin --locale=C.UTF-8\" -d postgres:17\n```\n\nFor PostgreSQL >= 18:\n\n```console\ndocker run --net=xwiki-nw --name postgres-xwiki -v /my/path/postgres:/var/lib/postgresql -e POSTGRES_ROOT_PASSWORD=xwiki -e POSTGRES_USER=xwiki -e POSTGRES_PASSWORD=xwiki -e POSTGRES_DB=xwiki -e \"POSTGRES_INITDB_ARGS=--encoding=UTF8 --locale-provider=builtin --locale=C.UTF-8\" -d postgres:17\n```\n\nYou should adapt the command line to use the passwords that you wish for the PostgreSQL root password and for the xwiki user password.\n\n#### Starting XWiki\n\nWe will also bind mount a local directory for the XWiki permanent directory (contains application config and state), for example:\n\n-\t`/my/path/xwiki`\n\nNote Make sure the directory you specify is specified with the fully-qualified path, not a relative path.\n\nEnsure this directory exists, and then run XWiki in a container by issuing one of the following command.\n\nFor MySQL:\n\n```console\ndocker run --net=xwiki-nw --name xwiki -p 8080:8080 -v /my/path/xwiki:/usr/local/xwiki -e DB_USER=xwiki -e DB_PASSWORD=xwiki -e DB_DATABASE=xwiki -e DB_HOST=mysql-xwiki xwiki:stable-mysql-tomcat\n```\n\nFor PostgreSQL:\n\n```console\ndocker run --net=xwiki-nw --name xwiki -p 8080:8080 -v /my/path/xwiki:/usr/local/xwiki -e DB_USER=xwiki -e DB_PASSWORD=xwiki -e DB_DATABASE=xwiki -e DB_HOST=postgres-xwiki xwiki:stable-postgres-tomcat\n```\n\nBe careful to use the same DB username, password and database names that you've used on the first command to start the DB container. Also, please don't forget to add a `-e DB_HOST=` environment variable with the name of the previously created DB container so that XWiki knows where its database is.\n\nAt this point, XWiki should start in interactive blocking mode, allowing you to see logs in the console. Should you wish to run it in \"detached mode\", just add a \"-d\" flag in the previous command.\n\n```console\ndocker run -d --net=xwiki-nw ...\n```\n\n### Using `docker-compose`\n\nAnother solution is to use the Docker Compose files we provide.\n\n#### For MySQL on Tomcat\n\n-\t`wget https://raw.githubusercontent.com/xwiki-contrib/docker-xwiki/master/16/mysql-tomcat/mysql/init.sql`: This will download some SQL to execute at startup for MySQL\n\t-\tIf you don't have `wget` or prefer to use `curl`: `curl -fSL https://raw.githubusercontent.com/xwiki-contrib/docker-xwiki/master/16/mysql-tomcat/mysql/init.sql -o init.sql`\n-\t`wget -O docker-compose.yml https://raw.githubusercontent.com/xwiki-contrib/docker-xwiki/master/16/mysql-tomcat/docker-compose.yml`\n\t-\tIf you don't have `wget` or prefer to use `curl`: `curl -fSL https://raw.githubusercontent.com/xwiki-contrib/docker-xwiki/master/16/mysql-tomcat/docker-compose.yml -o docker-compose.yml`\n-\t`wget https://raw.githubusercontent.com/xwiki-contrib/docker-xwiki/master/16/mysql-tomcat/.env`: This contains default configuration values you should edit (version of XWiki to use, etc)\n\t -\tIf you don't have `wget` or prefer to use `curl`: `curl -fSL https://raw.githubusercontent.com/xwiki-contrib/docker-xwiki/master/16/mysql-tomcat/.env -o .env`\n-\t`docker-compose up`\n\nFor reference here's a minimal Docker Compose file using MySQL that you could use as an example (full example [here](https://github.com/xwiki/xwiki-docker/blob/master/16/mysql-tomcat/docker-compose.yml)):\n\n```yaml\nversion: '2'\nnetworks:\n  bridge:\n    driver: bridge\nservices:\n  web:\n    image: \"xwiki:stable-mysql-tomcat\"\n    container_name: xwiki-mysql-tomcat-web\n    depends_on:\n      - db\n    ports:\n      - \"8080:8080\"\n    environment:\n      - DB_USER=xwiki\n      - DB_PASSWORD=xwiki\n      - DB_HOST=xwiki-mysql-db\n    volumes:\n      - xwiki-data:/usr/local/xwiki\n    networks:\n      - bridge\n  db:\n    image: \"mysql:9.1\"\n    container_name: xwiki-mysql-db\n    volumes:\n      - mysql-data:/var/lib/mysql\n      - ./init.sql:/docker-entrypoint-initdb.d/init.sql\n    environment:\n      - MYSQL_ROOT_PASSWORD=xwiki\n      - MYSQL_USER=xwiki\n      - MYSQL_PASSWORD=xwiki\n      - MYSQL_DATABASE=xwiki\n    command:\n      - \"--character-set-server=utf8mb4\"\n      - \"--collation-server=utf8mb4_bin\"\n      - \"--explicit-defaults-for-timestamp=1\"\n    networks:\n      - bridge\nvolumes:\n  mysql-data: {}\n  xwiki-data: {}\n```\n\n#### For MariaDB on Tomcat\n\n-\t`wget https://raw.githubusercontent.com/xwiki-contrib/docker-xwiki/master/16/mariadb-tomcat/mariadb/init.sql`: This will download some SQL to execute at startup for MariaDB\n\t-\tIf you don't have `wget` or prefer to use `curl`: `curl -fSL https://raw.githubusercontent.com/xwiki-contrib/docker-xwiki/master/16/mariadb-tomcat/mariadb/init.sql -o init.sql`\n-\t`wget -O docker-compose.yml https://raw.githubusercontent.com/xwiki-contrib/docker-xwiki/master/16/mariadb-tomcat/docker-compose.yml`\n\t-\tIf you don't have `wget` or prefer to use `curl`: `curl -fSL https://raw.githubusercontent.com/xwiki-contrib/docker-xwiki/master/16/mariadb-tomcat/docker-compose.yml -o docker-compose.yml`\n-\t`wget https://raw.githubusercontent.com/xwiki-contrib/docker-xwiki/master/16/mariadb-tomcat/.env`: This contains default configuration values you should edit (version of XWiki to use, etc)\n\t-\tIf you don't have `wget` or prefer to use `curl`: `curl -fSL https://raw.githubusercontent.com/xwiki-contrib/docker-xwiki/master/16/mariadb-tomcat/.env -o .env`\n-\t`docker-compose up`\n\nFor reference here's a minimal Docker Compose file using MariaDB that you could use as an example (full example [here](https://github.com/xwiki/xwiki-docker/blob/master/16/mariadb-tomcat/docker-compose.yml)):\n\n```yaml\nversion: '2'\nnetworks:\n  bridge:\n    driver: bridge\nservices:\n  web:\n    image: \"xwiki:stable-mariadb-tomcat\"\n    container_name: xwiki-mariadb-tomcat-web\n    depends_on:\n      - db\n    ports:\n      - \"8080:8080\"\n    environment:\n      - DB_USER=xwiki\n      - DB_PASSWORD=xwiki\n      - DB_HOST=xwiki-mariadb-db\n    volumes:\n      - xwiki-data:/usr/local/xwiki\n    networks:\n      - bridge\n  db:\n    image: \"mariadb:11.6\"\n    container_name: xwiki-mariadb-db\n    volumes:\n      - mariadb-data:/var/lib/mysql\n      - ./init.sql:/docker-entrypoint-initdb.d/init.sql\n    environment:\n      - MYSQL_ROOT_PASSWORD=xwiki\n      - MYSQL_USER=xwiki\n      - MYSQL_PASSWORD=xwiki\n      - MYSQL_DATABASE=xwiki\n    command:\n      - \"--character-set-server=utf8mb4\"\n      - \"--collation-server=utf8mb4_bin\"\n      - \"--explicit-defaults-for-timestamp=1\"\n    networks:\n      - bridge\nvolumes:\n  mariadb-data: {}\n  xwiki-data: {}\n```\n\n#### For PostgreSQL on Tomcat\n\n-\t`wget -O docker-compose.yml https://raw.githubusercontent.com/xwiki-contrib/docker-xwiki/master/16/postgres-tomcat/docker-compose.yml`\n\t-\tIf you don't have `wget` or prefer to use `curl`: `curl -fSL https://raw.githubusercontent.com/xwiki-contrib/docker-xwiki/master/16/postgres-tomcat/docker-compose.yml -o docker-compose.yml`\n-\t`wget https://raw.githubusercontent.com/xwiki-contrib/docker-xwiki/master/16/postgres-tomcat/.env`: This contains default configuration values you should edit (version of XWiki to use, etc)\n\t -\tIf you don't have `wget` or prefer to use `curl`: `curl -fSL https://raw.githubusercontent.com/xwiki-contrib/docker-xwiki/master/16/postgres-tomcat/.env -o .env`\n-\t`docker-compose up`\n\nFor reference here's a minimal Docker Compose file using PostgreSQL that you could use as an example (full example [here](https://github.com/xwiki/xwiki-docker/blob/master/16/postgres-tomcat/docker-compose.yml)):\n\n```yaml\nversion: '2'\nnetworks:\n  bridge:\n    driver: bridge\nservices:\n  web:\n    image: \"xwiki:stable-postgres-tomcat\"\n    container_name: xwiki-postgres-tomcat-web\n    depends_on:\n      - db\n    ports:\n      - \"8080:8080\"\n    environment:\n      - DB_USER=xwiki\n      - DB_PASSWORD=xwiki\n      - DB_HOST=xwiki-postgres-db\n    volumes:\n      - xwiki-data:/usr/local/xwiki\n    networks:\n      - bridge\n  db:\n    image: \"postgres:17\"\n    container_name: xwiki-postgres-db\n    volumes:\n      - postgres-data:/var/lib/postgresql/data\n    environment:\n      - POSTGRES_ROOT_PASSWORD=xwiki\n      - POSTGRES_PASSWORD=xwiki\n      - POSTGRES_USER=xwiki\n      - POSTGRES_DB=xwiki\n      - POSTGRES_INITDB_ARGS=--encoding=UTF8 --locale-provider=builtin --locale=C.UTF-8\n    networks:\n      - bridge\nvolumes:\n  postgres-data: {}\n  xwiki-data: {}\n```\n\n### Using Docker Swarm\n\nHere are some examples of using this image with Docker Swarm. These examples leverage additional features of Docker Swarm such as Docker secrets, and Docker configs. As such, these examples require Docker to be in swarm mode.\n\nYou can read more about these features and Docker swarm mode here:\n\n-\t[Docker swarm mode](https://docs.docker.com/engine/swarm/)\n-\t[Creating Docker secrets](https://docs.docker.com/engine/reference/commandline/secret_create/)\n-\t[Creating Docker configs](https://docs.docker.com/engine/reference/commandline/config_create/)\n\n#### MySQL Example\n\nThis example presupposes the existence of the Docker secrets `xwiki-db-username`, `xwiki-db-password` and `xwiki-db-root-password`, and the Docker config `xwiki-mysql-config`.\n\nYou can create these secrets and configs with the following:\n\n-\t`echo ${MY_XWIKI_USER:-xwiki} | docker secret create xwiki-db-username -`\n-\t`echo $(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1) | docker secret create xwiki-db-password -`\n-\t`echo $(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1) | docker secret create xwiki-db-root-password -`\n\nTo deploy this example, save the following YAML as `xwiki-stack.yaml`, then run:\n\n-\t`docker stack deploy -c xwiki-stack.yaml xwiki`\n\n```yaml\nversion: '3.3'\nservices:\n  web:\n    image: \"xwiki:stable-mysql-tomcat\"\n    ports:\n      - \"8080:8080\"\n    environment:\n      - DB_USER_FILE=/run/secrets/xwiki-db-username\n      - DB_PASSWORD_FILE=/run/secrets/xwiki-db-password\n      - DB_DATABASE=xwiki\n      - DB_HOST=db\n    volumes:\n      - xwiki-data:/usr/local/xwiki\n    secrets:\n      - xwiki-db-username\n      - xwiki-db-password\n  db:\n    image: \"mysql:9.1\"\n    volumes:\n      - mysql-data:/var/lib/mysql\n    environment:\n      - MYSQL_ROOT_PASSWORD_FILE=/run/secrets/xwiki-db-root-password\n      - MYSQL_USER_FILE=/run/secrets/xwiki-db-username\n      - MYSQL_PASSWORD_FILE=/run/secrets/xwiki-db-password\n      - MYSQL_DATABASE=xwiki\n    command:\n      - \"--character-set-server=utf8mb4\"\n      - \"--collation-server=utf8mb4_bin\"\n      - \"--explicit-defaults-for-timestamp=1\"\n    secrets:\n      - xwiki-db-username\n      - xwiki-db-password\n      - xwiki-db-root-password\nvolumes:\n  mysql-data:\n  xwiki-data:\nsecrets:\n  xwiki-db-username:\n    name: xwiki-db-username\n    external: true\n  xwiki-db-password:\n    name: xwiki-db-password\n    external: true\n  xwiki-db-root-password:\n    name: xwiki-db-root-password\n    external: true\n```\n\n#### PostgreSQL Example\n\nThis example presupposes the existence of the Docker secrets `xwiki-db-username`, `xwiki-db-password`, and `xwiki-db-root-password`.\n\nYou can create these secrets with the following:\n\n-\t`echo ${MY_XWIKI_USER:-xwiki} | docker secret create xwiki-db-username -`\n-\t`echo $(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1) | docker secret create xwiki-db-password -`\n-\t`echo $(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1) | docker secret create xwiki-db-root-password -`\n\nTo deploy this example, save the following YAML as `xwiki-stack.yaml` then run:\n\n-\t`docker stack deploy -c xwiki-stack.yaml xwiki`\n\n```yaml\nversion: '3.3'\nservices:\n  web:\n    image: \"xwiki:stable-postgres-tomcat\"\n    ports:\n      - \"8080:8080\"\n    environment:\n      - DB_USER_FILE=/run/secrets/xwiki-db-username\n      - DB_PASSWORD_FILE=/run/secrets/xwiki-db-password\n      - DB_DATABASE=xwiki\n      - DB_HOST=db\n    volumes:\n      - xwiki-data:/usr/local/xwiki\n    secrets:\n      - xwiki-db-username\n      - xwiki-db-password\n  db:\n    image: \"postgres:17\"\n    volumes:\n      - postgres-data:/var/lib/postgresql/data\n    environment:\n      - POSTGRES_ROOT_PASSWORD_FILE=/run/secrets/xwiki-db-root-password\n      - POSTGRES_USER_FILE=/run/secrets/xwiki-db-username\n      - POSTGRES_PASSWORD_FILE=/run/secrets/xwiki-db-password\n      - POSTGRES_DB=xwiki\n    secrets:\n      - xwiki-db-username\n      - xwiki-db-password\n      - xwiki-db-root-password\nvolumes:\n  postgres-data:\n  xwiki-data:\nsecrets:\n  xwiki-db-username:\n    name: xwiki-db-username\n    external: true\n  xwiki-db-password:\n    name: xwiki-db-password\n    external: true\n  xwiki-db-root-password:\n    name: xwiki-db-root-password\n    external: true\n```\n\n## Building\n\nThis allows you to rebuild the XWiki docker image locally. Here are the steps:\n\n-\tInstall Git and run `git clone https://github.com/xwiki-contrib/docker-xwiki.git` or download the sources from the GitHub UI. Then go to the directory corresponding to the docker tag you wish to use. For example: `cd 13/mysql-tomcat`\n\t-\tThe `13/mysql-tomcat` directory will get you the latest released XWiki version of the 13.x cycle running on Tomcat and for MySQL.\n\t-\tThe `13/postgres-tomcat` directory will get you the latest released XWiki version of the 13.x cycle running on Tomcat and for MySQL.\n\t-\tThe `12/mysql-tomcat` directory will get you the latest released XWiki version of the 12.x cycle running on Tomcat and for MySQL.\n\t-\tetc.\n-\tRun `docker-compose up`\n-\tStart a browser and point it to `http://localhost:8080`\n\nNote that if you want to set a custom version of XWiki you can edit the `.env` file and set the values you need in there. It's also possible to override them on the command line with `docker-compose run -e \"XWIKI_VERSION=12.10.10\"`.\n\nNote that `docker-compose up` will automatically build the XWiki image on the first run. If you need to rebuild it you can issue `docker-compose up --build`. You can also build the image with `docker build . -t xwiki-mysql-tomcat:latest` for example.\n\nYou can also just build the image by issuing `docker build -t xwiki .` and then use the instructions from above to start XWiki and the database using `docker run ...`.\n\n# Upgrading XWiki\n\nYou've installed an XWiki docker image and used it and now comes the time when you'd like to upgrade XWiki to a newer version.\n\nIf you've followed the instructions above, you've mapped the XWiki permanent directory to a local directory on your host, and you've done the same for each configuration files that you have needed to customize (see [Configuration Files](#configuration-files)) \n\nFollow these steps:\n* Stop the running XWiki container. You should keep your DB container running.\n* Check the [Release Notes](https://www.xwiki.org/xwiki/bin/view/ReleaseNotes/) for all releases that happened between your current version and the new version you're upgrading to, as there could be some manual steps to perform (such as updating your XWiki configuration files).\n* Start the new version of the XWiki container that you want to upgrade to. \n\n# Details for the xwiki image\n\n## Configuration Options\n\nThe first time you create a container out of the xwiki image, a shell script (`/usr/local/bin/docker-entrypoint.sh`) is executed in the container to setup some configuration. The following environment variables can be passed:\n\n-\t`DB_USER`: The user name used by XWiki to read/write to the DB.\n-\t`DB_PASSWORD`: The user password used by XWiki to read/write to the DB.\n-\t`DB_DATABASE`: The name of the XWiki database to use/create.\n-\t`DB_HOST`: The name of the host (or docker container) containing the database. Default is \"db\".\n-\t`INDEX_HOST`: The hostname of an externally configured Solr instance. Defaults to \"localhost\", and configures an embedded Solr instance.\n-\t`INDEX_PORT`: The port used by an externally configured Solr instance. Defaults to 8983.\n-   `CONTEXT_PATH`: The name of the context path under which XWiki will be deployed in Tomcat. If not specified then it'll be deployed as ROOT.\n    -   If you had set this environment property and later on, recreate the XWiki container without passing it (i.e you wish to deploy XWiki as ROOT again), the you'll need to edit the `xwiki.cfg` file in your mapped local permanent directory and set `xwiki.webapppath=`.\n-\t`JDBC_PARAMS`: Custom JDB parameters to pass to the JBC connection. Setting this value overwrites the default parameters used (which depend on the DB used). The value must start with a question mark and the content be XML-encoded. For example: `?useSSL=false&amp;connectionTimeZone=LOCAL&amp;allowPublicKeyRetrieval=true`.\n    \nIn order to support [Docker secrets](https://docs.docker.com/engine/swarm/secrets/), these configuration values can also be given to the container as files containing that value.\n\n-\t`DB_USER_FILE`: The location, inside the container, of a file containing the value for `DB_USER`\n-\t`DB_PASSWORD_FILE`: The location, inside the container, of a file containing the value for `DB_PASSWORD`\n-\t`DB_DATABASE_FILE`: The location, inside the container, of a file containing the value for `DB_DATABASE`\n-\t`DB_HOST_FILE`: The location, inside the container, of a file containing the value for `DB_HOST`\n-\t`INDEX_HOST_FILE`: The location, inside the container, of a file containing the value for `INDEX_HOST`\n-\t`INDEX_PORT_FILE`: The location, inside the container, of a file containing the value for `INDEX_PORT`\n-\t`JDBC_PARAMS_FILE`: The location, inside the container, of a file containing the value for `JDBC_PARAMS`\n\n*Note:* For each configuration value, the normal environment variable and \\_FILE environment variable are mutually exclusive. Providing values for both variables will result in an error.\n\n## Passing JVM Options\n\nIt's possible to pass JVM options to Tomcat by defining the `JAVA_OPTS` environment property.\n\nSee an example below, used to perform remote debugging of an XWiki instance.\n\n## Remote Debugging\n\nTo perform remote debugging on an XWiki instance started using a Docker container, you'll need to do 2 things:\n-\tExpose the debugging port (using the `-p` option when executing `docker run`)\n-   Configure Tomcat to start Java in debug mode (using the `JAVA_OPTS` environment variable)\n\nThis can be achieved with:\n\n```console\ndocker run --net=xwiki-nw --name xwiki -p 8080:8080 -v xwiki:/usr/local/xwiki -e DB_USER=xwiki -e DB_PASSWORD=xwiki -e DB_DATABASE=xwiki -e DB_HOST=mysql-xwiki -e JAVA_OPTS=\"-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=*:5005\" -p 5005:5005 xwiki\n```\n\n## Configuration Files\n\nYou will find below all the XWiki configuration files that exist and that you may want to configure. In order to do so, the strategy is to map Docker volumes for these files from your local host machine to their locations inside the XWiki Docker image. \n\nFull list of configuration files, with their location inside the XWiki Docker image:\n-\t[Permanent directory](https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Configuration/#HPermanentDirectory): `/usr/local/xwiki`\n-\t`xwiki.cfg`: `$WEB-INF/xwiki.cfg`\n-\t`xwiki.properties`: `$WEB-INF/xwiki.properties`\n-\t`hibernate.cfg.xml`: `$WEB-INF/hibernate.cfg.xml`\n-\tClustering (JGroups directory): `$WEB-INF/observation/remote/jgroups`\n-\t`logback.xml` (logging) : `$WEB-INF/classes/logback.xml`\n-\t`web.xml` : `$WEB-INF/web.xml`\n\nwhere:\n* `$WEB-INF` is the location of the XWiki WAR's `WEB-INF` directory, at `/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/`.\n* `$CONTEXT_PATH` is the Servlet context deployment name for the XWiki webapp, by default it's `ROOT`.\n\nNotes: \n* In the past, the first 3 configuration files listed above (`xwiki.cfg`, `xwiki.properties` and `hibernate.cfg.xml`) had a special handling, and they were copied automatically on the first XWiki container start, from the XWiki image into the local permanent directory. This was removed starting with XWiki 16.6.0/15.10.12. However, in order to preserve backward compatibility, if these files are found in the permanent directory, they are copied on container start to their location inside the container.\n* It's recommended to only map volumes for configuration files that you need to customize. This is because when you upgrade you'll need to perform a merge between XWiki's default configuration files and the ones you modified. If you haven't modified them, then there's no merge to do. \n\n### Example for `docker run`\n\nIf your config files are in a local `/my/xwiki/config/path` directory, you would use the following for `docker run`:\n\n```console\ndocker run ... -v /my/xwiki/config/path/xwiki.cfg:/usr/local/tomcat/webapps/ROOT/WEB-INF/xwiki.cfg -v ... xwiki\n```\n\n### Example for `docker-compose`\n\n```yaml\n[...]\nservices:\n  web:\n    image: \"xwiki:stable-mysql-tomcat\"\n    [...]\n    volumes:\n      - xwiki-data:/usr/local/xwiki\n      - xwiki-cfg:/usr/local/tomcat/webapps/ROOT/WEB-INF/xwiki.cfg\n      - xwiki-properties:/usr/local/tomcat/webapps/ROOT/WEB-INF/xwiki.properties\n      - xwiki-hibernate:/usr/local/tomcat/webapps/ROOT/WEB-INF/hibernate.cfg.xml\n      - xwiki-jgroups:/usr/local/tomcat/webapps/ROOT/WEB-INF/observation/remote/jgroups\n      - xwiki-logback:/usr/local/tomcat/webapps/ROOT/WEB-INF/classes/logback.xml\n\t  - xwiki-webxml:/usr/local/tomcat/webapps/ROOT/WEB-INF/web.xml\n    [...]\nvolumes:\n  [...]\n  xwiki-data: {}\n  xwiki-cfg: {}\n  xwiki-properties: {}\n  xwiki-hibernate: {}\n  xwiki-jgroups: {}\n  xwiki-logback: {}\n  xwiki-webxml: {}\n```\n\n## Configuring Tomcat\n\nIf you need to configure Tomcat (for example to setup a reverse proxy configuration), you'll need to mount the Tomcat configuration directory (`/usr/local/tomcat/conf`) inside the image onto your local host.  \n\nIf you want to modify the existing configuration rather than provide a brand new one, you'll need to use `docker cp` to copy the configuration from the container to your local host.\n\nHere are some example steps you can follow:\n\n-   Create a docker container from the XWiki image with `docker create`.\n    -   Example: `docker create --name xwiki xwiki:stable-mysql-tomcat`.\n-   Copy the Tomcat configuration from the container to the host to start with some existing configuration files, using `docker cp`.\n    -   Example: `sudo docker cp xwiki:/usr/local/tomcat/conf /tmp/tomcat`.\n-   Modify the Tomcat configuration locally to bring the changes you need.\n-   Delete the created XWiki container since it was only used to copy the configuration files and we'll need to create a new one with different parameters.\n    -   Example: `docker rm xwiki`.\n-   Run the container with the Tomcat mount and the other parameters.\n    -   Example: `docker run --net=xwiki-nw --name xwiki -p 8080:8080 -v /tmp/xwiki:/usr/local/xwiki -v /tmp/tomcat:/usr/local/tomcat/conf -e DB_USER=xwiki -e DB_PASSWORD=xwiki -e DB_DATABASE=xwiki -e DB_HOST=mysql-xwiki xwiki:stable-mysql-tomcat`\n\n## Miscellaneous\n\nVolumes:\n\nIf you don't map any volume when using `docker run` or if you use `docker-compose` then Docker will create some internal volumes attached to your containers as follows.\n\n-\tTwo volumes are created:\n\t-\tA volume named `<prefix>_mysql-data` or `<prefix>_postgres-data` that contains the database data.\n\t-\tA volume named `<prefix>_xwiki-data` that contains XWiki's permanent directory.\n-\tTo find out where those volumes are located on your local host machine you can inspect them with `docker volume inspect <volume name>`. To find the volume name, you can list all volumes with `docker volume ls`.\n\n-\tNote that on Mac OSX, Docker runs inside the xhyve VM and thus the paths you get when inspecting the volumes are relative to this. Thus, you need to get into that VM if you need to access the volume data.\n\nMySQL:\n\n-\tTo issue some mysql commands:\n\t-\tFind the container id with `docker ps`\n\t-\tExecute bash in the mysql container: `docker exec -it <containerid> bash -l`\n\t-\tOnce inside the mysql container execute the `mysql` command: `mysql --user=xwiki --password=xwiki`\n\n## Using an external Solr service\n\nFrom the [XWiki Solr Search API documentation](https://extensions.xwiki.org/xwiki/bin/view/Extension/Solr%20Search%20API):\n\n> By default XWiki ships with an embedded Solr. This is mostly for ease of use but the embedded instance is not really recommended by the Solr team so you might want to externalize it when starting to have a wiki with a lots of pages. Solr is using a lot of memory and a standalone Solr instance is generally better in term of speed than the embedded one. It should not be much noticeable in a small wiki but if you find yourself starting to have memory issues and slow search results you should probably try to install and setup an external instance of Solr using the guide.\n>\n> Also the speed of the drive where the Solr index is located can be very important because Solr/Lucene is quite filesystem intensive. For example putting it in a SSD might give a noticeable boost.\n>\n> You can also find more Solr-specific performance details on https://wiki.apache.org/solr/SolrPerformanceProblems. Standalone Solr also comes with a very nice UI, along with monitoring and test tools.\n\nThis image provides the configuration parameters `INDEX_HOST` and `INDEX_PORT` which are used to configure `xwiki.properties` with:\n\n```data\nsolr.type=remote\nsolr.remote.baseURL=http://$INDEX_HOST:$INDEX_PORT/solr\n```\n\n#### Preparing Solr container\n\nThe simplest way to create an external Solr service is using the [official Solr image](https://hub.docker.com/_/solr/).\n\n-\tSelect the appropriate XWiki Solr configuration JAR from [here](https://maven.xwiki.org/releases/org/xwiki/platform/xwiki-platform-search-solr-server-data/) (Note: it's usually better to synchronize it with your version of XWiki)\n-\tPlace this JAR in a directory along side `solr-init.sh` that you can fetch from the [docker-xwiki repository](https://github.com/xwiki-contrib/docker-xwiki/tree/master/contrib/solr)\n-\tEnsure that this directory is owned by the Solr user and group `chown -R 8983:8983 /path/to/solr/init/directory`\n-\tLaunch the Solr container and mount this directory at `/docker-entrypoint-initdb.d`\n-\tThis will execute `solr-init.sh` on container startup and prepare the XWiki core with the contents from the given JAR\n-\tIf you want to persist the Solr index outside of the container with a bind mount, make sure that that directory is owned by the Solr user and group `chown 8983:8983 /my/path/solr`\n\n#### Example with `docker run`\n\nStart your chosen database container normally using the docker run command above, this example happens to assume MySQL was chosen.\n\nThe command below will configure the Solr container to initialize based on the contents of `/path/to/solr/init/directory/` and save its data on the host in a `/my/path/solr` directory:\n\n```console\ndocker run \\\n  --net=xwiki-nw \\\n  --name solr-xwiki \\\n  -v /path/to/solr/init/directory:/docker-entrypoint-initdb.d \\\n  -v /my/path/solr:/opt/solr/server/solr/xwiki \\\n  -d solr:9\n```\n\nThen start the XWiki container, the below command is nearly identical to that specified in the Starting XWiki section above, except that it includes the `-e INDEX_HOST=` environment variable which specifies the hostname of the Solr container.\n\n```console\ndocker run \\\n  --net=xwiki-nw \\\n  --name xwiki \\\n  -p 8080:8080 \\\n  -v /my/path/xwiki:/usr/local/xwiki \\\n  -e DB_USER=xwiki \\\n  -e DB_PASSWORD=xwiki \\\n  -e DB_DATABASE=xwiki \\\n  -e DB_HOST=mysql-xwiki \\\n  -e INDEX_HOST=solr-xwiki \\\n  -d xwiki:stable-mysql-tomcat\n```\n\n#### Example with `docker-compose`\n\nThe below compose file assumes that `./solr` contains `solr-init.sh` and the configuration JAR file.\n\n```yaml\nversion: '2'\nnetworks:\n  bridge:\n    driver: bridge\nservices:\n  web:\n    image: \"xwiki:stable-mysql-tomcat\"\n    container_name: xwiki-web\n    depends_on:\n      - db\n      - index\n    ports:\n      - \"8080:8080\"\n    environment:\n      - XWIKI_VERSION=xwiki\n      - DB_USER=xwiki\n      - DB_PASSWORD=xwiki\n      - DB_DATABASE=xwiki\n      - DB_HOST=xwiki-db\n      - INDEX_HOST=xwiki-index\n    volumes:\n      - xwiki-data:/usr/local/xwiki\n    networks:\n      - bridge\n  db:\n    image: \"mysql:9.1\"\n    container_name: xwiki-db\n    volumes:\n      - mysql-data:/var/lib/mysql\n    environment:\n      - MYSQL_ROOT_PASSWORD=xwiki\n      - MYSQL_USER=xwiki\n      - MYSQL_PASSWORD=xwiki\n      - MYSQL_DATABASE=xwiki\n    command:\n      - \"--character-set-server=utf8mb4\"\n      - \"--collation-server=utf8mb4_bin\"\n      - \"--explicit-defaults-for-timestamp=1\"\n    networks:\n      - bridge\n  index:\n    image: \"solr:9\"\n    container_name: xwiki-index\n    volumes:\n      - ./solr:/docker-entrypoint-initdb.d\n      - solr-data:/opt/solr/server/solr\n    networks:\n      - bridge\nvolumes:\n  mysql-data: {}\n  xwiki-data: {}\n  solr-data: {}\n```\n\n# Troubleshooting\n\n## Problem with eclipse-temurin base image\n\nIf you're hitting a problem when running the XWiki docker image related to the use of eclipse-temurin in the XWiki base image, there are 2 workarounds:\n\n-\tMake sure you use a Docker version >= 20.10.16\n-\tIf that's not possible run the XWiki Docker container without the default seccomp profile\n\n# For Maintainers\n\n## Update Docker Images\n\n- Create a JIRA issue on the [XDOCKER project](https://jira.xwiki.org/browse/XDOCKER) with subject `Upgrade stable version to <version>`.\n- Update the version of XWiki in the `build.gradle` file found in the XWiki Docker repository (clone it locally first).\n- To know how to generate the sha256, check the doc inside `build.gradle`. You need to download in advance the XWiki WAR file and run the according command in order to generate.\n\t- On Linux, use the following one-liner and replace the value of the `VERSION` variable accordingly:\n\n\t\t```console\n\t\tVERSION=\"12.10.10\"; wget http://nexus.xwiki.org/nexus/content/groups/public/org/xwiki/platform/xwiki-platform-distribution-war/${VERSION}/xwiki-platform-distribution-war-${VERSION}.war && sha256sum xwiki-platform-distribution-war-${VERSION}.war && rm xwiki-platform-distribution-war-${VERSION}.war\n\t\t```\n\n\t- On Mac, use the following one-liner and replace the value of the `VERSION` variable accordingly:\n\n\t\t```console\n\t\tVERSION=\"12.10.10\"; wget http://nexus.xwiki.org/nexus/content/groups/public/org/xwiki/platform/xwiki-platform-distribution-war/${VERSION}/xwiki-platform-distribution-war-${VERSION}.war && shasum --algorithm 256 xwiki-platform-distribution-war-${VERSION}.war && rm xwiki-platform-distribution-war-${VERSION}.war\n\t\t```\n\n- Execute the Gradle build (run `./gradlew`) to generate the various Dockerfiles and other resources for all image tags\n- [Test](#testing-docker-images) the docker container\n- If all is ok commit, push and close the jira issue created above\n- Note down the SHA1 of the last commit and [update the official library file](https://github.com/docker-library/official-images/blob/master/library/xwiki) with it by creating a Pull Request (you can edit directly on the GitHub web page and create a Pull Request).\n- Make sure to update this file if the documentation needs to be updated.\n\n## Testing Docker Images\n\nTest the modified files. On Linux, you need to use `sudo` on each docker command or configure it differently.\n\n- First time only: Install Docker. For Mac you can use the Docker for Mac installer.\n\t- Make sure you open Docker before running the commands.\n\t\t- Linux (except Ubuntu): `sudo systemctl start docker`\n- Create a network: `docker network create -d bridge xwiki-test`\n- Make sure that `/tmp/xwiki-docker-test/postgres` and `/tmp/xwiki-docker-test/xwiki` exist (you can run the clean up script below to create them)\n- Update the PostgreSQL image to use the latest version: `docker pull postgres:latest`\n- Execute the following command to start a Postgres database (for example):\n\n\t```console\n\tdocker run --net=xwiki-test --name postgres-xwiki-test -v /tmp/xwiki-docker-test/postgres:/var/lib/postgresql -e POSTGRES_ROOT_PASSWORD=xwiki -e POSTGRES_USER=xwiki -e POSTGRES_PASSWORD=xwiki -e POSTGRES_DB=xwiki -e POSTGRES_INITDB_ARGS=\"--encoding=UTF8\" -d postgres:latest\n\t```\n\t\n- Navigate to the directory to test, e.g. `14/postgres-tomcat` and issue:\n\t- Update the Tomcat image to use the latest version: `docker pull <image name here>`, where the image name is found in the `FROM` command inside the [Dockerfile](https://github.com/xwiki/xwiki-docker/blob/master/template/Dockerfile#L20)\n\t- Build the image: `docker build -t xwiki-test .`\n\t- Start XWiki (using the started Postgres container in this example): \n  \n\t\t```console \n\t\tdocker run --net=xwiki-test --name xwiki-test -p 8080:8080 -v /tmp/xwiki-docker-test/xwiki:/usr/local/xwiki -e DB_USER=xwiki -e DB_PASSWORD=xwiki -e DB_DATABASE=xwiki -e DB_HOST=postgres-xwiki-test xwiki-test\n\t\t```\n\t\n  \tNote that same as for the Postgres container above you'll need to remove the container if it already exists.\n  \t\n\t- In case you had an XWiki instance running on 8080 and the above command fails (i.e. address already in use), you cannot simply run it again. If you do (and you should try, actually), will try to recreate the container with the `xwiki-test` name that is now already in use by a container for which you are given the ID (note that down). Instead, you need to simply start the mentioned container ID which previously failed by running `docker start <FAILED_START_CONTAINER_ID>`.\n\t- Open your browser to http://localhost:8080 and try to setup XWiki and verify it works\n- If all is ok commit, push and close the JIRA issue created above\n\n### Clean Up\n\nExecute:\n\n```console\ndocker stop xwiki-test\ndocker rm xwiki-test\ndocker stop postgres-xwiki-test\ndocker rm postgres-xwiki-test\ndocker network rm xwiki-test\ndocker rmi xwiki-test\nrm -Rf /tmp/xwiki-docker-test\nmkdir -p /tmp/xwiki-docker-test/postgres\nmkdir -p /tmp/xwiki-docker-test/xwiki\n```\n\n# License\n\nXWiki is licensed under the [LGPL 2.1](https://github.com/xwiki-contrib/docker-xwiki/blob/master/LICENSE).\n\nThe Dockerfile repository is also licensed under the [LGPL 2.1](https://github.com/xwiki-contrib/docker-xwiki/blob/master/LICENSE).\n\n# Support\n\n-\tIf you wish to raise an issue or an idea of improvement use [XWiki Docker JIRA project](https://jira.xwiki.org/browse/XDOCKER)\n-\tIf you have questions, use the [XWiki Users Mailing List/Forum](https://dev.xwiki.org/xwiki/bin/view/Community/MailingLists) or use the [XWiki IRC channel](https://dev.xwiki.org/xwiki/bin/view/Community/IRC)\n\n# Contribute\n\n-\tIf you wish to help out on the code, please send Pull Requests on [XWiki Docker GitHub project](https://github.com/xwiki-contrib/docker-xwiki)\n-\tNote that changes need to be merged to all other branches where they make sense and if they make sense for existing tags, those tags must be deleted and recreated.\n-\tIn addition, whenever a branch or tag is modified, a Pull Request on the [DockerHub XWiki official image](https://github.com/docker-library/official-images/blob/master/library/xwiki) must be made \n\n# Credits\n\n-\tOriginally created by Vincent Massol\n-\tContributions from Fabio Mancinelli, Ludovic Dubost, Jean Simard, Denis Germain and a lot of others\n-\tSome code was copied from https://github.com/ThomasSteinbach/docker_xwiki. Thank you Thomas Steinbach\n-\tStolen XWiki ascii art from [https://github.com/babelop](babelop), see https://hub.docker.com/r/binarybabel/xwiki/~/dockerfile/\n"
  },
  {
    "path": "build.gradle",
    "content": "/*\n * See the NOTICE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\nimport org.apache.tools.ant.filters.ReplaceTokens\n\n// Run this Gradle build with 'gradle' to generate the various versions and variants from the template directory.\n// Whenever a new version of XWiki is out, update this file to update the token values, run gradle and commit the\n// result.\n//\n// Note: As a consequence only update the template files and never the generated files!\n\ndefaultTasks 'generate'\n\ndef variants = ['mysql-tomcat', 'mariadb-tomcat', 'postgres-tomcat']\n\n// Notes:\n// - To compute the XWiki sha256, download the XWiki WAR from\n//   http://nexus.xwiki.org/nexus/content/groups/public/org/xwiki/platform/xwiki-platform-distribution-war, and issue:\n//   - Unix: sha256sum <binary name>\n//   - Mac: shasum --algorithm 256 <binary name>\n// - To compute the Mysql JDBC sha256, get the JAR at https://search.maven.org/artifact/com.mysql/mysql-connector-j and do the same as for the XWiki sha256.\n// - To compute the MariaDB JDBC sha256, get the JAR at https://search.maven.org/artifact/org.mariadb.jdbc/mariadb-java-client and  do the same as for the XWiki sha256.\n// - To compute the Postgres JDBC sha256, get the JAR at https://search.maven.org/artifact/org.postgresql/postgresql and do the same as for the XWiki sha256.\n// - Use the JDBC driver versions found in the XWiki POM for the specified versions:\n//   - mysql: https://github.com/xwiki/xwiki-platform/blob/master/pom.xml#L110 (link for master)\n//   - mariadb: https://github.com/xwiki/xwiki-platform/blob/master/pom.xml#L113 (link for master)\n//   - postgresql: https://github.com/xwiki/xwiki-platform/blob/master/pom.xml#L119 (link for master)\n\n// Versions of mysql, mariadb and postgres currently in use in the docker images.\ndef mysql = [\n    '9': [\n        JDBCVersion: '9.7.0',\n        JDBCSha256: '0353648eaa1c91e0f4020c959abf756bc866ffd583df22ae6b6f6e0cbd43eb44'\n    ]\n]\n\ndef mariadb = [\n    '3.5': [\n        JDBCVersion: '3.5.8',\n        JDBCSha256: '6127dc7858047b3d4482899139640b0e2ab2b8abdeb708cfb8c011117771cddf'\n    ]\n]\n\ndef postgres = [\n    '42': [\n        JDBCVersion: '42.7.11',\n        JDBCSha256: '1981b31d3993c58702783c1cddf10a34e48c1f413d70ff1cb6def0a143484647'\n    ]\n]\n\ndef tokens = [\n    '18': [\n        xwikiVersion: '18.3.0',\n        xwikiSha256: '3a0594e4260bc832c8a42f9ea1d6f47d9da7c8ffb7bbe65b7c363e7e8308051a',\n        mysqlJDBCVersion: mysql['9'].JDBCVersion,\n        mysqlJDBCSha256: mysql['9'].JDBCSha256,\n        mariadbJDBCVersion: mariadb['3.5'].JDBCVersion,\n        mariadbJDBCSha256: mariadb['3.5'].JDBCSha256,\n        postgresJDBCVersion: postgres['42'].JDBCVersion,\n        postgresJDBCSha256: postgres['42'].JDBCSha256,\n        tomcatImageTag: [\n            tomcatVersion: '10',\n            javaVersion: '21'\n        ]\n    ],\n    '17': [\n        xwikiVersion: '17.10.8',\n        xwikiSha256: 'f5dfab908fddb6319e64897bb2fc41661dd5b5d8aafa455db72c8a794eaa5287',\n        mysqlJDBCVersion: mysql['9'].JDBCVersion,\n        mysqlJDBCSha256: mysql['9'].JDBCSha256,\n        mariadbJDBCVersion: mariadb['3.5'].JDBCVersion,\n        mariadbJDBCSha256: mariadb['3.5'].JDBCSha256,\n        postgresJDBCVersion: postgres['42'].JDBCVersion,\n        postgresJDBCSha256: postgres['42'].JDBCSha256,\n        tomcatImageTag: [\n            tomcatVersion: '10',\n            javaVersion: '21'\n        ]\n    ]\n]\n\ntask generate() {\n    doLast {\n        // Copy the template for all versions and variants\n        tokens.keySet().each() { version ->\n            variants.each() { variant ->\n                // Extract the db type and add it as a token\n                def (db, servlet) = variant.tokenize('-')\n                tokens[version].'db' = db\n                // Copy common template files, evaluating groovy in them\n                copy {\n                    from 'template'\n                    into \"${version}/${variant}\"\n                    include '.env'\n                    include 'Dockerfile'\n                    include 'docker-compose.yml'\n                    include 'xwiki/*'\n                    expand(tokens[version])\n                    filteringCharset = 'UTF-8'\n                }\n                // Copy DB-specific template files, evaluating groovy in them\n                copy {\n                    from 'template'\n                    into \"${version}/${variant}\"\n                    include \"${db}/*\"\n                    expand(tokens[version])\n                    filteringCharset = 'UTF-8'\n                }\n                // Copy Servlet-specific template files, evaluating groovy in them\n                copy {\n                    from 'template'\n                    into \"${version}/${variant}\"\n                    include \"${servlet}/*\"\n                    expand(tokens[version])\n                    filteringCharset = 'UTF-8'\n                }\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "contrib/solr/solr-init.sh",
    "content": "#!/bin/bash\n\n# Usage:\n# - Place the XWiki Solr configuration jar into the same directory as this script\n#\t- ex. wget https://maven.xwiki.org/releases/org/xwiki/platform/xwiki-platform-search-solr-server-data/10.1/xwiki-platform-search-solr-server-data-10.1.jar\n# - ensure that this directory, and it's contents, are owned by the solr user and group, 8983:8983\n#\t- ex. chown -R 8983:8983 $PARENT_DIRECTORY\n# - mount the partent directory of this script to /docker-entrypoint-initdb.d/ when you run the Solr container\n#\t- ex. add the following to docker run command ... -v $PWD/$PARENT_DIRECTORY:/docker-entrypoint-initdb.d ...\n# - At run time, before starting Solr, the container will execute scripts in the /docker-entrypoint-initdb.d/ directory.\n\ncd /docker-entrypoint-initdb.d/\nlocation='/opt/solr/server/solr/'\n\n# Verify the existence of a singular XWiki Solr configuration jar\njars=$(find . -type f -name *.jar | wc -l)\nif [ $jars -lt 1 ]; then\n\techo 'No XWiki Solr configuration jar found'\n\texit 1\nelif [ $jars -gt 1 ]; then\n\techo 'Too many XWiki Solr configuration jars found, please include only one jar'\n\texit 1\nfi\n# Get the name of the XWiki Solr configuration jar\njar=$(find . -type f -name *.jar)\n# Ensure that the Solr directory exists\nmkdir -p $location\n\n# Add the XWiki Solr plugin\nplugin=$(unzip -Z1 $jar | grep lib.*jar)\nunzip -o $jar \\\n\t$plugin \\\n\t-d $location\n\n# Add the XWiki core\ncore='xwiki/*'\nunzip -o $jar \\\n\t$core \\\n\t-d $location\n"
  },
  {
    "path": "gradle/wrapper/gradle-wrapper.properties",
    "content": "distributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\ndistributionUrl=https\\://services.gradle.org/distributions/gradle-9.5.0-bin.zip\nnetworkTimeout=10000\nretries=0\nretryBackOffMs=500\nvalidateDistributionUrl=true\nzipStoreBase=GRADLE_USER_HOME\nzipStorePath=wrapper/dists\n"
  },
  {
    "path": "gradlew",
    "content": "#!/bin/sh\n\n#\n# Copyright © 2015 the original authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      https://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\n# SPDX-License-Identifier: Apache-2.0\n#\n\n##############################################################################\n#\n#   Gradle start up script for POSIX generated by Gradle.\n#\n#   Important for running:\n#\n#   (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is\n#       noncompliant, but you have some other compliant shell such as ksh or\n#       bash, then to run this script, type that shell name before the whole\n#       command line, like:\n#\n#           ksh Gradle\n#\n#       Busybox and similar reduced shells will NOT work, because this script\n#       requires all of these POSIX shell features:\n#         * functions;\n#         * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,\n#           «${var#prefix}», «${var%suffix}», and «$( cmd )»;\n#         * compound commands having a testable exit status, especially «case»;\n#         * various built-in commands including «command», «set», and «ulimit».\n#\n#   Important for patching:\n#\n#   (2) This script targets any POSIX shell, so it avoids extensions provided\n#       by Bash, Ksh, etc; in particular arrays are avoided.\n#\n#       The \"traditional\" practice of packing multiple parameters into a\n#       space-separated string is a well documented source of bugs and security\n#       problems, so this is (mostly) avoided, by progressively accumulating\n#       options in \"$@\", and eventually passing that to Java.\n#\n#       Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,\n#       and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;\n#       see the in-line comments for details.\n#\n#       There are tweaks for specific operating systems such as AIX, CygWin,\n#       Darwin, MinGW, and NonStop.\n#\n#   (3) This script is generated from the Groovy template\n#       https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt\n#       within the Gradle project.\n#\n#       You can find Gradle at https://github.com/gradle/gradle/.\n#\n##############################################################################\n\n# Attempt to set APP_HOME\n\n# Resolve links: $0 may be a link\napp_path=$0\n\n# Need this for daisy-chained symlinks.\nwhile\n    APP_HOME=${app_path%\"${app_path##*/}\"}  # leaves a trailing /; empty if no leading path\n    [ -h \"$app_path\" ]\ndo\n    ls=$( ls -ld \"$app_path\" )\n    link=${ls#*' -> '}\n    case $link in             #(\n      /*)   app_path=$link ;; #(\n      *)    app_path=$APP_HOME$link ;;\n    esac\ndone\n\n# This is normally unused\n# shellcheck disable=SC2034\nAPP_BASE_NAME=${0##*/}\n# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)\nAPP_HOME=$( cd -P \"${APP_HOME:-./}\" > /dev/null && printf '%s\\n' \"$PWD\" ) || exit\n\n# Use the maximum available, or set MAX_FD != -1 to use that value.\nMAX_FD=maximum\n\nwarn () {\n    echo \"$*\"\n} >&2\n\ndie () {\n    echo\n    echo \"$*\"\n    echo\n    exit 1\n} >&2\n\n# OS specific support (must be 'true' or 'false').\ncygwin=false\nmsys=false\ndarwin=false\nnonstop=false\ncase \"$( uname )\" in                #(\n  CYGWIN* )         cygwin=true  ;; #(\n  Darwin* )         darwin=true  ;; #(\n  MSYS* | MINGW* )  msys=true    ;; #(\n  NONSTOP* )        nonstop=true ;;\nesac\n\n\n\n# Determine the Java command to use to start the JVM.\nif [ -n \"$JAVA_HOME\" ] ; then\n    if [ -x \"$JAVA_HOME/jre/sh/java\" ] ; then\n        # IBM's JDK on AIX uses strange locations for the executables\n        JAVACMD=$JAVA_HOME/jre/sh/java\n    else\n        JAVACMD=$JAVA_HOME/bin/java\n    fi\n    if [ ! -x \"$JAVACMD\" ] ; then\n        die \"ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\n    fi\nelse\n    JAVACMD=java\n    if ! command -v java >/dev/null 2>&1\n    then\n        die \"ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\n    fi\nfi\n\n# Increase the maximum file descriptors if we can.\nif ! \"$cygwin\" && ! \"$darwin\" && ! \"$nonstop\" ; then\n    case $MAX_FD in #(\n      max*)\n        # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.\n        # shellcheck disable=SC2039,SC3045\n        MAX_FD=$( ulimit -H -n ) ||\n            warn \"Could not query maximum file descriptor limit\"\n    esac\n    case $MAX_FD in  #(\n      '' | soft) :;; #(\n      *)\n        # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.\n        # shellcheck disable=SC2039,SC3045\n        ulimit -n \"$MAX_FD\" ||\n            warn \"Could not set maximum file descriptor limit to $MAX_FD\"\n    esac\nfi\n\n# Collect all arguments for the java command, stacking in reverse order:\n#   * args from the command line\n#   * the main class name\n#   * -classpath\n#   * -D...appname settings\n#   * --module-path (only if needed)\n#   * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.\n\n# For Cygwin or MSYS, switch paths to Windows format before running java\nif \"$cygwin\" || \"$msys\" ; then\n    APP_HOME=$( cygpath --path --mixed \"$APP_HOME\" )\n\n    JAVACMD=$( cygpath --unix \"$JAVACMD\" )\n\n    # Now convert the arguments - kludge to limit ourselves to /bin/sh\n    for arg do\n        if\n            case $arg in                                #(\n              -*)   false ;;                            # don't mess with options #(\n              /?*)  t=${arg#/} t=/${t%%/*}              # looks like a POSIX filepath\n                    [ -e \"$t\" ] ;;                      #(\n              *)    false ;;\n            esac\n        then\n            arg=$( cygpath --path --ignore --mixed \"$arg\" )\n        fi\n        # Roll the args list around exactly as many times as the number of\n        # args, so each arg winds up back in the position where it started, but\n        # possibly modified.\n        #\n        # NB: a `for` loop captures its iteration list before it begins, so\n        # changing the positional parameters here affects neither the number of\n        # iterations, nor the values presented in `arg`.\n        shift                   # remove old arg\n        set -- \"$@\" \"$arg\"      # push replacement arg\n    done\nfi\n\n\n# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nDEFAULT_JVM_OPTS='\"-Xmx64m\" \"-Xms64m\"'\n\n# Collect all arguments for the java command:\n#   * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,\n#     and any embedded shellness will be escaped.\n#   * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be\n#     treated as '${Hostname}' itself on the command line.\n\nset -- \\\n        \"-Dorg.gradle.appname=$APP_BASE_NAME\" \\\n        -jar \"$APP_HOME/gradle/wrapper/gradle-wrapper.jar\" \\\n        \"$@\"\n\n# Stop when \"xargs\" is not available.\nif ! command -v xargs >/dev/null 2>&1\nthen\n    die \"xargs is not available\"\nfi\n\n# Use \"xargs\" to parse quoted args.\n#\n# With -n1 it outputs one arg per line, with the quotes and backslashes removed.\n#\n# In Bash we could simply go:\n#\n#   readarray ARGS < <( xargs -n1 <<<\"$var\" ) &&\n#   set -- \"${ARGS[@]}\" \"$@\"\n#\n# but POSIX shell has neither arrays nor command substitution, so instead we\n# post-process each arg (as a line of input to sed) to backslash-escape any\n# character that might be a shell metacharacter, then use eval to reverse\n# that process (while maintaining the separation between arguments), and wrap\n# the whole thing up as a single \"set\" statement.\n#\n# This will of course break if any of these variables contains a newline or\n# an unmatched quote.\n#\n\neval \"set -- $(\n        printf '%s\\n' \"$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS\" |\n        xargs -n1 |\n        sed ' s~[^-[:alnum:]+,./:=@_]~\\\\&~g; ' |\n        tr '\\n' ' '\n    )\" '\"$@\"'\n\nexec \"$JAVACMD\" \"$@\"\n"
  },
  {
    "path": "gradlew.bat",
    "content": "@rem\r\n@rem Copyright 2015 the original author or authors.\r\n@rem\r\n@rem Licensed under the Apache License, Version 2.0 (the \"License\");\r\n@rem you may not use this file except in compliance with the License.\r\n@rem You may obtain a copy of the License at\r\n@rem\r\n@rem      https://www.apache.org/licenses/LICENSE-2.0\r\n@rem\r\n@rem Unless required by applicable law or agreed to in writing, software\r\n@rem distributed under the License is distributed on an \"AS IS\" BASIS,\r\n@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n@rem See the License for the specific language governing permissions and\r\n@rem limitations under the License.\r\n@rem\r\n@rem SPDX-License-Identifier: Apache-2.0\r\n@rem\r\n\r\n@if \"%DEBUG%\"==\"\" @echo off\r\n@rem ##########################################################################\r\n@rem\r\n@rem  Gradle startup script for Windows\r\n@rem\r\n@rem ##########################################################################\r\n\r\n@rem Set local scope for the variables, and ensure extensions are enabled\r\nsetlocal EnableExtensions\r\n\r\nset DIRNAME=%~dp0\r\nif \"%DIRNAME%\"==\"\" set DIRNAME=.\r\n@rem This is normally unused\r\nset APP_BASE_NAME=%~n0\r\nset APP_HOME=%DIRNAME%\r\n\r\n@rem Resolve any \".\" and \"..\" in APP_HOME to make it shorter.\r\nfor %%i in (\"%APP_HOME%\") do set APP_HOME=%%~fi\r\n\r\n@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\r\nset DEFAULT_JVM_OPTS=\"-Xmx64m\" \"-Xms64m\"\r\n\r\n@rem Find java.exe\r\nif defined JAVA_HOME goto findJavaFromJavaHome\r\n\r\nset JAVA_EXE=java.exe\r\n%JAVA_EXE% -version >NUL 2>&1\r\nif %ERRORLEVEL% equ 0 goto execute\r\n\r\necho. 1>&2\r\necho ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2\r\necho. 1>&2\r\necho Please set the JAVA_HOME variable in your environment to match the 1>&2\r\necho location of your Java installation. 1>&2\r\n\r\n\"%COMSPEC%\" /c exit 1\r\n\r\n:findJavaFromJavaHome\r\nset JAVA_HOME=%JAVA_HOME:\"=%\r\nset JAVA_EXE=%JAVA_HOME%/bin/java.exe\r\n\r\nif exist \"%JAVA_EXE%\" goto execute\r\n\r\necho. 1>&2\r\necho ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2\r\necho. 1>&2\r\necho Please set the JAVA_HOME variable in your environment to match the 1>&2\r\necho location of your Java installation. 1>&2\r\n\r\n\"%COMSPEC%\" /c exit 1\r\n\r\n:execute\r\n@rem Setup the command line\r\n\r\n\r\n\r\n@rem Execute Gradle\r\n@rem endlocal doesn't take effect until after the line is parsed and variables are expanded\r\n@rem which allows us to clear the local environment before executing the java command\r\nendlocal & \"%JAVA_EXE%\" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% \"-Dorg.gradle.appname=%APP_BASE_NAME%\" -jar \"%APP_HOME%\\gradle\\wrapper\\gradle-wrapper.jar\" %* & call :exitWithErrorLevel\r\n\r\n:exitWithErrorLevel\r\n@rem Use \"%COMSPEC%\" /c exit to allow operators to work properly in scripts\r\n\"%COMSPEC%\" /c exit %ERRORLEVEL%\r\n"
  },
  {
    "path": "template/Dockerfile",
    "content": "# ---------------------------------------------------------------------------\n# See the NOTICE file distributed with this work for additional\n# information regarding copyright ownership.\n#\n# This is free software; you can redistribute it and/or modify it\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 2.1 of\n# the License, or (at your option) any later version.\n#\n# This software is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n# Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this software; if not, write to the Free\n# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n# 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n# ---------------------------------------------------------------------------\nFROM tomcat:${tomcatImageTag.tomcatVersion}-jre${tomcatImageTag.javaVersion}\n\n#    ____  ____  ____      ____  _   __        _\n#   |_  _||_  _||_  _|    |_  _|(_) [  |  _   (_)\n#     \\\\ \\\\  / /    \\\\ \\\\  /\\\\  / /  __   | | / ]  __\n#      > `' <      \\\\ \\\\/  \\\\/ /  [  |  | '' <  [  |\n#    _/ /'`\\\\ \\\\_     \\\\  /\\\\  /    | |  | |`\\\\ \\\\  | |\n#   |____||____|     \\\\/  \\\\/    [___][__|  \\\\_][___]\n\nLABEL org.opencontainers.image.authors='XWiki Development Team <committers@xwiki.org>'\nLABEL org.opencontainers.image.url='https://hub.docker.com/_/xwiki'\nLABEL org.opencontainers.image.documentation='https://hub.docker.com/_/xwiki'\nLABEL org.opencontainers.image.source='https://github.com/xwiki/xwiki-docker.git'\nLABEL org.opencontainers.image.vendor='xwiki.org'\nLABEL org.opencontainers.image.licenses='LGPL-2.1'\n\n# Note: when using docker-compose, the ENV values below are overridden from the .env file.\n\n# Install LibreOffice + other tools\n# Note that procps is required to get ps which is used by JODConverter to start LibreOffice\nRUN apt-get update && \\\\\n  apt-get --no-install-recommends -y install \\\\\n    curl \\\\\n    libreoffice \\\\\n    unzip \\\\\n    procps && \\\\\n  rm -rf /var/lib/apt/lists/*\n\n# Install XWiki as the ROOT webapp context in Tomcat\n# Create the Tomcat temporary directory\n# Configure the XWiki permanent directory\nENV XWIKI_VERSION=\"$xwikiVersion\"\nENV XWIKI_URL_PREFIX \"https://maven.xwiki.org/releases/org/xwiki/platform/xwiki-platform-distribution-war/\\${XWIKI_VERSION}\"\nENV XWIKI_DOWNLOAD_SHA256 $xwikiSha256\nRUN rm -rf /usr/local/tomcat/webapps/* && \\\\\n  mkdir -p /usr/local/tomcat/temp && \\\\\n  mkdir -p /usr/local/xwiki/data && \\\\\n  curl -fSL \"\\${XWIKI_URL_PREFIX}/xwiki-platform-distribution-war-\\${XWIKI_VERSION}.war\" -o xwiki.war && \\\\\n  echo \"\\$XWIKI_DOWNLOAD_SHA256 xwiki.war\" | sha256sum -c - && \\\\\n  unzip -d /usr/local/tomcat/webapps/ROOT xwiki.war && \\\\\n  rm -f xwiki.war\n\n# Copy the JDBC driver in the XWiki webapp\n<%\nprintln \"# We take the database driver version from the Maven Central repository since we want to control the version \"\nprintln \"# used and have it being consistent with what is tested in the CI.\"\nif (db == 'mysql') {\n  println \"ENV MYSQL_JDBC_VERSION=\\\"$mysqlJDBCVersion\\\"\"\n  println \"ENV MYSQL_JDBC_SHA256=\\\"$mysqlJDBCSha256\\\"\"\n  println \"ENV MYSQL_JDBC_PREFIX=\\\"https://repo1.maven.org/maven2/com/mysql/mysql-connector-j/\\${MYSQL_JDBC_VERSION}\\\"\"\n  println \"ENV MYSQL_JDBC_ARTIFACT=\\\"mysql-connector-j-\\${MYSQL_JDBC_VERSION}.jar\\\"\"\n  println \"ENV MYSQL_JDBC_TARGET=\\\"/usr/local/tomcat/webapps/ROOT/WEB-INF/lib/\\${MYSQL_JDBC_ARTIFACT}\\\"\"\n  println \"RUN curl -fSL \\\"\\${MYSQL_JDBC_PREFIX}/\\${MYSQL_JDBC_ARTIFACT}\\\" -o \\$MYSQL_JDBC_TARGET && \\\\\"\n  print \"  echo \\\"\\$MYSQL_JDBC_SHA256 \\$MYSQL_JDBC_TARGET\\\" | sha256sum -c -\"\n} else if (db == 'mariadb') {\n  println \"ENV MARIADB_JDBC_VERSION=\\\"$mariadbJDBCVersion\\\"\"\n  println \"ENV MARIADB_JDBC_SHA256=\\\"$mariadbJDBCSha256\\\"\"\n  println \"ENV MARIADB_JDBC_PREFIX=\\\"https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/\\${MARIADB_JDBC_VERSION}\\\"\"\n  println \"ENV MARIADB_JDBC_ARTIFACT=\\\"mariadb-java-client-\\${MARIADB_JDBC_VERSION}.jar\\\"\"\n  println \"ENV MARIADB_JDBC_TARGET=\\\"/usr/local/tomcat/webapps/ROOT/WEB-INF/lib/\\${MARIADB_JDBC_ARTIFACT}\\\"\"\n  println \"RUN curl -fSL \\\"\\${MARIADB_JDBC_PREFIX}/\\${MARIADB_JDBC_ARTIFACT}\\\" -o \\$MARIADB_JDBC_TARGET && \\\\\"\n  print \"  echo \\\"\\$MARIADB_JDBC_SHA256 \\$MARIADB_JDBC_TARGET\\\" | sha256sum -c -\"\n} else if (db == 'postgres') {\n  println \"ENV POSTGRES_JDBC_VERSION=\\\"$postgresJDBCVersion\\\"\"\n  println \"ENV POSTGRES_JDBC_SHA256=\\\"$postgresJDBCSha256\\\"\"\n  println \"ENV POSTGRES_JDBC_PREFIX=\\\"https://repo1.maven.org/maven2/org/postgresql/postgresql/\\${POSTGRES_JDBC_VERSION}\\\"\"\n  println \"ENV POSTGRES_JDBC_ARTIFACT=\\\"postgresql-\\${POSTGRES_JDBC_VERSION}.jar\\\"\"\n  println \"ENV POSTGRES_JDBC_TARGET=\\\"/usr/local/tomcat/webapps/ROOT/WEB-INF/lib/\\${POSTGRES_JDBC_ARTIFACT}\\\"\"\n  println \"RUN curl -fSL \\\"\\${POSTGRES_JDBC_PREFIX}/\\${POSTGRES_JDBC_ARTIFACT}\\\" -o \\$POSTGRES_JDBC_TARGET && \\\\\"\n  print \"  echo \\\"\\$POSTGRES_JDBC_SHA256 \\$POSTGRES_JDBC_TARGET\\\" | sha256sum -c -\"\n} %>\n\n# Configure Tomcat. For example set the memory for the Tomcat JVM since the default value is too small for XWiki\nCOPY tomcat/setenv.sh /usr/local/tomcat/bin/\n\n# Setup the XWiki Hibernate configuration\nCOPY xwiki/hibernate.cfg.xml /usr/local/tomcat/webapps/ROOT/WEB-INF/hibernate.cfg.xml\n\n# Set a specific distribution id in XWiki for this docker packaging.\nRUN sed -i \\'s/<id>org.xwiki.platform:xwiki-platform-distribution-war/<id>org.xwiki.platform:xwiki-platform-distribution-docker/\\' \\\\\n  /usr/local/tomcat/webapps/ROOT/META-INF/extension.xed\n\n# Add scripts required to make changes to XWiki configuration files at execution time\n# Note: we don't run CHMOD since 1) it's not required since the executabe bit is already set in git and 2) running\n# CHMOD after a COPY will sometimes fail, depending on different host-specific factors (especially on AUFS).\nCOPY xwiki/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh\n\n# Make the XWiki directory (the permanent directory is included in it) persist on the host (so that it's not recreated\n# across runs)\nVOLUME /usr/local/xwiki\n\n# At this point the image is done and what remains below are the runtime configuration used by the user to configure\n# the container that will be created out of the image. Namely the user can override some environment variables with\n#   docker run -e \"var1=val1\" -e \"var2=val2\" ...\n# The supported environment variables that can be overridden are:\n# - DB_USER: the name of the user configured for XWiki in the DB. Default is \"xwiki\". This is used to configure\n#            xwiki's hibernate.cfg.xml file.\n# - DB_PASSWORD: the password for the user configured for XWiki in the DB. Default is \"xwiki\". This is used to\n#                configure xwiki's hibernate.cfg.xml file.\n# - DB_DATABASE: the name of the database to use. Default is \"xwiki\". This is used to configure xwiki's\n#                hibernate.cfg.xml file.\n# - DB_HOST: The name of the host (or docker container) containing the database. Default is \"db\". This is used to\n#            configure xwiki's hibernate.cfg.xml file.\n# - CONTEXT_PATH: The name of the context path under which XWiki will be deployed in Tomcat. If not specified then it'll\n#                 be deployed as ROOT.\n# - JDBC_PARAMS: Replaces the default JDBC parameters with the passed ones.\n\n# Example:\n#   docker run -it -e \"DB_USER=xwiki\" -e \"DB_PASSWORD=xwiki\" <imagename>\n\n# Starts XWiki by starting Tomcat. All options passed to \"docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]\"\n# are also passed to docker-entrypoint.sh. If \"xwiki\" is passed then XWiki will be configured the first time the\n# container executes and Tomcat will be started. If some other parameter is passed then it'll be executed to comply\n# with best practices defined at https://github.com/docker-library/official-images#consistency.\nENTRYPOINT [\"docker-entrypoint.sh\"]\nCMD [\"xwiki\"]\n"
  },
  {
    "path": "template/docker-compose.yml",
    "content": "# ---------------------------------------------------------------------------\n# See the NOTICE file distributed with this work for additional\n# information regarding copyright ownership.\n#\n# This is free software; you can redistribute it and/or modify it\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 2.1 of\n# the License, or (at your option) any later version.\n#\n# This software is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n# Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this software; if not, write to the Free\n# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n# 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n# ---------------------------------------------------------------------------\nversion: '2'\nnetworks:\n  bridge:\n    driver: bridge\nservices:\n  # The container that runs XWiki in Tomcat, with the appropriate JDBC driver (for ${db}).\n  web:\n    image: \"xwiki:\\${XWIKI_VERSION}-${db}-tomcat\"\n    container_name: xwiki-${db}-tomcat-web\n    depends_on:\n      - db\n    ports:\n      - \"8080:8080\"\n    # Default values defined in .env file.\n    # The DB_USER/DB_PASSWORD/DB_DATABASE/DB_HOST variables are used in the hibernate.cfg.xml file.\n    environment:\n      - XWIKI_VERSION=\\${XWIKI_VERSION}\n      - DB_USER=\\${DB_USER}\n      - DB_PASSWORD=\\${DB_PASSWORD}\n      - DB_DATABASE=\\${DB_DATABASE}\n      - DB_HOST=xwiki-${db}-db\n    # Provide a name instead of an auto-generated id for xwiki data (the permanent directory in included in it)\n    # configured in the Dockerfile, to make it simpler to identify in 'docker volume ls'.\n    volumes:\n      - xwiki-data:/usr/local/xwiki\n    networks:\n      - bridge\n  # The container that runs the database (${db})\n  db:\n    <% if (db == 'mysql') print '''image: \"mysql:9\"\n    container_name: xwiki-mysql-db\n    # - Provide a name instead of an auto-generated id for the mysql data, to make it simpler to identify in\n    # 'docker volume ls'\n    # - Provide a SQL script to be executed when the db image starts (to set permissions to create subwikis)\n    volumes:\n      - mysql-data:/var/lib/mysql\n      - ./init.sql:/docker-entrypoint-initdb.d/init.sql\n\n    # Configure the MySQL database and create a user with provided name/password.\n    # See https://hub.docker.com/_/mysql/ for more details.\n    # Default values defined in .env file.\n    environment:\n      - MYSQL_ROOT_PASSWORD=\\${MYSQL_ROOT_PASSWORD}\n      - MYSQL_USER=\\${DB_USER}\n      - MYSQL_PASSWORD=\\${DB_PASSWORD}\n      - MYSQL_DATABASE=\\${DB_DATABASE}\n\n    # Pass arguments to configure the database\n    command:\n      - \"--character-set-server=utf8mb4\"\n      - \"--collation-server=utf8mb4_bin\"\n      - \"--explicit-defaults-for-timestamp=1\"'''\n\n    else if (db == 'mariadb') print '''image: \"mariadb:12\"\n    container_name: xwiki-mariadb-db\n    # - Provide a name instead of an auto-generated id for the mariadb data, to make it simpler to identify in\n    # 'docker volume ls'\n    # - Provide a SQL script to be executed when the db image starts (to set permissions to create subwikis)\n    volumes:\n      - mariadb-data:/var/lib/mysql\n      - ./init.sql:/docker-entrypoint-initdb.d/init.sql\n\n    # Configure the MariaDB database and create a user with provided name/password.\n    # See https://hub.docker.com/_/mariadb/ for more details.\n    # Default values defined in .env file.\n    environment:\n      - MYSQL_ROOT_PASSWORD=\\${MYSQL_ROOT_PASSWORD}\n      - MYSQL_USER=\\${DB_USER}\n      - MYSQL_PASSWORD=\\${DB_PASSWORD}\n      - MYSQL_DATABASE=\\${DB_DATABASE}\n\n    # Pass arguments to configure the database\n    command:\n      - \"--character-set-server=utf8mb4\"\n      - \"--collation-server=utf8mb4_bin\"\n      - \"--explicit-defaults-for-timestamp=1\"'''\n\n    else if (db == 'postgres') print '''image: \"postgres:18\"\n    container_name: xwiki-postgres-db\n    volumes:\n      - postgres-data:/var/lib/postgresql\n    environment:\n      - POSTGRES_ROOT_PASSWORD=\\${POSTGRES_ROOT_PASSWORD}\n      - POSTGRES_PASSWORD=\\${DB_PASSWORD}\n      - POSTGRES_USER=\\${DB_USER}\n      - POSTGRES_DB=\\${DB_DATABASE}\n      - POSTGRES_INITDB_ARGS=--encoding=UTF8 --locale-provider=builtin --locale=C.UTF-8''' %>\n    networks:\n      - bridge\nvolumes:\n  ${db}-data: {}\n  xwiki-data: {}\n"
  },
  {
    "path": "template/mariadb/init.sql",
    "content": "grant all privileges on *.* to xwiki@'%'"
  },
  {
    "path": "template/mysql/init.sql",
    "content": "grant all privileges on *.* to xwiki@'%'"
  },
  {
    "path": "template/tomcat/setenv.sh",
    "content": "#!/bin/bash\n# ---------------------------------------------------------------------------\n# See the NOTICE file distributed with this work for additional\n# information regarding copyright ownership.\n#\n# This is free software; you can redistribute it and/or modify it\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 2.1 of\n# the License, or (at your option) any later version.\n#\n# This software is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n# Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this software; if not, write to the Free\n# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n# 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n# ---------------------------------------------------------------------------\n\n# We're making the following changes to the default:\n# * Adding more memory (default is 512MB which is not enough for XWiki)\n# * By default, Tomcat does not allow the usage of encoded slash '%2F' and backslash '%5C' in URLs, as noted in\n#   https://tomcat.apache.org/security-6.html#Fixed_in_Apache_Tomcat_6.0.10. We want to allow for them as it's useful to\n#   be able to have '/' and '\\' in wiki page names.\n# * On some system /dev/random is slow to init leading to a slow Tomcat and thus Xwiki startup.\n\n# Users can override these values by setting the JAVA_OPTS environment variable. For example:\n# -e JAVA_OPTS=\"-Xmx2048m\"\n\nXMX=\"-Xmx1024m\"\nALLOW_ENCODED_SLASH=\"-Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true\"\nALLOW_BACKSLASH=\"-Dorg.apache.catalina.connector.CoyoteAdapter.ALLOW_BACKSLASH=true\"\nSECURERANDOM=\"-Djava.security.egd=file:/dev/./urandom\"\n\nif [[ ! -z \"\\$JAVA_OPTS\" ]]; then\n  if [[ ! \\$JAVA_OPTS =~ .*-Xmx[0-9]+.* ]]; then\n    JAVA_OPTS=\"\\$JAVA_OPTS \\$XMX\"\n  fi\n  if [[ ! \\$JAVA_OPTS =~ .*ALLOW_ENCODED_SLASH.* ]]; then\n    JAVA_OPTS=\"\\$JAVA_OPTS \\$ALLOW_ENCODED_SLASH\"\n  fi\n  if [[ ! \\$JAVA_OPTS =~ .*ALLOW_BACKSLASH.* ]]; then\n    JAVA_OPTS=\"\\$JAVA_OPTS \\$ALLOW_BACKSLASH\"\n  fi\n  if [[ ! \\$JAVA_OPTS =~ .*java\\\\.security\\\\.egd.* ]]; then\n    JAVA_OPTS=\"\\$JAVA_OPTS \\$SECURERANDOM\"\n  fi\nelse\n  JAVA_OPTS=\"\\$XMX \\$ALLOW_ENCODED_SLASH \\$ALLOW_BACKSLASH \\$SECURERANDOM\"\nfi\n\nexport JAVA_OPTS\n"
  },
  {
    "path": "template/xwiki/docker-entrypoint.sh",
    "content": "#!/bin/bash\n# ---------------------------------------------------------------------------\n# See the NOTICE file distributed with this work for additional\n# information regarding copyright ownership.\n#\n# This is free software; you can redistribute it and/or modify it\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 2.1 of\n# the License, or (at your option) any later version.\n#\n# This software is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n# Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this software; if not, write to the Free\n# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n# 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n# ---------------------------------------------------------------------------\n\nset -e\n\nfunction first_start() {\n  configure\n  touch /usr/local/tomcat/webapps/\\$CONTEXT_PATH/.first_start_completed\n}\n\nfunction other_starts() {\n  mkdir -p /usr/local/xwiki/data\n  restoreConfigurationFile 'hibernate.cfg.xml'\n  restoreConfigurationFile 'xwiki.cfg'\n  restoreConfigurationFile 'xwiki.properties'\n}\n\n# \\$1 - the path to xwiki.[cfg|properties]\n# \\$2 - the setting/property to set\n# \\$3 - the new value\nfunction xwiki_replace() {\n  # Don't use \"sed -i\" as it creates a temporary file and perform a rename (thus changing the inode of the initial file)\n  # which makes it fail if you map the initial file as a Docker volume mount.\n  sed s~\"\\\\#\\\\? \\\\?\\$2 \\\\?=.*\"~\"\\$2=\\$3\"~g \"\\$1\" > \"\\$1.old\"\n  cp \"\\$1.old\" \"\\$1\"\n  rm \"\\$1.old\"\n}\n\n# \\$1 - the setting/property to set\n# \\$2 - the new value\nfunction xwiki_set_cfg() {\n  xwiki_replace /usr/local/tomcat/webapps/\\$CONTEXT_PATH/WEB-INF/xwiki.cfg \"\\$1\" \"\\$2\"\n}\n\n# \\$1 - the setting/property to set\n# \\$2 - the new value\nfunction xwiki_set_properties() {\n  xwiki_replace /usr/local/tomcat/webapps/\\$CONTEXT_PATH/WEB-INF/xwiki.properties \"\\$1\" \"\\$2\"\n}\n\n# usage: file_env VAR [DEFAULT]\n#    ie: file_env 'XYZ_DB_PASSWORD' 'example'\n# (will allow for \"\\$XYZ_DB_PASSWORD_FILE\" to fill in the value of\n#  \"\\$XYZ_DB_PASSWORD\" from a file, especially for Docker's secrets feature)\nfile_env() {\n  local var=\"\\$1\"\n  local fileVar=\"\\${var}_FILE\"\n  local def=\"\\${2:-}\"\n  if [ \"\\${!var:-}\" ] && [ \"\\${!fileVar:-}\" ]; then\n    echo >&2 \"error: both \\$var and \\$fileVar are set (but are exclusive)\"\n    exit 1\n  fi\n  local val=\"\\$def\"\n  if [ \"\\${!var:-}\" ]; then\n    val=\"\\${!var}\"\n  elif [ \"\\${!fileVar:-}\" ]; then\n    val=\"\\$(< \"\\${!fileVar}\")\"\n  fi\n  export \"\\$var\"=\"\\$val\"\n  unset \"\\$fileVar\"\n}\n\n# Allows to use sed but with user input which can contain special sed characters such as \\\\, / or &.\n# \\$1 - the text to search for\n# \\$2 - the replacement text\n# \\$3 - the file in which to do the search/replace\nfunction safesed {\n  # Don't use \"sed -i\" as it creates a temporary file and perform a rename (thus changing the inode of the initial file)\n  # which makes it fail if you map the initial file as a Docker volume mount.\n  sed \"s/\\$(echo \\$1 | sed -e 's/\\\\([[\\\\/.*]\\\\|\\\\]\\\\)/\\\\\\\\&/g')/\\$(echo \\$2 | sed -e 's/[\\\\/&]/\\\\\\\\&/g')/g\" \"\\$3\" > \"\\$3.old\"\n  cp \"\\$3.old\" \"\\$3\"\n  rm \"\\$3.old\"\n}\n\n# \\$1 - the config file name found in WEB-INF (e.g. \"xwiki.cfg\")\nfunction saveConfigurationFile() {\n  if [ -f \"/usr/local/xwiki/data/\\$1\" ]; then\n     echo \"  Reusing existing config file \\$1...\"\n     cp \"/usr/local/xwiki/data/\\$1\" \"/usr/local/tomcat/webapps/\\$CONTEXT_PATH/WEB-INF/\\$1\"\n  fi\n}\n\n# \\$1 - the config file name to restore in WEB-INF (e.g. \"xwiki.cfg\")\nfunction restoreConfigurationFile() {\n  if [ -f \"/usr/local/xwiki/data/\\$1\" ]; then\n     echo \"  Synchronizing config file \\$1...\"\n     cp \"/usr/local/xwiki/data/\\$1\" \"/usr/local/tomcat/webapps/\\$CONTEXT_PATH/WEB-INF/\\$1\"\n  fi\n}\n\nfunction configure() {\n  echo 'Configuring XWiki...'\n\n  echo 'Setting environment variables'\n  file_env 'DB_USER' 'xwiki'\n  file_env 'DB_PASSWORD' 'xwiki'\n  file_env 'DB_HOST' 'db'\n  file_env 'DB_DATABASE' 'xwiki'\n  file_env 'INDEX_HOST' 'localhost'\n  file_env 'INDEX_PORT' '8983'\n  <% // Set default JDBC param values depending on the DB\n  if (db == 'mysql') {\n    print '''file_env 'JDBC_PARAMS' '?useSSL=false&amp;connectionTimeZone=LOCAL&amp;allowPublicKeyRetrieval=true''''\n  } else if (db == 'mariadb') {\n    print '''file_env 'JDBC_PARAMS' '?useSSL=false''''\n  } else if (db == 'postgres') {\n    print '''file_env 'JDBC_PARAMS' '?''''\n  } %>\n\n  echo \"  Deploying XWiki in the '\\$CONTEXT_PATH' context\"\n  if [ \"\\$CONTEXT_PATH\" == \"ROOT\" ]; then\n    xwiki_set_cfg 'xwiki.webapppath' ''\n  else\n    mkdir -p -v /usr/local/tomcat/webapps/\\$CONTEXT_PATH\n    cp -a --update=none /usr/local/tomcat/webapps/ROOT/.  /usr/local/tomcat/webapps/\\$CONTEXT_PATH/\n  fi\n\n  echo 'Replacing environment variables in files'\n  safesed \"replaceuser\" \\$DB_USER /usr/local/tomcat/webapps/\\$CONTEXT_PATH/WEB-INF/hibernate.cfg.xml\n  safesed \"replacepassword\" \\$DB_PASSWORD /usr/local/tomcat/webapps/\\$CONTEXT_PATH/WEB-INF/hibernate.cfg.xml\n  safesed \"replacecontainer\" \\$DB_HOST /usr/local/tomcat/webapps/\\$CONTEXT_PATH/WEB-INF/hibernate.cfg.xml\n  safesed \"replacedatabase\" \\$DB_DATABASE /usr/local/tomcat/webapps/\\$CONTEXT_PATH/WEB-INF/hibernate.cfg.xml\n  safesed \"replacejdbcparams\" \\$JDBC_PARAMS /usr/local/tomcat/webapps/\\$CONTEXT_PATH/WEB-INF/hibernate.cfg.xml\n\n  <% // XWiki uses PostgreSQL schemas by default and the schema name is defined by xwiki.db. Thus we shouldn't change it\n  // when the db name is not the default one (the schema must remain being \"public\"). For MySQL and MariaDB, we use\n  // different dbs (and not schemas and thus \"xwiki.db\" must be set.\n  if (db != 'postgres') {\n    println '''# Set any non-default main wiki database name in the xwiki.cfg file.'''\n    println '''  if [ \"\\$DB_DATABASE\" != \"xwiki\" ]; then'''\n    println '''    xwiki_set_cfg \"xwiki.db\" \\$DB_DATABASE'''\n    print '''  fi'''\n  } %>\n\n  echo '  Setting permanent directory...'\n  xwiki_set_properties 'environment.permanentDirectory' '/usr/local/xwiki/data'\n  echo '  Configure libreoffice...'\n  xwiki_set_properties 'openoffice.autoStart' 'true'\n\n  if [ \\$INDEX_HOST != 'localhost' ]; then\n    echo '  Configuring remote Solr Index'\n    xwiki_set_properties 'solr.type' 'remote'\n    xwiki_set_properties 'solr.remote.url' \"http://\\$INDEX_HOST:\\$INDEX_PORT/solr/xwiki\"\n  fi\n\n  # If the files already exist then copy them to the XWiki's WEB-INF directory.\n  mkdir -p /usr/local/xwiki/data\n  saveConfigurationFile 'hibernate.cfg.xml'\n  saveConfigurationFile 'xwiki.cfg'\n  saveConfigurationFile 'xwiki.properties'\n}\n\n# This if will check if the first argument is a flag but only works if all arguments require a hyphenated flag\n# -v; -SL; -f arg; etc will work, but not arg1 arg2\nif [ \"\\${1:0:1}\" = '-' ]; then\n    set -- xwiki \"\\$@\"\nfi\n\n# Check for the expected command\nif [ \"\\$1\" = 'xwiki' ]; then\n  file_env 'CONTEXT_PATH' 'ROOT'\n  if [[ ! -f /usr/local/tomcat/webapps/\\$CONTEXT_PATH/.first_start_completed ]]; then\n    first_start\n  else\n    other_starts\n  fi\n  shift\n  set -- catalina.sh run \"\\$@\"\nfi\n\n# Else default to run whatever the user wanted like \"bash\"\nexec \"\\$@\"\n"
  },
  {
    "path": "template/xwiki/hibernate.cfg.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<!--\n * See the NOTICE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n-->\n\n<!DOCTYPE hibernate-configuration PUBLIC\n  \"-//Hibernate/Hibernate Configuration DTD//EN\"\n  \"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd\">\n<hibernate-configuration>\n  <session-factory>\n\n    <!-- Please refer to the installation guide on\n         https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Installation/ for configuring your\n         database. You'll need to do 2 things:\n         1) Copy your database driver JAR in WEB-INF/lib or in some shared lib directory\n         2) Uncomment the properties below for your specific DB (and comment the default\n            database configuration if it doesn't match your DB)\n    -->\n\n    <!-- Generic parameters common to all Databases -->\n\n    <property name=\"show_sql\">false</property>\n    <property name=\"use_outer_join\">true</property>\n\n    <!-- Without it, some queries fail in MS SQL. XWiki doesn't need scrollable result sets, anyway. -->\n    <property name=\"jdbc.use_scrollable_resultset\">false</property>\n\n    <!-- DBCP Connection Pooling configuration. Only some properties are shown. All available properties can be found\n         at https://commons.apache.org/proper/commons-dbcp/configuration.html\n    -->\n    <property name=\"dbcp.defaultAutoCommit\">false</property>\n    <property name=\"dbcp.maxTotal\">50</property>\n    <property name=\"dbcp.maxIdle\">5</property>\n    <property name=\"dbcp.maxWaitMillis\">30000</property>\n    <property name=\"connection.provider_class\">com.xpn.xwiki.store.DBCPConnectionProvider</property>\n\n    <!-- Setting \"dbcp.poolPreparedStatements\" to true and \"dbcp.maxOpenPreparedStatements\" will tell DBCP to cache\n         Prepared Statements (it's off by default). Note that for backward compatibility the \"dbcp.ps.maxActive\" is also\n         supported and when set it'll set \"dbcp.poolPreparedStatements\" to true and \"dbcp.maxOpenPreparedStatements\" to\n         value of \"dbcp.ps.maxActive\".\n\n         Note 1: When using HSQLDB for example, it's important to NOT cache prepared statements because HSQLDB\n         Prepared Statements (PS) contain the schema on which they were initially created and thus when switching\n         schema if the same PS is reused it'll execute on the wrong schema! Since HSQLDB does internally cache\n         prepared statement there's no performance loss by not caching Prepared Statements at the DBCP level.\n         See https://jira.xwiki.org/browse/XWIKI-1740.\n         Thus we recommend not turning on this configuration for HSQLDB unless you know what you're doing :)\n\n         Note 2: The same applies to PostGreSQL.\n    -->\n\n    <!-- BoneCP Connection Pooling configuration.\n    <property name=\"bonecp.idleMaxAgeInMinutes\">240</property>\n    <property name=\"bonecp.idleConnectionTestPeriodInMinutes\">60</property>\n    <property name=\"bonecp.partitionCount\">3</property>\n    <property name=\"bonecp.acquireIncrement\">10</property>\n    <property name=\"bonecp.maxConnectionsPerPartition\">60</property>\n    <property name=\"bonecp.minConnectionsPerPartition\">20</property>\n    <property name=\"bonecp.statementsCacheSize\">50</property>\n    <property name=\"bonecp.releaseHelperThreads\">3</property>\n    <property name=\"connection.provider_class\">com.xpn.xwiki.store.DBCPConnectionProvider</property>\n    -->\n\n    <% if (db == 'mysql') print '''<!-- MySQL configuration.\n         Notes:\n           - If you want the main wiki database to be different than \"xwiki\"\n             you will also have to set the property xwiki.db in xwiki.cfg file\n           - Use the local timezone to work around a bug in the MySQL 8.x which often does not understand the server\n              timezone and crash\n    -->\n    <property name=\"connection.url\">jdbc:mysql://replacecontainer/replacedatabasereplacejdbcparams</property>\n    <property name=\"connection.username\">replaceuser</property>\n    <property name=\"connection.password\">replacepassword</property>\n    <property name=\"connection.driver_class\">com.mysql.cj.jdbc.Driver</property>\n    <property name=\"dbcp.poolPreparedStatements\">true</property>\n    <property name=\"dbcp.maxOpenPreparedStatements\">20</property>\n\n    <property name=\"hibernate.connection.charSet\">UTF-8</property>\n    <property name=\"hibernate.connection.useUnicode\">true</property>\n    <property name=\"hibernate.connection.characterEncoding\">utf8</property>\n\n    <mapping resource=\"xwiki.hbm.xml\"/>\n    <mapping resource=\"feeds.hbm.xml\"/>\n    <mapping resource=\"instance.hbm.xml\"/>\n    <mapping resource=\"notification-filter-preferences.hbm.xml\"/>\n    <mapping resource=\"mailsender.hbm.xml\"/>'''\n\n    else if (db == 'mariadb') print '''<!-- MariaDB configuration.\n         Notes:\n           - If you want the main wiki database to be different than \"xwiki\"\n             you will also have to set the property xwiki.db in xwiki.cfg file\n    -->\n    <property name=\"connection.url\">jdbc:mariadb://replacecontainer/replacedatabasereplacejdbcparams</property>\n    <property name=\"connection.username\">replaceuser</property>\n    <property name=\"connection.password\">replacepassword</property>\n    <property name=\"connection.driver_class\">org.mariadb.jdbc.Driver</property>\n    <property name=\"dbcp.poolPreparedStatements\">true</property>\n    <property name=\"dbcp.maxOpenPreparedStatements\">20</property>\n\n    <property name=\"hibernate.connection.charSet\">UTF-8</property>\n    <property name=\"hibernate.connection.useUnicode\">true</property>\n    <property name=\"hibernate.connection.characterEncoding\">utf8</property>\n\n    <mapping resource=\"xwiki.hbm.xml\"/>\n    <mapping resource=\"feeds.hbm.xml\"/>\n    <mapping resource=\"instance.hbm.xml\"/>\n    <mapping resource=\"notification-filter-preferences.hbm.xml\"/>\n    <mapping resource=\"mailsender.hbm.xml\"/>'''\n\n    else if (db == 'postgres') print '''<!-- PostgreSQL configuration.\n         Notes:\n           - \"jdbc.use_streams_for_binary\" needs to be set to \"false\",\n             see https://community.jboss.org/wiki/HibernateCoreMigrationGuide36\n           - \"xwiki.virtual_mode\" can be set to either \"schema\" or \"database\". Note that currently the database mode\n             doesn't support database creation (see https://jira.xwiki.org/browse/XWIKI-8753)\n           - if you want the main wiki database to be different than \"xwiki\" (or \"public\" in schema mode)\n             you will also have to set the property xwiki.db in xwiki.cfg file\n    -->\n    <property name=\"connection.url\">jdbc:postgresql://replacecontainer:5432/replacedatabasereplacejdbcparams</property>\n    <property name=\"connection.username\">replaceuser</property>\n    <property name=\"connection.password\">replacepassword</property>\n    <property name=\"connection.driver_class\">org.postgresql.Driver</property>\n    <property name=\"jdbc.use_streams_for_binary\">false</property>\n    <property name=\"xwiki.virtual_mode\">schema</property>\n\n    <property name=\"hibernate.connection.charSet\">UTF-8</property>\n    <property name=\"hibernate.connection.useUnicode\">true</property>\n    <property name=\"hibernate.connection.characterEncoding\">utf8</property>\n\n    <mapping resource=\"xwiki.postgresql.hbm.xml\"/>\n    <mapping resource=\"feeds.hbm.xml\"/>\n    <mapping resource=\"instance.hbm.xml\"/>\n    <mapping resource=\"notification-filter-preferences.hbm.xml\"/>\n    <mapping resource=\"mailsender.hbm.xml\"/>''' %>\n  </session-factory>\n</hibernate-configuration>\n"
  }
]