项目作者: duncdrum

项目描述 :
experimental docker exist-db repo
高级语言: Shell
项目地址: git://github.com/duncdrum/exist-docker.git
创建时间: 2018-05-08T22:11:24Z
项目社区:https://github.com/duncdrum/exist-docker

开源协议:GNU Affero General Public License v3.0

下载


docker-eXist (WIP)

!! Development has stalled, and moved to eXist-db/docker-existdb !!

minimal exist-db docker image with FO support

Build Status
Codacy Badge


This repository holds the source files for building a minimal docker image of the exist-db xml database, automatically building from eXist’s source code repo. It uses Google Cloud Platforms “Distroless” Docker Images.

Requirements

How to use

Pre-build images are available on DockerHub. There are two channels:

  • stable for the latest stable releases (coming soon™)
  • latest for last commit to the development branch.

To download the image run:

  1. docker pull duncdrum/exist-docker:latest
  2. docker run -it -d -p 8080:8080 -p 8443:8443 duncdrum/exist-docker:latest

You can now access eXist via localhost:8080 in your browser.
Try to stick with matching internal and external port assignments, to avoid unnecessary reloads and connection issues.

To stop the container issue:

  1. docker stop exist

or if you omitted the -d flag earlier press CTRL-C inside the terminal showing the exist logs.

Interacting with the running container

Containers build from this image run a periodical healtheck to make sure that eXist is operating normally. If docker ps reports unhealthy you can see a more detailed report (where exist is the name of the container)

  1. docker inspect --format='{{json .State.Health}}' exist

Logging

There is a slight modification to eXist’s logger to ease access to the logs via:

  1. docker logs exist

This works best when providing the -t flag when running an image.

Development use via docker-compose

Use of docker compose for local development or integration into a multi-container environment is strongly recommended.

  1. # starting eXist
  2. docker-compose up -d
  3. # stop eXist
  4. docker-compose down

Docker compose defines a data volume for eXist named exist-data so that changes to the container’s apps persist through reboots. You can inspect the volume via:

  1. docker volume inspect exist-data

You can configure additional volumes e.g. for backups, or additional services such as an nginx reverse proxy by modifying the docker-compose.yml, to suite your needs.

To update the exist-docker image from a newer version

  1. docker-compose pull

Caveat

As with normal installations, the password for the default dba user admin is empty. Change it via the usermanager or set the password to e.g. 123 from docker CLI:

  1. docker exec exist java -jar start.jar client -q -u admin -P '' -x 'sm:passwd("admin", "123")'

Note: 123 is not a good password.

Building the Image

To build the docker image run:

  1. docker build .

This will build an eXist image with sensible defaults as specified in the Dockerfile. The image uses a multi-stage building approach, so you can customize the compilation of eXist, or the final image.

To interact with the compilation of eXist you can either modify the build.sh file directly, or if you prefer to work via docker stop the build process after the builder stage, via

  1. docker build --target builder .
  2. # Do your thing…
  3. docker commit

Available Arguments and Defaults

eXist’s cache size and maximum brokers can be configured at built time using the following syntax.

  1. docker build --build-arg MAX_CACHE=312 MAX_BROKER=15 .

NOTE: Due to the fact that the final images does not provide a shell setting ENV variables for eXist has no effect.

  1. # !This has no effect!
  2. docker run -it -d -p8080:8080 -e MAX_BROKER=10 ae4d6d653d30

The preferred method to change your images to a customized cache or broker configuration is to edit the default values inside the Dockerfile used for building your images.

  1. ARG MAX_BROKER=10

Alternatively you can edit, the configuration files in the /src folder to customize the eXist instance. Make your customizations and uncomment the following lines in the Dockerfile.

  1. # Add customized configuration files
  2. # ADD ./src/conf.xml .
  3. # ADD ./src/log4j2.xml .
  4. # ADD ./src/mime-types.xml .

These files only serve as a template. While upstream updates from eXist to them are rare, such upstream changes will be immediately mirrored here. Users are responsible to ensure that local changes in their forks / clones persist when syncing with this repo, e.g. by rebasing their own changes after pulling from upstream.

JVM configuration

This image uses advanced JVM configuration to set set the heap-size. Avoid passing -Xmx arguments to eXist’s JVM to set maximum memory. This will lead to frequent crashes since java and Docker are not on the same page concerning available memory. Instead, use -XX:MaxRAMFraction=1 to modify the memory available to the JVM. For production use it is recommended to increase the value to 2 or even 4. The values express ratios, so setting it to 2 means half the container’s memory will be available to the JVM, ‘4’ means ¼, etc.

To allocate e.g. 600mb to the container around the JVM use:

  1. docker run -m 600m

Lastly, this images uses a new garbage collection mechanism “garbage first (G1)” -XX:+UseG1GC and enables string deduplication -XX:+UseStringDeduplication to improve performance. To disable or further tweak these features edit the JAVA_TOOL_OPTIONS env variable inside the Dockerfile or when running the image. As always when using the latest and greatest, YMMV. Feedback about real world experiences with this features in connection with eXist is very much welcome.

Interacting with image via CLI

You can now interact with a running container as if it were a regular linux host, the name of the container in these examples is exist:

  1. # Copy my-data.xml from running eXist to local folder
  2. docker cp exist:/exist-data/apps/my-app/data/my-data.xml ./my-folder
  3. # Using java syntax on a running eXist instances
  4. docker exec exist java -jar start.jar client --no-gui --xpath "system:get-memory-max()"
  5. # Interacting with the JVM
  6. docker exec exist java -version