Add 'rebuild.sh' to rebuild a docker image
This commit is contained in:
parent
5905847b1c
commit
a25c12b0fa
6 changed files with 57 additions and 11 deletions
20
README.md
20
README.md
|
|
@ -153,6 +153,26 @@ To do so, use:
|
||||||
sudo bash /distillery/provision.sh SLUG
|
sudo bash /distillery/provision.sh SLUG
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Rebuild an instance -- 'rebuild.sh'
|
||||||
|
|
||||||
|
Sometimes it becomes necessary (because of changes to this project) to rebuild the docker image running a certain docker instance.
|
||||||
|
To do so, use:
|
||||||
|
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo bash /distillery/rebuild.sh SLUG
|
||||||
|
```
|
||||||
|
|
||||||
|
Note that rebuilding an instance does restart the docker container resulting in a small (typical < 1 second) interruption to the website in question.
|
||||||
|
Furthermore, while the container recreated, the old image stays on the host.
|
||||||
|
To delete all instances, run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo docker image prune --all
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Purge an existing WissKI instance -- 'purge.sh'
|
## Purge an existing WissKI instance -- 'purge.sh'
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ function install_resource_dir() {
|
||||||
for filename in "$from"/*; do
|
for filename in "$from"/*; do
|
||||||
dest="$to/`basename "${filename}"`"
|
dest="$to/`basename "${filename}"`"
|
||||||
echo "Writing \"$dest\""
|
echo "Writing \"$dest\""
|
||||||
cp -r "$filename" "$dest"
|
cp -rTv "$filename" "$dest"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,3 +14,11 @@ export DEBIAN_FRONTEND=noninteractive
|
||||||
# This file just sets a few utility functions to be used by the code.
|
# This file just sets a few utility functions to be used by the code.
|
||||||
# randompw generates a random password as per the configuration file.
|
# randompw generates a random password as per the configuration file.
|
||||||
alias randompw="cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w $PASSWORD_LENGTH | head -n 1"
|
alias randompw="cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w $PASSWORD_LENGTH | head -n 1"
|
||||||
|
|
||||||
|
# update_stack fully updates a docker-compose stack in the given location.
|
||||||
|
function update_stack() {
|
||||||
|
cd "$1"
|
||||||
|
docker-compose pull
|
||||||
|
docker-compose build --pull
|
||||||
|
docker-compose up -d
|
||||||
|
}
|
||||||
25
distillery/rebuild.sh
Normal file
25
distillery/rebuild.sh
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
#!/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
|
||||||
|
|
||||||
|
|
||||||
|
# if the site doesn't exist, I can't open a shell.
|
||||||
|
if ! sql_bookkeep_exists "$SLUG"; then
|
||||||
|
log_error "=> Site '$SLUG' does not exist in bookeeping table. "
|
||||||
|
echo "I can't rebuild it. "
|
||||||
|
exit 1
|
||||||
|
fi;
|
||||||
|
|
||||||
|
# Read everything from the database
|
||||||
|
read -r INSTANCE_BASE_DIR MYSQL_DATABASE MYSQL_USER GRAPHDB_REPO GRAPHDB_USER <<< "$(sql_bookkeep_load "${SLUG}" "filesystem_base,sql_database,sql_user,graphdb_repository,graphdb_user" | tail -n +2)"
|
||||||
|
|
||||||
|
log_info " => Updating compose files"
|
||||||
|
install_resource_dir "compose/runtime" "$INSTANCE_BASE_DIR"
|
||||||
|
|
||||||
|
log_info "=> Rebuilding and restarting '$INSTANCE_BASE_DIR'"
|
||||||
|
update_stack "$INSTANCE_BASE_DIR"
|
||||||
|
|
@ -6,8 +6,9 @@ DISABLE_LOG=1
|
||||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||||
cd "$DIR"
|
cd "$DIR"
|
||||||
source "$DIR/lib/lib.sh"
|
source "$DIR/lib/lib.sh"
|
||||||
require_slug_argument
|
|
||||||
DISABLE_LOG=0
|
DISABLE_LOG=0
|
||||||
|
require_slug_argument
|
||||||
|
|
||||||
|
|
||||||
# if the site doesn't exist, I can't open a shell.
|
# if the site doesn't exist, I can't open a shell.
|
||||||
if ! sql_bookkeep_exists "$SLUG"; then
|
if ! sql_bookkeep_exists "$SLUG"; then
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,6 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||||
cd "$DIR"
|
cd "$DIR"
|
||||||
source "$DIR/lib/lib.sh"
|
source "$DIR/lib/lib.sh"
|
||||||
|
|
||||||
# update_stack fully updates a docker-compose stack in the given location.
|
|
||||||
function update_stack() {
|
|
||||||
cd "$1"
|
|
||||||
docker-compose pull
|
|
||||||
docker-compose build --pull
|
|
||||||
docker-compose up -d
|
|
||||||
}
|
|
||||||
|
|
||||||
log_info "=> Rebuilding and restarting 'web' stack"
|
log_info "=> Rebuilding and restarting 'web' stack"
|
||||||
update_stack "$DEPLOY_WEB_DIR"
|
update_stack "$DEPLOY_WEB_DIR"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue