Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XDOCKER-87: Automatically build SOLR docker image with compose #22

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions 10/solr/.env
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions 10/solr/Dockerfile
Original file line number Diff line number Diff line change
@@ -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/
77 changes: 77 additions & 0 deletions 10/solr/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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: {}
39 changes: 39 additions & 0 deletions 10/solr/solr-init.sh
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions 11/solr/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Default environment values
XWIKI_VERSION=11.5
DB_USER=xwiki
DB_PASSWORD=xwiki
DB_DATABASE=xwiki
POSTGRES_ROOT_PASSWORD=xwiki
20 changes: 20 additions & 0 deletions 11/solr/Dockerfile
Original file line number Diff line number Diff line change
@@ -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/
77 changes: 77 additions & 0 deletions 11/solr/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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: {}
39 changes: 39 additions & 0 deletions 11/solr/solr-init.sh
Original file line number Diff line number Diff line change
@@ -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
38 changes: 25 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -574,19 +574,31 @@ MySQL:

- Create a JIRA issue on the XDOCKER project with subject `Upgrade stable version to <version>`.
- 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
Expand Down
31 changes: 29 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,20 @@ def variants = ['mysql-tomcat', 'postgres-tomcat']
// Note: To compute the sha256, download the XWiki WAR and issue:
// - Unix: sha256sum <binary name>
// - Mac: shasum --algorithm 256 <binary name>
//

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'
]
]

Expand Down Expand Up @@ -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'
}
}
}
}
Loading