Add a means of reserving an instance
This commit is contained in:
parent
e210504ca8
commit
07b8061c7a
6 changed files with 103 additions and 0 deletions
14
README.md
14
README.md
|
|
@ -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
41
distillery/reserve.sh
Executable 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"
|
||||||
14
distillery/resources/compose/reserve/.env.sample
Normal file
14
distillery/resources/compose/reserve/.env.sample
Normal 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=
|
||||||
26
distillery/resources/compose/reserve/docker-compose.yml
Normal file
26
distillery/resources/compose/reserve/docker-compose.yml
Normal 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
|
||||||
4
distillery/resources/compose/reserve/index.html
Normal file
4
distillery/resources/compose/reserve/index.html
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
|
||||||
|
This domain name is reserved.
|
||||||
|
Content is a work in progress.
|
||||||
4
distillery/resources/templates/docker-env/reserve
Normal file
4
distillery/resources/templates/docker-env/reserve
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
VIRTUAL_HOST=${VIRTUAL_HOST}
|
||||||
|
|
||||||
|
LETSENCRYPT_HOST=${LETSENCRYPT_HOST}
|
||||||
|
LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue