From 717de1291dce41c0945165532c46616c762714fa Mon Sep 17 00:00:00 2001 From: Vincent Massol <vincent@massol.net> Date: Fri, 24 Feb 2017 11:39:21 +0100 Subject: [PATCH] XDOCKER-15: Reorganize directory structure to remove the need for branches --- xwiki-mysql-tomcat/.dockerignore | 1 - xwiki-mysql-tomcat/.env | 7 -- xwiki-mysql-tomcat/Dockerfile | 93 ---------------- xwiki-mysql-tomcat/docker-compose-using.yml | 67 ------------ xwiki-mysql-tomcat/docker-compose.yml | 72 ------------- xwiki-mysql-tomcat/mysql/xwiki.cnf | 11 -- xwiki-mysql-tomcat/tomcat/setenv.sh | 1 - xwiki-mysql-tomcat/xwiki/docker-entrypoint.sh | 85 --------------- xwiki-mysql-tomcat/xwiki/hibernate.cfg.xml | 101 ------------------ 9 files changed, 438 deletions(-) delete mode 100644 xwiki-mysql-tomcat/.dockerignore delete mode 100644 xwiki-mysql-tomcat/.env delete mode 100644 xwiki-mysql-tomcat/Dockerfile delete mode 100644 xwiki-mysql-tomcat/docker-compose-using.yml delete mode 100644 xwiki-mysql-tomcat/docker-compose.yml delete mode 100644 xwiki-mysql-tomcat/mysql/xwiki.cnf delete mode 100755 xwiki-mysql-tomcat/tomcat/setenv.sh delete mode 100755 xwiki-mysql-tomcat/xwiki/docker-entrypoint.sh delete mode 100644 xwiki-mysql-tomcat/xwiki/hibernate.cfg.xml diff --git a/xwiki-mysql-tomcat/.dockerignore b/xwiki-mysql-tomcat/.dockerignore deleted file mode 100644 index f4df651..0000000 --- a/xwiki-mysql-tomcat/.dockerignore +++ /dev/null @@ -1 +0,0 @@ -docker-compose-using.yml diff --git a/xwiki-mysql-tomcat/.env b/xwiki-mysql-tomcat/.env deleted file mode 100644 index 10a3dd8..0000000 --- a/xwiki-mysql-tomcat/.env +++ /dev/null @@ -1,7 +0,0 @@ -# Default environment values -XWIKI_VERSION=8.4.4 -MYSQL_DRIVER_VERSION=5.1.38 -MYSQL_USER=xwiki -MYSQL_PASSWORD=xwiki -MYSQL_DATABASE=xwiki -MYSQL_ROOT_PASSWORD=xwiki diff --git a/xwiki-mysql-tomcat/Dockerfile b/xwiki-mysql-tomcat/Dockerfile deleted file mode 100644 index c72d1cc..0000000 --- a/xwiki-mysql-tomcat/Dockerfile +++ /dev/null @@ -1,93 +0,0 @@ -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- -FROM tomcat:8-jre8 - -MAINTAINER Vincent Massol <vincent@massol.net> - -# Note: when using docker-compose, the ENV values below are overridden from the .env file. - -# Install LibreOffice + other tools -RUN apt-get update && \ - apt-get --no-install-recommends -y install \ - curl \ - libreoffice \ - unzip \ - libmysql-java && \ - rm -rf /var/lib/apt/lists/* - -# Install XWiki as the ROOT webapp context in Tomcat -# Create the Tomcat temporary directory -# Configure the XWiki permanent directory -ENV XWIKI_VERSION=8.4.4 -ENV XWIKI_URL_PREFIX "http://maven.xwiki.org/releases/org/xwiki/enterprise/xwiki-enterprise-web/${XWIKI_VERSION}" -# Note: To compute the sha256, download the binary and issue: -# - Unix: sha256sum <binary name> -# - Mac: shasum --algorithm 25 <binary name> -ENV XWIKI_DOWNLOAD_SHA256 b414edb4527e3d8b27c40a8c3f2f09423980de7963207b7dc89da71d14e7fb23 -RUN rm -rf /usr/local/tomcat/webapps/* && \ - mkdir -p /usr/local/tomcat/temp && \ - mkdir -p /usr/local/xwiki/data && \ - curl -fSL "${XWIKI_URL_PREFIX}/xwiki-enterprise-web-${XWIKI_VERSION}.war" -o xwiki.war && \ - echo "$XWIKI_DOWNLOAD_SHA256 xwiki.war" | sha256sum -c - && \ - unzip -d /usr/local/tomcat/webapps/ROOT xwiki.war && \ - rm -f xwiki.war - -# Copy the MySQL JDBC driver in the XWiki webapp -RUN cp /usr/share/java/mysql-connector-java-*.jar /usr/local/tomcat/webapps/ROOT/WEB-INF/lib/ - -# Configure Tomcat. For example set the memory for the Tomcat JVM since the default value is too small for XWiki -COPY tomcat/setenv.sh /usr/local/tomcat/bin/ - -# Setup the XWiki Hibernate configuration -ENV MYSQL_DATABASE=xwiki -COPY xwiki/hibernate.cfg.xml /usr/local/tomcat/webapps/ROOT/WEB-INF/hibernate.cfg.xml - -# Set a specific distribution id in XWiki for this docker packaging. -RUN sed -i 's/<id>org.xwiki.enterprise:xwiki-enterprise-web/<id>org.xwiki.enterprise:xwiki-enterprise-docker/' \ - /usr/local/tomcat/webapps/ROOT/META-INF/extension.xed - -# Add scripts required to make changes to XWiki configuration files at execution time -# Note: we don't run CHMOD since 1) it's not required since the executabe bit is already set in git and 2) running -# CHMOD after a COPY will sometimes fail, depending on different host-specific factors (especially on AUFS). -COPY xwiki/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh - -# Make the XWiki directory (the permanent directory is included in it) persist on the host (so that it's not recreated -# across runs) -VOLUME /usr/local/xwiki - -# At this point the image is done and what remains below are the runtime configuration used by the user to configure -# the container that will be created out of the image. Namely the user can override some environment variables with -# docker run -e "var1=val1" -e "var2=val2" ... -# The supported environment variables that can be overridden are: -# - MYSQL_USER: the name of the user configured for XWiki in the DB. Default is "xwiki". This is used to configure -# xwiki's hibernate.cfg.xml file. -# - MYSQL_PASSWORD: the password for the user configured for XWiki in the DB. Default is "xwiki". This is used to -# configure xwiki's hibernate.cfg.xml file. -# Example: -# docker run -it -e "MYSQL_USER=xwiki" -e "MYSQL_PASSWORD=xwiki" <imagename> - -# Starts XWiki by starting Tomcat. All options passed to "docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]" -# are also passed to docker-entrypoint.sh. If "xwiki" is passed then XWiki will be configured the first time the -# container executes and Tomcat will be started. If some other parameter is passed then it'll be executed to comply -# with best practices defined at https://github.com/docker-library/official-images#consistency. -ENV MYSQL_USER=xwiki \ - MYSQL_PASSWORD=xwiki -ENTRYPOINT ["docker-entrypoint.sh"] -CMD ["xwiki"] diff --git a/xwiki-mysql-tomcat/docker-compose-using.yml b/xwiki-mysql-tomcat/docker-compose-using.yml deleted file mode 100644 index 3842218..0000000 --- a/xwiki-mysql-tomcat/docker-compose-using.yml +++ /dev/null @@ -1,67 +0,0 @@ -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- -version: '2' -networks: - bridge: - driver: bridge -services: - web: - # Use an already built XWiki image from DockerHub. - image: "xwiki:mysql-tomcat" - container_name: xwiki - depends_on: - - db - ports: - - "8080:8080" - # The MYSQL_USER/MYSQL_PASSWORD/DB_CONTAINER_NAME variables are used in the hibernate.cfg.xml file. - environment: - - MYSQL_USER=xwiki - - MYSQL_PASSWORD=xwiki - - DB_CONTAINER_NAME=xwiki-mysql - # Provide a name instead of an auto-generated id for the xwiki permanent directory configured in the Dockerfile, - # to make it simpler to identify in 'docker volume ls'. - volumes: - - xwiki-data:/usr/local/xwiki - networks: - - bridge - # The container that runs MySQL - db: - image: "mysql:5.7" - container_name: xwiki-mysql - # - We provide a xwiki.cnf file in order to configure the mysql db to support UTF8 and be case-insensitive - # We have to do it here since we use an existing image and that's how this image allows customizations. - # See https://hub.docker.com/_/mysql/ for more details. - # - Provide a name instead of an auto-generated id for the mysql data, to make it simpler to identify in - # 'docker volume ls' - volumes: - - ./xwiki.cnf:/etc/mysql/conf.d/xwiki.cnf - - mysql-data:/var/lib/mysql - # Configure the MySQL database and create a user with provided name/password. - # See https://hub.docker.com/_/mysql/ for more details. - environment: - - MYSQL_ROOT_PASSWORD=xwiki - - MYSQL_USER=xwiki - - MYSQL_PASSWORD=xwiki - - MYSQL_DATABASE=xwiki - networks: - - bridge -volumes: - mysql-data: {} - xwiki-data: {} diff --git a/xwiki-mysql-tomcat/docker-compose.yml b/xwiki-mysql-tomcat/docker-compose.yml deleted file mode 100644 index c7bd535..0000000 --- a/xwiki-mysql-tomcat/docker-compose.yml +++ /dev/null @@ -1,72 +0,0 @@ -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- -version: '2' -networks: - bridge: - driver: bridge -services: - # The container that runs XWiki + Tomcat - web: - build: . - container_name: xwiki - depends_on: - - db - ports: - - "8080:8080" - # Default values defined in .env file. - # The MYSQL_USER/MYSQL_PASSWORD/MYSQL_DATABASE/DB_CONTAINER_NAME variables are used in the hibernate.cfg.xml file. - environment: - - XWIKI_VERSION=${XWIKI_VERSION} - - MYSQL_DRIVER_VERSION=${MYSQL_DRIVER_VERSION} - - MYSQL_USER=${MYSQL_USER} - - MYSQL_PASSWORD=${MYSQL_PASSWORD} - - MYSQL_DATABASE=${MYSQL_DATABASE} - - DB_CONTAINER_NAME=xwiki-mysql - # Provide a name instead of an auto-generated id for xwiki data (the permanent directory in included in it) - # configured in the Dockerfile, to make it simpler to identify in 'docker volume ls'. - volumes: - - xwiki-data:/usr/local/xwiki - networks: - - bridge - # The container that runs MySQL - db: - image: "mysql:5.7" - container_name: xwiki-mysql - # - We provide a xwiki.cnf file in order to configure the mysql db to support UTF8 and be case-insensitive - # We have to do it here since we use an existing image and that's how this image allows customizations. - # See https://hub.docker.com/_/mysql/ for more details. - # - Provide a name instead of an auto-generated id for the mysql data, to make it simpler to identify in - # 'docker volume ls' - volumes: - - ./mysql/xwiki.cnf:/etc/mysql/conf.d/xwiki.cnf - - mysql-data:/var/lib/mysql - # Configure the MySQL database and create a user with provided name/password. - # See https://hub.docker.com/_/mysql/ for more details. - # Default values defined in .env file. - environment: - - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} - - MYSQL_USER=${MYSQL_USER} - - MYSQL_PASSWORD=${MYSQL_PASSWORD} - - MYSQL_DATABASE=${MYSQL_DATABASE} - networks: - - bridge -volumes: - mysql-data: {} - xwiki-data: {} diff --git a/xwiki-mysql-tomcat/mysql/xwiki.cnf b/xwiki-mysql-tomcat/mysql/xwiki.cnf deleted file mode 100644 index 73e4844..0000000 --- a/xwiki-mysql-tomcat/mysql/xwiki.cnf +++ /dev/null @@ -1,11 +0,0 @@ -[client] -default-character-set = utf8 - -[mysqld] -character-set-server = utf8 -collation-server = utf8_bin -explicit_defaults_for_timestamp = 1 - -[mysql] -default-character-set = utf8 - diff --git a/xwiki-mysql-tomcat/tomcat/setenv.sh b/xwiki-mysql-tomcat/tomcat/setenv.sh deleted file mode 100755 index 9e4977b..0000000 --- a/xwiki-mysql-tomcat/tomcat/setenv.sh +++ /dev/null @@ -1 +0,0 @@ -export CATALINA_OPTS="-Xmx1024m" diff --git a/xwiki-mysql-tomcat/xwiki/docker-entrypoint.sh b/xwiki-mysql-tomcat/xwiki/docker-entrypoint.sh deleted file mode 100755 index 586f4ab..0000000 --- a/xwiki-mysql-tomcat/xwiki/docker-entrypoint.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/bash -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- - -set -e - -function first_start() { - configure - touch /usr/local/xwiki/.first_start_completed -} - -# $1 - the path to xwiki.[cfg|properties] -# $2 - the setting/property to set -# $3 - the new value -function xwiki_replace() { - sed -i s~"\#\? \?$2 \?=.*"~"$2=$3"~g "$1" -} - -# $1 - the setting/property to set -# $2 - the new value -function xwiki_set_cfg() { - xwiki_replace /usr/local/tomcat/webapps/ROOT/WEB-INF/xwiki.cfg "$1" "$2" -} - -# $1 - the setting/property to set -# $2 - the new value -function xwiki_set_properties() { - xwiki_replace /usr/local/tomcat/webapps/ROOT/WEB-INF/xwiki.properties "$1" "$2" -} - -function configure() { - echo 'Configuring XWiki...' - sed -i "s/replacemysqluser/${MYSQL_USER:-xwiki}/g" /usr/local/tomcat/webapps/ROOT/WEB-INF/hibernate.cfg.xml - sed -i "s/replacemysqlpassword/${MYSQL_PASSWORD:-xwiki}/g" /usr/local/tomcat/webapps/ROOT/WEB-INF/hibernate.cfg.xml - sed -i "s/replacemysqlcontainername/${DB_CONTAINER_NAME:-db}/g" /usr/local/tomcat/webapps/ROOT/WEB-INF/hibernate.cfg.xml - sed -i "s/replacemysqldatabase/${MYSQL_DATABASE:-xwiki}/g" /usr/local/tomcat/webapps/ROOT/WEB-INF/hibernate.cfg.xml - - echo ' Using filesystem-based attachments...' - xwiki_set_cfg 'xwiki.store.attachment.hint' 'file' - xwiki_set_cfg 'xwiki.store.attachment.versioning.hint' 'file' - xwiki_set_cfg 'xwiki.store.attachment.recyclebin.hint' 'file' - echo ' Generating authentication validation and encryption keys...' - xwiki_set_cfg 'xwiki.authentication.validationKey' "$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)" - xwiki_set_cfg 'xwiki.authentication.encryptionKey' "$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)" - - echo ' Setting permanent directory...' - xwiki_set_properties 'environment.permanentDirectory' '/usr/local/xwiki/data' - echo ' Configure libreoffice...' - xwiki_set_properties 'openoffice.autoStart' 'true' -} - -# This if will check if the first argument is a flag but only works if all arguments require a hyphenated flag -# -v; -SL; -f arg; etc will work, but not arg1 arg2 -if [ "${1:0:1}" = '-' ]; then - set -- xwiki "$@" -fi - -# Check for the expected command -if [ "$1" = 'xwiki' ]; then - if [[ ! -f /usr/local/xwiki/.first_start_completed ]]; then - first_start - fi - shift - set -- catalina.sh run "$@" -fi - -# Else default to run whatever the user wanted like "bash" -exec "$@" diff --git a/xwiki-mysql-tomcat/xwiki/hibernate.cfg.xml b/xwiki-mysql-tomcat/xwiki/hibernate.cfg.xml deleted file mode 100644 index bdd419b..0000000 --- a/xwiki-mysql-tomcat/xwiki/hibernate.cfg.xml +++ /dev/null @@ -1,101 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!-- - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. ---> - -<!DOCTYPE hibernate-configuration PUBLIC - "-//Hibernate/Hibernate Configuration DTD//EN" - "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> -<hibernate-configuration> - <session-factory> - - <!-- Please refer to the installation guide on - http://platform.xwiki.org/xwiki/bin/view/AdminGuide/Installation for configuring your - database. You'll need to do 2 things: - 1) Copy your database driver JAR in WEB-INF/lib or in some shared lib directory - 2) Uncomment the properties below for your specific DB (and comment the default - database configuration if it doesn't match your DB) - --> - - <!-- Generic parameters common to all Databases --> - - <property name="show_sql">false</property> - <property name="use_outer_join">true</property> - - <!-- Without it, some queries fail in MS SQL. XWiki doesn't need scrollable result sets, anyway. --> - <property name="jdbc.use_scrollable_resultset">false</property> - - <!-- DBCP Connection Pooling configuration. Only some properties are shown. All available properties can be found - at http://commons.apache.org/proper/commons-dbcp/configuration.html - --> - <property name="dbcp.defaultAutoCommit">false</property> - <property name="dbcp.maxTotal">50</property> - <property name="dbcp.maxIdle">5</property> - <property name="dbcp.maxWaitMillis">30000</property> - <property name="connection.provider_class">com.xpn.xwiki.store.DBCPConnectionProvider</property> - - <!-- Setting "dbcp.poolPreparedStatements" to true and "dbcp.maxOpenPreparedStatements" will tell DBCP to cache - Prepared Statements (it's off by default). Note that for backward compatibility the "dbcp.ps.maxActive" is also - supported and when set it'll set "dbcp.poolPreparedStatements" to true and "dbcp.maxOpenPreparedStatements" to - value of "dbcp.ps.maxActive". - - Note 1: When using HSQLDB for example, it's important to NOT cache prepared statements because HSQLDB - Prepared Statements (PS) contain the schema on which they were initially created and thus when switching - schema if the same PS is reused it'll execute on the wrong schema! Since HSQLDB does internally cache - prepared statement there's no performance loss by not caching Prepared Statements at the DBCP level. - See http://jira.xwiki.org/browse/XWIKI-1740. - Thus we recommend not turning on this configuration for HSQLDB unless you know what you're doing :) - - Note 2: The same applies to PostGreSQL. - --> - - <!-- BoneCP Connection Pooling configuration. - <property name="bonecp.idleMaxAgeInMinutes">240</property> - <property name="bonecp.idleConnectionTestPeriodInMinutes">60</property> - <property name="bonecp.partitionCount">3</property> - <property name="bonecp.acquireIncrement">10</property> - <property name="bonecp.maxConnectionsPerPartition">60</property> - <property name="bonecp.minConnectionsPerPartition">20</property> - <property name="bonecp.statementsCacheSize">50</property> - <property name="bonecp.releaseHelperThreads">3</property> - <property name="connection.provider_class">com.xpn.xwiki.store.DBCPConnectionProvider</property> - --> - - <!-- MySQL configuration. - Uncomment if you want to use MySQL and comment out other database configurations. - Notes: - - if you want the main wiki database to be different than "xwiki" - you will also have to set the property xwiki.db in xwiki.cfg file - --> - <property name="connection.url">jdbc:mysql://replacemysqlcontainername/replacemysqldatabase?useSSL=false</property> - <property name="connection.username">replacemysqluser</property> - <property name="connection.password">replacemysqlpassword</property> - <property name="connection.driver_class">com.mysql.jdbc.Driver</property> - <property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property> - <property name="dbcp.poolPreparedStatements">true</property> - <property name="dbcp.maxOpenPreparedStatements">20</property> - <mapping resource="xwiki.hbm.xml"/> - <mapping resource="feeds.hbm.xml"/> - <mapping resource="activitystream.hbm.xml"/> - <mapping resource="instance.hbm.xml"/> - <mapping resource="mailsender.hbm.xml"/> - - </session-factory> -</hibernate-configuration> -- GitLab