diff --git a/10/solr/.env b/10/solr/.env new file mode 100644 index 00000000..e449a4fd --- /dev/null +++ b/10/solr/.env @@ -0,0 +1,6 @@ +# Default environment values +XWIKI_VERSION=10.11.8 +DB_USER=xwiki +DB_PASSWORD=xwiki +DB_DATABASE=xwiki +POSTGRES_ROOT_PASSWORD=xwiki diff --git a/10/solr/Dockerfile b/10/solr/Dockerfile new file mode 100644 index 00000000..ddc88eca --- /dev/null +++ b/10/solr/Dockerfile @@ -0,0 +1,20 @@ +# ARG used in FROM must come first +ARG SOLR_VERSION=7.5.0 + +FROM busybox as buildenv + +# ARG for build must come after the FROM statement +ARG XWIKI_VERSION=10.11.8 +ARG XWIKI_URL_PREFIX="https://maven.xwiki.org/releases/org/xwiki/platform/xwiki-platform-search-solr-server-data/${XWIKI_VERSION}" + +ENV XWIKI_SOLR_SHA256 0cce5266f3d9925cf09b041b1b4ea833332a0f6d9e90291e3c719f5866c52c0a + +WORKDIR /var/xwiki-solr-temp/ + +COPY ./solr-init.sh . +RUN wget "${XWIKI_URL_PREFIX}/xwiki-platform-search-solr-server-data-${XWIKI_VERSION}.jar" +RUN echo "$XWIKI_SOLR_SHA256 xwiki-platform-search-solr-server-data-${XWIKI_VERSION}.jar" | sha256sum -c - + +FROM solr:${SOLR_VERSION} + +COPY --from=buildenv /var/xwiki-solr-temp/ /docker-entrypoint-initdb.d/ \ No newline at end of file diff --git a/10/solr/docker-compose.yml b/10/solr/docker-compose.yml new file mode 100644 index 00000000..dfadda5d --- /dev/null +++ b/10/solr/docker-compose.yml @@ -0,0 +1,77 @@ +# --------------------------------------------------------------------------- +# 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: ../postgres-tomcat/ + container_name: xwiki-postgres-tomcat-web + depends_on: + - db + ports: + - "8080:8080" + # Default values defined in .env file. + # The DB_USER/DB_PASSWORD/DB_DATABASE/DB_HOST variables are used in the hibernate.cfg.xml file. + environment: + - XWIKI_VERSION=${XWIKI_VERSION} + - DB_USER=${DB_USER} + - DB_PASSWORD=${DB_PASSWORD} + - DB_DATABASE=${DB_DATABASE} + - DB_HOST=xwiki-postgres-db + - INDEX_HOST=index + # 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 the database (postgres) + db: + image: "postgres:9.5-alpine" + container_name: xwiki-postgres-db + volumes: + - postgres-data:/var/lib/postgresql/data + environment: + - POSTGRES_ROOT_PASSWORD=${POSTGRES_ROOT_PASSWORD} + - POSTGRES_PASSWORD=${DB_PASSWORD} + - POSTGRES_USER=${DB_USER} + - POSTGRES_DB=${DB_DATABASE} + - POSTGRES_INITDB_ARGS="--encoding=UTF8" + networks: + - bridge + index: + build: . + container_name: xwiki-solr-index + build: + context: . + args: + - SOLR_VERSION=7.5.0 + - XWIKI_VERSION=10.11.8 + volumes: + - solr-data:/opt/solr/server/solr + networks: + - bridge +volumes: + postgres-data: {} + xwiki-data: {} + solr-data: {} diff --git a/10/solr/solr-init.sh b/10/solr/solr-init.sh new file mode 100755 index 00000000..c94bc4bc --- /dev/null +++ b/10/solr/solr-init.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +# Usage: +# - Place the XWiki Solr configuration jar into the same directory as this script +# - 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 +# - ensure that this directory, and it's contents, are owned by the solr user and group, 8983:8983 +# - ex. chown -R 8983:8983 $PARENT_DIRECTORY +# - mount the partent directory of this script to /docker-entrypoint-initdb.d/ when you run the Solr container +# - ex. add the following to docker run command ... -v $PWD/$PARENT_DIRECTORY:/docker-entrypoint-initdb.d ... +# - At run time, before starting Solr, the container will execute scripts in the /docker-entrypoint-initdb.d/ directory. + +cd /docker-entrypoint-initdb.d/ +location='/opt/solr/server/solr/' + +# Verify the existence of a singular XWiki Solr configuration jar +jars=$(find . -type f -name *.jar | wc -l) +if [ $jars -lt 1 ]; then + echo 'No XWiki Solr configuration jar found' + exit 1 +elif [ $jars -gt 1 ]; then + echo 'Too many XWiki Solr configuration jars found, please include only one jar' + exit 1 +fi +# Get the name of the XWiki Solr configuration jar +jar=$(find . -type f -name *.jar) +# Ensure that the Solr directory exists +mkdir -p $location + +# Add the XWiki Solr plugin +plugin=$(unzip -Z1 $jar | grep lib.*jar) +unzip -o $jar \ + $plugin \ + -d $location + +# Add the XWiki core +core='xwiki/*' +unzip -o $jar \ + $core \ + -d $location diff --git a/11/solr/.env b/11/solr/.env new file mode 100644 index 00000000..caa77d7a --- /dev/null +++ b/11/solr/.env @@ -0,0 +1,6 @@ +# Default environment values +XWIKI_VERSION=11.5 +DB_USER=xwiki +DB_PASSWORD=xwiki +DB_DATABASE=xwiki +POSTGRES_ROOT_PASSWORD=xwiki diff --git a/11/solr/Dockerfile b/11/solr/Dockerfile new file mode 100644 index 00000000..98ddb8e8 --- /dev/null +++ b/11/solr/Dockerfile @@ -0,0 +1,20 @@ +# ARG used in FROM must come first +ARG SOLR_VERSION=7.5.0 + +FROM busybox as buildenv + +# ARG for build must come after the FROM statement +ARG XWIKI_VERSION=11.5 +ARG XWIKI_URL_PREFIX="https://maven.xwiki.org/releases/org/xwiki/platform/xwiki-platform-search-solr-server-data/${XWIKI_VERSION}" + +ENV XWIKI_SOLR_SHA256 216c46c11c41a1195cd23f2f568a70acdcdd731f1e179d7f1d4e93c40cacbcb1 + +WORKDIR /var/xwiki-solr-temp/ + +COPY ./solr-init.sh . +RUN wget "${XWIKI_URL_PREFIX}/xwiki-platform-search-solr-server-data-${XWIKI_VERSION}.jar" +RUN echo "$XWIKI_SOLR_SHA256 xwiki-platform-search-solr-server-data-${XWIKI_VERSION}.jar" | sha256sum -c - + +FROM solr:${SOLR_VERSION} + +COPY --from=buildenv /var/xwiki-solr-temp/ /docker-entrypoint-initdb.d/ \ No newline at end of file diff --git a/11/solr/docker-compose.yml b/11/solr/docker-compose.yml new file mode 100644 index 00000000..13e75758 --- /dev/null +++ b/11/solr/docker-compose.yml @@ -0,0 +1,77 @@ +# --------------------------------------------------------------------------- +# 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: ../postgres-tomcat/ + container_name: xwiki-postgres-tomcat-web + depends_on: + - db + ports: + - "8080:8080" + # Default values defined in .env file. + # The DB_USER/DB_PASSWORD/DB_DATABASE/DB_HOST variables are used in the hibernate.cfg.xml file. + environment: + - XWIKI_VERSION=${XWIKI_VERSION} + - DB_USER=${DB_USER} + - DB_PASSWORD=${DB_PASSWORD} + - DB_DATABASE=${DB_DATABASE} + - DB_HOST=xwiki-postgres-db + - INDEX_HOST=index + # 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 the database (postgres) + db: + image: "postgres:9.5-alpine" + container_name: xwiki-postgres-db + volumes: + - postgres-data:/var/lib/postgresql/data + environment: + - POSTGRES_ROOT_PASSWORD=${POSTGRES_ROOT_PASSWORD} + - POSTGRES_PASSWORD=${DB_PASSWORD} + - POSTGRES_USER=${DB_USER} + - POSTGRES_DB=${DB_DATABASE} + - POSTGRES_INITDB_ARGS="--encoding=UTF8" + networks: + - bridge + index: + build: . + container_name: xwiki-solr-index + build: + context: . + args: + - SOLR_VERSION=7.5.0 + - XWIKI_VERSION=11.5 + volumes: + - solr-data:/opt/solr/server/solr + networks: + - bridge +volumes: + postgres-data: {} + xwiki-data: {} + solr-data: {} diff --git a/11/solr/solr-init.sh b/11/solr/solr-init.sh new file mode 100755 index 00000000..c94bc4bc --- /dev/null +++ b/11/solr/solr-init.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +# Usage: +# - Place the XWiki Solr configuration jar into the same directory as this script +# - 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 +# - ensure that this directory, and it's contents, are owned by the solr user and group, 8983:8983 +# - ex. chown -R 8983:8983 $PARENT_DIRECTORY +# - mount the partent directory of this script to /docker-entrypoint-initdb.d/ when you run the Solr container +# - ex. add the following to docker run command ... -v $PWD/$PARENT_DIRECTORY:/docker-entrypoint-initdb.d ... +# - At run time, before starting Solr, the container will execute scripts in the /docker-entrypoint-initdb.d/ directory. + +cd /docker-entrypoint-initdb.d/ +location='/opt/solr/server/solr/' + +# Verify the existence of a singular XWiki Solr configuration jar +jars=$(find . -type f -name *.jar | wc -l) +if [ $jars -lt 1 ]; then + echo 'No XWiki Solr configuration jar found' + exit 1 +elif [ $jars -gt 1 ]; then + echo 'Too many XWiki Solr configuration jars found, please include only one jar' + exit 1 +fi +# Get the name of the XWiki Solr configuration jar +jar=$(find . -type f -name *.jar) +# Ensure that the Solr directory exists +mkdir -p $location + +# Add the XWiki Solr plugin +plugin=$(unzip -Z1 $jar | grep lib.*jar) +unzip -o $jar \ + $plugin \ + -d $location + +# Add the XWiki core +core='xwiki/*' +unzip -o $jar \ + $core \ + -d $location diff --git a/README.md b/README.md index 40819ace..d18272a2 100644 --- a/README.md +++ b/README.md @@ -574,19 +574,31 @@ MySQL: - Create a JIRA issue on the XDOCKER project with subject `Upgrade stable version to `. - Update the version of XWiki in the `build.gradle` file found in the XWiki Docker repository (clone it locally first). -- 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. - - On Linux, use the following one-liner and replace the value of the `VERSION` variable accordingly: - - ```console - VERSION="9.11.8"; 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 - ``` - - - On Mac, use the following one-liner and replace the value of the `VERSION` variable accordingly: - - ```console - VERSION="10.11"; 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 - ``` - +- To know how to generate the sha256 for, 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. + - `Xwiki App sha256`: + - On Linux, use the following one-liner and replace the value of the `VERSION` variable accordingly to get: + + ```console + VERSION="9.11.8"; 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 + ``` + + - On Mac, use the following one-liner and replace the value of the `VERSION` variable accordingly: + + ```console + VERSION="10.11"; 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 + ``` + - `Xwiki Solr sha256` + - On Linux, use the following one-liner and replace the value of the `VERSION` variable accordingly to get: + + ```console + VERSION="11.5"; wget https://maven.xwiki.org/releases/org/xwiki/platform/xwiki-platform-search-solr-server-data/${VERSION}/xwiki-platform-search-solr-server-data-${VERSION}.jar && sha256sum xwiki-platform-search-solr-server-data-${VERSION}.jar && rm xwiki-platform-search-solr-server-data-${VERSION}.jar + ``` + + - On Mac, use the following one-liner and replace the value of the `VERSION` variable accordingly: + + ```console + VERSION="11.5"; wget https://maven.xwiki.org/releases/org/xwiki/platform/xwiki-platform-search-solr-server-data/${VERSION}/xwiki-platform-search-solr-server-data-${VERSION}.jar && shasum --algorithm 256 xwiki-platform-search-solr-server-data-${VERSION}.jar && rm xwiki-platform-search-solr-server-data-${VERSION}.jar + ``` - Execute the Gradle build (run `./gradlew`) to generate the various Dockerfiles and other resources for all image tags - [Test](#testing-docker-container) the docker container - If all is ok commit, push and close the jira issue created above diff --git a/build.gradle b/build.gradle index 86a2b348..51c90377 100644 --- a/build.gradle +++ b/build.gradle @@ -32,15 +32,20 @@ def variants = ['mysql-tomcat', 'postgres-tomcat'] // Note: To compute the sha256, download the XWiki WAR and issue: // - Unix: sha256sum // - Mac: shasum --algorithm 256 +// def tokens = [ '10' : [ xwikiVersion: '10.11.8', - xwikiSha256: 'd3ac801e156966b1e5729a5251aa13662262460edcbf903ec8b5e5d98563bf7e' + xwikiSha256: 'd3ac801e156966b1e5729a5251aa13662262460edcbf903ec8b5e5d98563bf7e', + xwikisolrSha256: '0cce5266f3d9925cf09b041b1b4ea833332a0f6d9e90291e3c719f5866c52c0a', + solrVersion: '7.5.0' ], '11': [ xwikiVersion: '11.5', - xwikiSha256: '4095548065fd32c6d7d90af9ae15e008207b5a144f5823b0bd8520d6a874bf3a' + xwikiSha256: '4095548065fd32c6d7d90af9ae15e008207b5a144f5823b0bd8520d6a874bf3a', + xwikisolrSha256: '216c46c11c41a1195cd23f2f568a70acdcdd731f1e179d7f1d4e93c40cacbcb1', + solrVersion: '7.5.0' ] ] @@ -80,6 +85,28 @@ task generate() { filteringCharset = 'UTF-8' } } + tokens[version].'db' = "postgres" + copy { + from 'template' + into "${version}" + include "solr/Dockerfile" + include "solr/docker-compose.yml" + expand(tokens[version]) + filteringCharset = 'UTF-8' + } + copy { + from 'template' + into "${version}/solr" + include ".env" + expand(tokens[version]) + filteringCharset = 'UTF-8' + } + copy { + from 'template' + into "${version}" + include "solr/solr-init.sh" + filteringCharset = 'UTF-8' + } } } } diff --git a/template/solr/Dockerfile b/template/solr/Dockerfile new file mode 100644 index 00000000..8dfd3a2a --- /dev/null +++ b/template/solr/Dockerfile @@ -0,0 +1,20 @@ +# ARG used in FROM must come first +ARG SOLR_VERSION=$solrVersion + +FROM busybox as buildenv + +# ARG for build must come after the FROM statement +ARG XWIKI_VERSION=$xwikiVersion +ARG XWIKI_URL_PREFIX="https://maven.xwiki.org/releases/org/xwiki/platform/xwiki-platform-search-solr-server-data/\${XWIKI_VERSION}" + +ENV XWIKI_SOLR_SHA256 $xwikisolrSha256 + +WORKDIR /var/xwiki-solr-temp/ + +COPY ./solr-init.sh . +RUN wget "\${XWIKI_URL_PREFIX}/xwiki-platform-search-solr-server-data-\${XWIKI_VERSION}.jar" +RUN echo "\$XWIKI_SOLR_SHA256 xwiki-platform-search-solr-server-data-\${XWIKI_VERSION}.jar" | sha256sum -c - + +FROM solr:\${SOLR_VERSION} + +COPY --from=buildenv /var/xwiki-solr-temp/ /docker-entrypoint-initdb.d/ \ No newline at end of file diff --git a/template/solr/docker-compose.yml b/template/solr/docker-compose.yml new file mode 100644 index 00000000..aa99f96e --- /dev/null +++ b/template/solr/docker-compose.yml @@ -0,0 +1,77 @@ +# --------------------------------------------------------------------------- +# 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: ../postgres-tomcat/ + container_name: xwiki-postgres-tomcat-web + depends_on: + - db + ports: + - "8080:8080" + # Default values defined in .env file. + # The DB_USER/DB_PASSWORD/DB_DATABASE/DB_HOST variables are used in the hibernate.cfg.xml file. + environment: + - XWIKI_VERSION=\${XWIKI_VERSION} + - DB_USER=\${DB_USER} + - DB_PASSWORD=\${DB_PASSWORD} + - DB_DATABASE=\${DB_DATABASE} + - DB_HOST=xwiki-postgres-db + - INDEX_HOST=index + # 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 the database (${db}) + db: + image: "postgres:9.5-alpine" + container_name: xwiki-postgres-db + volumes: + - postgres-data:/var/lib/postgresql/data + environment: + - POSTGRES_ROOT_PASSWORD=\${POSTGRES_ROOT_PASSWORD} + - POSTGRES_PASSWORD=\${DB_PASSWORD} + - POSTGRES_USER=\${DB_USER} + - POSTGRES_DB=\${DB_DATABASE} + - POSTGRES_INITDB_ARGS="--encoding=UTF8" + networks: + - bridge + index: + build: . + container_name: xwiki-solr-index + build: + context: . + args: + - SOLR_VERSION=$solrVersion + - XWIKI_VERSION=$xwikiVersion + volumes: + - solr-data:/opt/solr/server/solr + networks: + - bridge +volumes: + ${db}-data: {} + xwiki-data: {} + solr-data: {} diff --git a/template/solr/solr-init.sh b/template/solr/solr-init.sh new file mode 100755 index 00000000..c94bc4bc --- /dev/null +++ b/template/solr/solr-init.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +# Usage: +# - Place the XWiki Solr configuration jar into the same directory as this script +# - 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 +# - ensure that this directory, and it's contents, are owned by the solr user and group, 8983:8983 +# - ex. chown -R 8983:8983 $PARENT_DIRECTORY +# - mount the partent directory of this script to /docker-entrypoint-initdb.d/ when you run the Solr container +# - ex. add the following to docker run command ... -v $PWD/$PARENT_DIRECTORY:/docker-entrypoint-initdb.d ... +# - At run time, before starting Solr, the container will execute scripts in the /docker-entrypoint-initdb.d/ directory. + +cd /docker-entrypoint-initdb.d/ +location='/opt/solr/server/solr/' + +# Verify the existence of a singular XWiki Solr configuration jar +jars=$(find . -type f -name *.jar | wc -l) +if [ $jars -lt 1 ]; then + echo 'No XWiki Solr configuration jar found' + exit 1 +elif [ $jars -gt 1 ]; then + echo 'Too many XWiki Solr configuration jars found, please include only one jar' + exit 1 +fi +# Get the name of the XWiki Solr configuration jar +jar=$(find . -type f -name *.jar) +# Ensure that the Solr directory exists +mkdir -p $location + +# Add the XWiki Solr plugin +plugin=$(unzip -Z1 $jar | grep lib.*jar) +unzip -o $jar \ + $plugin \ + -d $location + +# Add the XWiki core +core='xwiki/*' +unzip -o $jar \ + $core \ + -d $location