Ship export plugin by default; rename profiles to open/auth
Integrate kalamar-plugin-export into the default setup for both the
open (anonymous) and auth (authenticated) profiles, replacing the
previous lite/full naming which didn't communicate the actual
distinction. Switch documentation from --profile flags to the
COMPOSE_PROFILES environment variable for consistency.
Make export default for lite mode
Change-Id: I80f5c8243961c44a0f3651e38889dac39ffa2eb1
diff --git a/Readme.md b/Readme.md
index 926f0d5..3150c83 100644
--- a/Readme.md
+++ b/Readme.md
@@ -28,26 +28,26 @@
For testing, there is a test index available as a docker image. Just run
```shell
-INDEX='example-index' docker compose -p korap --profile=lite --profile=example up
+COMPOSE_PROFILES="open,example" INDEX='example-index' docker compose -p korap up
```
to start the example image and the service with Linux
(See [here](#Windows) for more information on Windows).
-To include the export plugin, add the export profile:
+To run without the export plugin, set `KALAMAR_EXPORT=false` or omit `export` from `COMPOSE_PROFILES`:
```shell
-COMPOSE_PROFILES="export" INDEX='example-index' docker compose -p korap --profile=lite --profile=example --profile=export up
+COMPOSE_PROFILES="open,example" KALAMAR_EXPORT=false INDEX='example-index' docker compose -p korap up
```
-Otherwise it's possible to download the sample index provided by
+It's also possible to download the sample index provided by
[Kustvakt](https://github.com/KorAP/Kustvakt/tree/master/sample-index).
To download, intialize and run KorAP pointing to that index folder
(in this example stored in the `index` folder in the local directory),
run
```shell
-INDEX=./index docker compose -p korap --profile=lite up
+COMPOSE_PROFILES="open" INDEX=./index docker compose -p korap up
```
This will make the frontend be available at
@@ -60,7 +60,7 @@
`data` in your working directory and then start it with
```shell
-INDEX=./index docker compose -p korap --profile=full up
+COMPOSE_PROFILES="auth" INDEX=./index docker compose -p korap up
```
Login with `user1` and `password1`. To change authentication settings, see the `/kusvakt/ldap` folder inside the docker container and Kustvakt's [LDAP Settings Wiki](https://github.com/KorAP/Kustvakt/wiki/LDAP-Setting) for documentation.
@@ -155,11 +155,11 @@
## Windows
Windows with Powershell requires environment variables to pass in a different way.
-In addition the `PWD` variable is not set beforehand. To run, e.g., the KorAP one-liner
+In addition the `PWD` variable is not set beforehand. To run the KorAP one-liner
with Windows, you have to start
```powershell
-$env:INDEX='example-index'; $env:PWD='.'; docker compose -p korap --profile=lite --profile=example up
+$env:INDEX='example-index'; $env:PWD='.'; $env:COMPOSE_PROFILES='open,example'; docker compose -p korap up
```
diff --git a/compose.yaml b/compose.yaml
index 21eb37b..57b31f3 100644
--- a/compose.yaml
+++ b/compose.yaml
@@ -1,3 +1,26 @@
+x-kalamar-export-setup: &export-setup
+ entrypoint: []
+ command: >
+ sh -c '
+ if [ "$$KALAMAR_EXPORT" != "false" ]; then
+ echo "Hacking in selective CSP policy...";
+ if ! grep -q "script-src.*unsafe-inline" /kalamar/kalamar.production.conf; then
+ cat /kalamar/kalamar.production.conf | perl -pe "s/\\{/\\{CSP=>{q!frame-src!=>[q!self!]},/" > /kalamar/kalamar.production.tmp.conf;
+ mv /kalamar/kalamar.production.tmp.conf /kalamar/kalamar.production.conf;
+ fi;
+ # Should better be retrieved by the export plugin service using curl
+ PLUGINJSON="{ name => \"Export\", desc => \"Exports Kalamar results\", embed => [{ panel => \"result\", title => \"exports KWICs and snippets\" , icon => \"\134x{f019}\", classes => [\"button-icon\",\"plugin\"], onClick => { action => \"addWidget\", template => \"/plugin/export/export\", permissions => [\"forms\",\"scripts\", \"downloads\" ]}}]},";
+ PLUGINPROXY="{ root_path => \"/plugin/export/\", mount => \"http://kalamar-export:7777/\", service => \"export-plugin-proxy\" },";
+ if ! grep -F -q "/plugin/export/export" /kalamar/kalamar.production.conf; then
+ cat /kalamar/kalamar.production.conf | perl -pe "s!\047PLUGIN_STUB\047!$$PLUGINJSON\047PLUGIN_STUB\047!;" > /kalamar/kalamar.production.tmp.conf;
+ mv /kalamar/kalamar.production.tmp.conf /kalamar/kalamar.production.conf
+ fi;
+ if ! grep -F -q "export-plugin-proxy" /kalamar/kalamar.production.conf; then
+ cat /kalamar/kalamar.production.conf | perl -pe "s!\047PROXY_STUB\047!$$PLUGINPROXY\047PROXY_STUB\047!;" > /kalamar/kalamar.production.tmp.conf;
+ mv /kalamar/kalamar.production.tmp.conf /kalamar/kalamar.production.conf
+ fi;
+ cat /kalamar/kalamar.production.conf;
+ fi || true; perl script/kalamar daemon -l http://0.0.0.0:64543'
volumes:
example-index:
services:
@@ -14,35 +37,14 @@
- "64543:64543"
environment:
KALAMAR_API: "http://kustvakt:8089/api/"
- COMPOSE_PROFILES: ${COMPOSE_PROFILES}
+ KALAMAR_EXPORT: ${KALAMAR_EXPORT:-true}
depends_on:
- kustvakt
profiles:
- - lite
- entrypoint: []
- command: >
- sh -c '
- if echo "$$COMPOSE_PROFILES" | grep -q "export"; then
- echo "Hacking in selective CSP policy...";
- if ! grep -q "script-src.*unsafe-inline" /kalamar/kalamar.production.conf; then
- cat /kalamar/kalamar.production.conf | perl -pe "s/\\{/\\{CSP=>{q!frame-src!=>[q!self!]},/" > /kalamar/kalamar.production.tmp.conf;
- mv /kalamar/kalamar.production.tmp.conf /kalamar/kalamar.production.conf;
- fi;
- # Should better be retrieved by the export plugin service using curl
- PLUGINJSON="{ name => \"Export\", desc => \"Exports Kalamar results\", embed => [{ panel => \"result\", title => \"exports KWICs and snippets\" , icon => \"\134x{f019}\", classes => [\"button-icon\",\"plugin\"], onClick => { action => \"addWidget\", template => \"/plugin/export/export\", permissions => [\"forms\",\"scripts\", \"downloads\" ]}}]},";
- PLUGINPROXY="{ root_path => \"/plugin/export/\", mount => \"http://kalamar-export:7777/\", service => \"export-plugin-proxy\" },";
- if ! grep -F -q "/plugin/export/export" /kalamar/kalamar.production.conf; then
- cat /kalamar/kalamar.production.conf | perl -pe "s!\047PLUGIN_STUB\047!$$PLUGINJSON\047PLUGIN_STUB\047!;" > /kalamar/kalamar.production.tmp.conf;
- mv /kalamar/kalamar.production.tmp.conf /kalamar/kalamar.production.conf
- fi;
- if ! grep -F -q "export-plugin-proxy" /kalamar/kalamar.production.conf; then
- cat /kalamar/kalamar.production.conf | perl -pe "s!\047PROXY_STUB\047!$$PLUGINPROXY\047PROXY_STUB\047!;" > /kalamar/kalamar.production.tmp.conf;
- mv /kalamar/kalamar.production.tmp.conf /kalamar/kalamar.production.conf
- fi;
- cat /kalamar/kalamar.production.conf;
- fi || true; perl script/kalamar daemon -l http://0.0.0.0:64543'
+ - open
+ <<: *export-setup
restart: "unless-stopped"
- full-init:
+ auth-init:
image: "korap/kalamar:latest"
command: super_client_info kalamar /kalamar/data/super_client_info
volumes:
@@ -50,33 +52,35 @@
source: "${PWD}/data/"
target: "/kalamar/data"
profiles:
- - full
+ - auth
- init
user: root
restart: "no"
- kalamar-full:
+ kalamar-auth:
image: "korap/kalamar:latest"
ports:
- "64543:64543"
environment:
- KALAMAR_API: "http://kustvakt-full:8089/api/"
+ KALAMAR_API: "http://kustvakt-auth:8089/api/"
KALAMAR_PLUGINS: "Auth"
KALAMAR_CLIENT_FILE: "/kalamar/super_client_info"
+ KALAMAR_EXPORT: ${KALAMAR_EXPORT:-true}
volumes:
- ${PWD}/data/super_client_info:/kalamar/super_client_info:z
depends_on:
- kustvakt-full:
+ kustvakt-auth:
condition: service_started
- full-init:
+ auth-init:
condition: service_completed_successfully
profiles:
- - full
+ - auth
+ <<: *export-setup
restart: "unless-stopped"
user: root
kalamar-export:
image: "korap/kalamar-plugin-export:0.4.1"
environment:
- KALAMAR_EXPORT_API_HOST: "kustvakt"
+ KALAMAR_EXPORT_API_HOST: "kustvakt-api"
KALAMAR_EXPORT_API_PORT: "8089"
KALAMAR_EXPORT_API_SCHEME: "http"
KALAMAR_EXPORT_ASSET_HOST: "localhost"
@@ -86,6 +90,8 @@
KALAMAR_EXPORT_SERVER_HOST: "0.0.0.0"
KALAMAR_EXPORT_SERVER_PORT: "7777"
profiles:
+ - open
+ - auth
- export
restart: "unless-stopped"
kustvakt:
@@ -95,9 +101,13 @@
volumes:
- "${INDEX}:/kustvakt/index:z"
profiles:
- - lite
+ - open
+ networks:
+ default:
+ aliases:
+ - kustvakt-api
restart: "unless-stopped"
- kustvakt-full:
+ kustvakt-auth:
image: "korap/kustvakt:latest-full"
expose:
- 8089
@@ -108,10 +118,14 @@
source: "${PWD}/data/"
target: /kustvakt/data/
profiles:
- - full
+ - auth
depends_on:
- full-init:
+ auth-init:
condition: service_completed_successfully
+ networks:
+ default:
+ aliases:
+ - kustvakt-api
restart: "unless-stopped"
configs:
super_client_info: