Hi Rob, 

Glad you got it up and running :)

Am 27.11.2021 um 16:39 schrieb Rob Stapper <r.stapper@lijbrandt.nl>:

Hi Michael,
 
Thanx for the extended answer. Eventually I got it working with my web application and xquey-modules as part of the image. I had a little trouble with the ownerships of the mounted datafiles but ‘chown’ under the ‘root’ solved that one.
Yeah, I think the obvious solution to this would be running the entire image as root — which may or may not impose a security issue in your architecture.

I find the image size a pretty big: 400Mb against the 227 Mb of the regular ‘basex/basexhttp’-image.
Yeah I think you could boil this down to a few megabytes (using the alpine variant) — but I moved to arm (thanks Apple M1) recently there is no OpenJDK / Alpine Image yet, hence the size.

On the other hand the performance is much better then a basexhttp-container with my code mounted on container-creation. I’m content for now, I’ll grab a beer.
Just a guess, but maybe that performance plus stems from the use of different JDKs? 
My example contains JDK 11 — the official BaseX Docker is running  JDK 8. I think we might consider updating our official image. 



Best
Michael 
 
Cheers,
Rob
 
Sent from Mail for Windows
 
From: Michael Seiferle
Sent: Friday, November 26, 2021 6:04 PM
To: Rob Stapper
Cc: basex-talk@mailman.uni-konstanz.de
Subject: Re: [basex-talk] docker, creating and deploying the dba docker-image
 
Hi Rob, 
 
this answer contains two parts, but tldr: if you mount nothing to /srv/basex/webapp the DBA should already be present.
 
Now the slightly longer part:
 
But I’m confused what directories to mount on: ‘/srv/basex/repo’ and ‘/srv/basex/webapp’? 
I can’t find the docker-run example for this.
 
Can you shine some more light on the issue.
 
 
Inside the docker image, the home-folder is /srv/basex, hence:
 
The /srv/basex/repo Folder contains all XQuery modules that can be imported from your query files, using the BaseX module resolution.
 
From the documentation: 
            Points to the Repository, in which all XQuery modules are located.
 
The webapp folder on the other hand contains your RestXQ-annotated-XQuery  files, and is configured via the WEBPATH property:
 
WEBPATH
Signature         WEBPATH [path]
Default             {home}/webapp
Summary         Points to the directory in which all the Web Application contents are stored, including XQuery, Script, RESTXQ and configuration files
 
 
As the docker container is (more or less) the ZIP-File extracted to a specific location, it behaves very much like starting basexhttp from the commandline.
 
When you download the BaseX Zipfile, you run:
 bin/basexhttp 
Which in turn runs: java -cp ${all-basex-libraries-and-jarfiles}  org.basex.BaseXHTTP
 
The BaseXHTTP-process now looks for the given folders in the current home directory: 
 
- `data` => for databases
- `repo` => for XQuery modules
- `webapp` => for web applications
 

When it comes to docker, the home directory is /srv/basex, with the following layout:
 
/srv/basex/data => for databases
/srv/basex/repo => for XQuery modules
/srv/basex/webapp => for RestXQ-annotated stuff such as the dba
 
 
As the ZIP-File contains the DBA, all needed files should be already present, if you did not mount something else into /srv/basex/webapp.
 
If you want to add your own RestXQ endpoints for example, the safe way is to mount them into a subfolder of /srv/basex/webapp, for example: 
 
docker run -d \
    --name basexhttp \
    --publish 1984:1984 \
    --publish 8984:8984 \
    --volume "$HOME/basex/data":/srv/basex/data \
    --volume "$(pwd)/webapp/myapp":/srv/basex/webapp/myapp \
  basex/basexhttp:latest
 
That way the webapp folder in the docker container keeps the DBA and also has your files present.
 
 
If you plan to distribute your image I’d suggest building your own image with a Dockerfile. 
I created a minimal example here: https://git.basex.io/basex-org/basex-app-with-docker 
All I’ve done is: download BaseX.zip, extract BaseX.zip, add a Dockerfile to build the image.
 
 
 
Hope this helps  :-)
 
 
 
Michael
 
 


Am 26.11.2021 um 14:50 schrieb Rob Stapper <r.stapper@lijbrandt.nl>:
 
I’ve mounted ‘c:/Program Files (x86)/basex/data’ on ‘/srv/basex/data’ 
 
 
 
 

Virus-free. www.avast.com