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/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: