Add a resolver
This commit adds a resolver to the toplevel Distillery domain, to allow resolving domains globally.
This commit is contained in:
parent
eee3d95351
commit
45ee6b665e
11 changed files with 129 additions and 7 deletions
10
README.md
10
README.md
|
|
@ -337,6 +337,16 @@ ssh -p 2222 -L localhost:7200:triplestore:7200 -L localhost:8080:phpmyadmin:8080
|
||||||
|
|
||||||
This will make GraphDB and PhpMyAdmin available at `localhost:7200` and `localhost:8080` for the duration of the connection.
|
This will make GraphDB and PhpMyAdmin available at `localhost:7200` and `localhost:8080` for the duration of the connection.
|
||||||
|
|
||||||
|
### Resolver
|
||||||
|
|
||||||
|
In order to resolve WissKI URIs globally, we make use of [wdresolve](https://github.com/FAU-CDI/wdresolve).
|
||||||
|
This can be queried with a single URI, and will be redirected to the page of the corresponding WissKI Entity.
|
||||||
|
This is deployed under `/go/` path of the top-level domain.
|
||||||
|
|
||||||
|
For example, if the domain name of the distillery instance is `wisski.example.com`, then the resolver would respond to queries like `https://wisski.example.com/go/?uri=https://first.wisski.example.com/content/123`.
|
||||||
|
The resolver configuration is automatically updated by the `update_prefix_config.sh` script.
|
||||||
|
It should not be neccessary to reload this configuration manually, as it is automatically called during `system_update.sh`.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
This project and associated files in this repository are licensed as follows:
|
This project and associated files in this repository are licensed as follows:
|
||||||
|
|
|
||||||
|
|
@ -247,6 +247,8 @@ GRAPHDB_AUTH_FLAGS="--user $(printf "admin:%s" "$GRAPHDB_ADMIN_PASSWORD")"
|
||||||
# paths to composer things
|
# paths to composer things
|
||||||
DEPLOY_WEB_DIR="$DEPLOY_ROOT/core/web"
|
DEPLOY_WEB_DIR="$DEPLOY_ROOT/core/web"
|
||||||
DEPLOY_SELF_DIR="$DEPLOY_ROOT/core/self"
|
DEPLOY_SELF_DIR="$DEPLOY_ROOT/core/self"
|
||||||
|
DEPLOY_RESOLVER_DIR="$DEPLOY_ROOT/core/resolver"
|
||||||
|
DEPLOY_PREFIX_CONFIG="$DEPLOY_RESOLVER_DIR/prefix.cfg"
|
||||||
DEPLOY_TRIPLESTORE_DIR="$DEPLOY_ROOT/core/triplestore"
|
DEPLOY_TRIPLESTORE_DIR="$DEPLOY_ROOT/core/triplestore"
|
||||||
DEPLOY_SQL_DIR="$DEPLOY_ROOT/core/sql"
|
DEPLOY_SQL_DIR="$DEPLOY_ROOT/core/sql"
|
||||||
DEPLOY_SSH_DIR="$DEPLOY_ROOT/core/ssh"
|
DEPLOY_SSH_DIR="$DEPLOY_ROOT/core/ssh"
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,12 @@ SLUG="$1"
|
||||||
|
|
||||||
# Compute the domain name for this instance.
|
# Compute the domain name for this instance.
|
||||||
# Also lowercase the domain name for consistency.
|
# Also lowercase the domain name for consistency.
|
||||||
INSTANCE_DOMAIN="$SLUG.$DEFAULT_DOMAIN"
|
function compute_instance_domain() {
|
||||||
INSTANCE_DOMAIN="$(echo "$INSTANCE_DOMAIN" | tr '[:upper:]' '[:lower:]')"
|
INSTANCE_DOMAIN="$1.$DEFAULT_DOMAIN"
|
||||||
|
INSTANCE_DOMAIN="$(echo "$INSTANCE_DOMAIN" | tr '[:upper:]' '[:lower:]')"
|
||||||
|
echo "$INSTANCE_DOMAIN"
|
||||||
|
}
|
||||||
|
INSTANCE_DOMAIN="$(compute_instance_domain "$SLUG")"
|
||||||
|
|
||||||
# Next we need a username base.
|
# Next we need a username base.
|
||||||
# This will be used as a username across the system (linux), MySQL and GraphDB.
|
# This will be used as a username across the system (linux), MySQL and GraphDB.
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This script will list all the URIs that this system is aware of.
|
||||||
|
* This works by listing all the default graph uris of all the adapters.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// iterate over all adapters
|
||||||
|
$storage = \Drupal::entityTypeManager()->getStorage('wisski_salz_adapter');
|
||||||
|
foreach ($storage->loadMultiple() as $adapter) {
|
||||||
|
// read the configuration, and check if we have a default graph
|
||||||
|
$conf = $adapter->getEngine()->getConfiguration();
|
||||||
|
if(!array_key_exists('default_graph', $conf)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// and echo it out
|
||||||
|
echo $conf['default_graph'] . "\n";
|
||||||
|
}
|
||||||
29
distillery/resources/compose/resolver/docker-compose.yml
Normal file
29
distillery/resources/compose/resolver/docker-compose.yml
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
version: "3.7"
|
||||||
|
|
||||||
|
services:
|
||||||
|
wdresolve:
|
||||||
|
image: ghcr.io/fau-cdi/wdresolve:latest
|
||||||
|
restart: always
|
||||||
|
volumes:
|
||||||
|
- "${PREFIX_FILE}:/prefixes.cfg:ro"
|
||||||
|
environment:
|
||||||
|
# port and hostname for this image to use
|
||||||
|
VIRTUAL_HOST: ${VIRTUAL_HOST}
|
||||||
|
VIRTUAL_PORT: 8080
|
||||||
|
VIRTUAL_PATH: /go/
|
||||||
|
|
||||||
|
# optional letsencrypt email
|
||||||
|
LETSENCRYPT_HOST: ${LETSENCRYPT_HOST}
|
||||||
|
LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL}
|
||||||
|
|
||||||
|
# default and legacy domain
|
||||||
|
DEFAULT_DOMAIN: ${DEFAULT_DOMAIN}
|
||||||
|
LEGACY_DOMAIN: ${LEGACY_DOMAIN}
|
||||||
|
|
||||||
|
# the prefix file
|
||||||
|
PREFIX_FILE: /prefixes.cfg
|
||||||
|
|
||||||
|
networks:
|
||||||
|
default:
|
||||||
|
external:
|
||||||
|
name: distillery
|
||||||
|
|
@ -10,6 +10,7 @@ services:
|
||||||
# port and hostname for this image to use
|
# port and hostname for this image to use
|
||||||
VIRTUAL_HOST: ${VIRTUAL_HOST}
|
VIRTUAL_HOST: ${VIRTUAL_HOST}
|
||||||
VIRTUAL_PORT: 8080
|
VIRTUAL_PORT: 8080
|
||||||
|
VIRTUAL_PATH: /
|
||||||
|
|
||||||
# optional letsencrypt email
|
# optional letsencrypt email
|
||||||
LETSENCRYPT_HOST: ${LETSENCRYPT_HOST}
|
LETSENCRYPT_HOST: ${LETSENCRYPT_HOST}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ version: "3.7"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
nginx-proxy:
|
nginx-proxy:
|
||||||
image: nginxproxy/nginx-proxy:alpine
|
image: ghcr.io/nginx-proxy/nginx-proxy:alpine
|
||||||
environment:
|
environment:
|
||||||
- DEFAULT_HOST=${DEFAULT_HOST}
|
- DEFAULT_HOST=${DEFAULT_HOST}
|
||||||
ports:
|
ports:
|
||||||
|
|
@ -23,7 +23,7 @@ services:
|
||||||
- default
|
- default
|
||||||
|
|
||||||
letsencrypt-nginx-proxy-companion:
|
letsencrypt-nginx-proxy-companion:
|
||||||
image: jrcs/letsencrypt-nginx-proxy-companion
|
image: docker.io/nginxproxy/acme-companion:latest
|
||||||
volumes:
|
volumes:
|
||||||
- "/var/run/docker.sock:/var/run/docker.sock:ro"
|
- "/var/run/docker.sock:/var/run/docker.sock:ro"
|
||||||
- "htpasswd:/etc/nginx/htpasswd"
|
- "htpasswd:/etc/nginx/htpasswd"
|
||||||
|
|
|
||||||
9
distillery/resources/templates/docker-env/resolver
Normal file
9
distillery/resources/templates/docker-env/resolver
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
VIRTUAL_HOST=${VIRTUAL_HOST}
|
||||||
|
|
||||||
|
PREFIX_FILE=${PREFIX_FILE}
|
||||||
|
|
||||||
|
DEFAULT_DOMAIN=${DEFAULT_DOMAIN}
|
||||||
|
LEGACY_DOMAIN=${LEGACY_DOMAIN}
|
||||||
|
|
||||||
|
LETSENCRYPT_HOST=${LETSENCRYPT_HOST}
|
||||||
|
LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL}
|
||||||
|
|
@ -45,10 +45,11 @@ apt-get install -y python3-pip libffi-dev
|
||||||
log_info "=> Installing docker-compose"
|
log_info "=> Installing docker-compose"
|
||||||
pip3 install --upgrade docker-compose
|
pip3 install --upgrade docker-compose
|
||||||
|
|
||||||
log_info "=> Creating docker-compose directories"
|
log_info "=> Creating docker-compose directories and files"
|
||||||
mkdir -p "$DEPLOY_INSTANCES_DIR"
|
mkdir -p "$DEPLOY_INSTANCES_DIR"
|
||||||
mkdir -p "$DEPLOY_WEB_DIR"
|
mkdir -p "$DEPLOY_WEB_DIR"
|
||||||
mkdir -p "$DEPLOY_SELF_DIR"
|
mkdir -p "$DEPLOY_SELF_DIR"
|
||||||
|
mkdir -p "$DEPLOY_RESOLVER_DIR"
|
||||||
mkdir -p "$DEPLOY_SSH_DIR"
|
mkdir -p "$DEPLOY_SSH_DIR"
|
||||||
mkdir -p "$DEPLOY_TRIPLESTORE_DIR"
|
mkdir -p "$DEPLOY_TRIPLESTORE_DIR"
|
||||||
mkdir -p "$DEPLOY_SQL_DIR"
|
mkdir -p "$DEPLOY_SQL_DIR"
|
||||||
|
|
@ -69,6 +70,10 @@ load_template "docker-env/web" \
|
||||||
log_info "=> Creating 'docker-compose' files for the 'self'. "
|
log_info "=> Creating 'docker-compose' files for the 'self'. "
|
||||||
install_resource_dir "compose/self" "$DEPLOY_SELF_DIR"
|
install_resource_dir "compose/self" "$DEPLOY_SELF_DIR"
|
||||||
|
|
||||||
|
log_info "=> Creating 'docker-compose' files for the 'resolver'. "
|
||||||
|
install_resource_dir "compose/resolver" "$DEPLOY_RESOLVER_DIR"
|
||||||
|
touch "$DEPLOY_PREFIX_CONFIG"
|
||||||
|
|
||||||
log_info "=> Creating 'docker-compose' files for the 'ssh'. "
|
log_info "=> Creating 'docker-compose' files for the 'ssh'. "
|
||||||
install_resource_dir "compose/ssh" "$DEPLOY_SSH_DIR"
|
install_resource_dir "compose/ssh" "$DEPLOY_SSH_DIR"
|
||||||
|
|
||||||
|
|
@ -86,6 +91,15 @@ load_template "docker-env/self" \
|
||||||
"OVERRIDES_FILE" "${SELF_OVERRIDES_FILE}" \
|
"OVERRIDES_FILE" "${SELF_OVERRIDES_FILE}" \
|
||||||
> "$DEPLOY_SELF_DIR/.env"
|
> "$DEPLOY_SELF_DIR/.env"
|
||||||
|
|
||||||
|
log_info " => Writing 'resolver' configuration file"
|
||||||
|
load_template "docker-env/resolver" \
|
||||||
|
"VIRTUAL_HOST" "${SELF_DOMAIN_SPEC}" \
|
||||||
|
"LETSENCRYPT_HOST" "${LETSENCRYPT_HOST}" \
|
||||||
|
"LETSENCRYPT_EMAIL" "${LETSENCRYPT_EMAIL}" \
|
||||||
|
"PREFIX_FILE" "${DEPLOY_PREFIX_CONFIG}" \
|
||||||
|
"DEFAULT_DOMAIN" "${DEFAULT_DOMAIN}" \
|
||||||
|
"LEGACY_DOMAIN" "${SELF_EXTRA_DOMAINS}" \
|
||||||
|
> "$DEPLOY_RESOLVER_DIR/.env"
|
||||||
|
|
||||||
# copy over the directory
|
# copy over the directory
|
||||||
log_info "=> Creating 'docker-compose' files for the 'triplestore'. "
|
log_info "=> Creating 'docker-compose' files for the 'triplestore'. "
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,9 @@ update_stack "$DEPLOY_WEB_DIR"
|
||||||
log_info "=> Rebuilding and restarting 'self' stack"
|
log_info "=> Rebuilding and restarting 'self' stack"
|
||||||
update_stack "$DEPLOY_SELF_DIR"
|
update_stack "$DEPLOY_SELF_DIR"
|
||||||
|
|
||||||
|
log_info "=> Rebuilding and restarting 'resolver' stack"
|
||||||
|
update_stack "$DEPLOY_RESOLVER_DIR"
|
||||||
|
|
||||||
# build and start the ssh server
|
# build and start the ssh server
|
||||||
log_info "=> Rebuilding and restarting 'ssh' stack"
|
log_info "=> Rebuilding and restarting 'ssh' stack"
|
||||||
update_stack "$DEPLOY_SSH_DIR"
|
update_stack "$DEPLOY_SSH_DIR"
|
||||||
|
|
@ -24,7 +27,7 @@ update_stack "$DEPLOY_TRIPLESTORE_DIR"
|
||||||
log_info "=> Rebuilding and restarting 'sql' stack"
|
log_info "=> Rebuilding and restarting 'sql' stack"
|
||||||
update_stack "$DEPLOY_SQL_DIR"
|
update_stack "$DEPLOY_SQL_DIR"
|
||||||
|
|
||||||
# TODO: Iterate over all the instance
|
log_info " => Updating Prefix Config"
|
||||||
# and a pull_and_update
|
bash update_prefix_config.sh
|
||||||
|
|
||||||
log_info "=> System up-to-date. "
|
log_info "=> System up-to-date. "
|
||||||
31
distillery/update_prefix_config.sh
Normal file
31
distillery/update_prefix_config.sh
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# read the lib/shared.sh
|
||||||
|
DISABLE_LOG=1
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||||
|
cd "$DIR"
|
||||||
|
source "$DIR/lib/lib.sh"
|
||||||
|
DISABLE_LOG=0
|
||||||
|
|
||||||
|
log_info " => Writing prefix configuration"
|
||||||
|
|
||||||
|
echo -n "# Prefix configuration, last updated on" | tee "$DEPLOY_PREFIX_CONFIG"
|
||||||
|
date | tee -a "$DEPLOY_PREFIX_CONFIG"
|
||||||
|
|
||||||
|
# update all the instances
|
||||||
|
for slug in $(sql_bookkeep_list); do
|
||||||
|
INSTANCE_DOMAIN="$(compute_instance_domain "$slug")"
|
||||||
|
echo "$INSTANCE_DOMAIN:" | tee -a "$DEPLOY_PREFIX_CONFIG"
|
||||||
|
|
||||||
|
read -r INSTANCE_BASE_DIR MYSQL_DATABASE MYSQL_USER GRAPHDB_REPO GRAPHDB_USER GRAPHDB_PASSWORD <<< "$(sql_bookkeep_load "${slug}" "filesystem_base,sql_database,sql_user,graphdb_repository,graphdb_user,graphdb_password" | tail -n +2)"
|
||||||
|
|
||||||
|
pushd "$INSTANCE_BASE_DIR" > /dev/null
|
||||||
|
docker-compose exec barrel /user_shell.sh -c "drush php:script /wisskiutils/list_uri_prefixes.php" | tee -a "$DEPLOY_PREFIX_CONFIG"
|
||||||
|
popd > /dev/null
|
||||||
|
done
|
||||||
|
|
||||||
|
log_info " => Restarting resolver"
|
||||||
|
|
||||||
|
cd "$DEPLOY_RESOLVER_DIR"
|
||||||
|
docker-compose restart
|
||||||
Loading…
Add table
Add a link
Reference in a new issue