Add a means of reserving an instance

This commit is contained in:
Tom Wiesing 2020-10-01 11:49:17 +02:00
parent e210504ca8
commit 07b8061c7a
No known key found for this signature in database
GPG key ID: DC1F29F2BC78AB15
6 changed files with 103 additions and 0 deletions

View file

@ -194,6 +194,20 @@ To automatically rebuild all instances, use:
sudo bash /distillery/rebuild-all.sh sudo bash /distillery/rebuild-all.sh
``` ```
## Reserving an instance -- 'reserve.sh'
Sometimes it is useful to reserve a particular instance name.
This is done by hosting a placeholder website at the domain.
To do so, use:
```bash
sudo bash /distillery/reserve.sh SLUG
```
To un-reserve a website, manually stop the docker stack and remove the folder.
## Purge an existing WissKI instance -- 'purge.sh' ## Purge an existing WissKI instance -- 'purge.sh'

41
distillery/reserve.sh Executable file
View file

@ -0,0 +1,41 @@
#!/bin/bash
set -e
# read the lib/shared.sh and read the slug argument.
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd "$DIR"
source "$DIR/lib/lib.sh"
require_slug_argument
# wait for sql to be awake
wait_for_sql
# check if the site exists
if sql_bookkeep_exists "$SLUG"; then
log_error "=> Site '$SLUG' already exists in bookeeping table. "
echo "Refusing to work"
exit 1;
fi
log_info " => Creating local directory structure at '$INSTANCE_BASE_DIR'"
mkdir -p "$INSTANCE_BASE_DIR"
install_resource_dir "compose/reserve" "$INSTANCE_BASE_DIR"
log_info " => Writing configuration file"
load_template "docker-env/reserve" \
"VIRTUAL_HOST" "${INSTANCE_DOMAIN}" \
"SLUG" "${SLUG}" \
"LETSENCRYPT_HOST" "${LETSENCRYPT_HOST}" \
"LETSENCRYPT_EMAIL" "${LETSENCRYPT_EMAIL}" \
> "$INSTANCE_BASE_DIR/.env"
log_info " => Running and building image"
cd "$INSTANCE_BASE_DIR"
docker-compose build --pull
docker-compose pull
log_info " => Starting container"
docker-compose up -d
log_info " => $INSTANCE_DOMAIN has been reserved"

View file

@ -0,0 +1,14 @@
#######################
# Meta Settings
#######################
#######################
### Web Server settings
#######################
# the hostname for the website
VIRTUAL_HOST=example.com
# optional letsencrypt support
# when blank, ignore
LETSENCRYPT_HOST=
LETSENCRYPT_EMAIL=

View file

@ -0,0 +1,26 @@
version: "3.7"
services:
static:
image: tkw01536/gostatic
restart: always
environment:
# port and hostname for this image to use
VIRTUAL_HOST: ${VIRTUAL_HOST}
VIRTUAL_PORT: 8043
# optional letsencrypt email
LETSENCRYPT_HOST: ${LETSENCRYPT_HOST}
LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL}
ports:
- 8043
# volumes that are mounted
volumes:
- ./index.html:/srv/http/index.html:ro
networks:
default:
external:
name: distillery

View file

@ -0,0 +1,4 @@
<!DOCTYPE html>
This domain name is reserved.
Content is a work in progress.

View file

@ -0,0 +1,4 @@
VIRTUAL_HOST=${VIRTUAL_HOST}
LETSENCRYPT_HOST=${LETSENCRYPT_HOST}
LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL}