Website deployment scripts (WIP)

pull/674/head
Zef Hemel 2024-01-28 10:22:40 +01:00
parent 3e623c3cef
commit ca816eca5a
4 changed files with 116 additions and 1 deletions

3
.gitignore vendored
View File

@ -15,4 +15,5 @@ node_modules
test_space test_space
silverbullet silverbullet
deploy.json deploy.json
*.generated *.generated
tmp_playground

View File

@ -0,0 +1,50 @@
#!/bin/bash -e
cd $(realpath $(dirname $(dirname $0)))
IMAGE_NAME="zefhemel/silverbullet:edge"
WEBSITE_SPACE="./website"
WEBSITE_PORT=3000
# Get the current image ID
BEFORE_PULL=$(docker images -q $IMAGE_NAME)
# Pull the Docker image
docker pull $IMAGE_NAME
# Get the new image ID
AFTER_PULL=$(docker images -q $IMAGE_NAME)
# Compare the image IDs
# if [ "$BEFORE_PULL" == "$AFTER_PULL" ]; then
# echo "The Docker image has not been updated. Done!"
# exit 0
# fi
echo "The Docker image has been updated, let's update the website content."
git pull
# Check if a silverbullet container is running already
if [ "$(docker ps -q -f name=silverbullet)" ]; then
echo "A silverbullet container is running, let's stop it."
docker kill silverbullet
docker rm silverbullet
fi
# Remove the old database
echo "Removing old databases"
rm -f $WEBSITE_SPACE/.silverbullet.db*
echo "Starting new silverbullet container"
docker run -d --name silverbullet -v $WEBSITE_SPACE:/space -e SB_READ_ONLY=1 -p $WEBSITE_PORT:3000 $IMAGE_NAME
echo "Waiting for the servers to start"
# Repeatedly try to connect to the server until it responds
until $(curl --output /dev/null --silent --head --fail http://localhost:$WEBSITE_PORT/); do
printf '.'
sleep 1
done
echo
echo "We're back up!"

View File

@ -0,0 +1,45 @@
#!/bin/bash -e
cd $(realpath $(dirname $(dirname $0)))
IMAGE_NAME="zefhemel/silverbullet:edge"
PLAYGROUND_SPACE="/tmp/silverbullet-playground"
PLAYGROUND_PORT=3001
# Pull the Docker image
docker pull $IMAGE_NAME
echo "Let's update the repo content, just in case."
git pull
# Now do the same for the playground
echo "Now resetting the playground"
# Check if a silverbullet container is running already
if [ "$(docker ps -q -f name=silverbullet-playground)" ]; then
echo "A playground container is running, let's stop it."
docker kill silverbullet-playground
docker rm silverbullet-playground
fi
# Remove the old space
echo "Removing old playground space"
rm -rf $PLAYGROUND_SPACE
echo "Creating fresh playground space"
mkdir -p $PLAYGROUND_SPACE
cp -r scripts/playground_space/* $PLAYGROUND_SPACE/
# Let's copy in the default libraries
cp -r website/Library $PLAYGROUND_SPACE/
echo "Starting new playground container"
docker run -d --name silverbullet-playground -v $PLAYGROUND_SPACE:/space -e SB_SHELL_BACKEND=off -p $PLAYGROUND_PORT:3000 $IMAGE_NAME
echo "Waiting for the server to start"
until $(curl --output /dev/null --silent --head --fail http://localhost:$PLAYGROUND_PORT/); do
printf '.'
sleep 1
done
echo
echo "We're back up!"

View File

@ -0,0 +1,19 @@
# Welcome to the SilverBullet Playground
This is a fully functional SilverBullet instance that **resets every hour.**
So go ahead, play around, but don't keep anything valuable here. It will be gone in a snap.
## Dont just sit there, try it!
* Click on the page picker (book icon) icon at the top right, or hit `Cmd-k` (Mac) or `Ctrl-k` (Linux and Windows) to open the **page switcher**. Type the name of a non-existent page to create it (although it wont save in this environment).
* Click on the terminal button (top right) or hit `Cmd-/` (Mac) or `Ctrl-/` (Linux and Windows) to open the **command palette** (note that not all commands will work in this mode).
* Select some text and hit `Alt-m` to ==highlight== it, or `Cmd-b` (Mac) or `Ctrl-b` (Windows/Linux) to make it **bold**, or `Cmd-i` (Mac) or `Ctrl-i` (Windows/Linux) to make it _italic_.
* Click a link somewhere on this page to navigate there.
* Start typing `[[` somewhere to insert a page link (with completion).
* [ ] Tap this box 👈 to mark this task as done.
* Start typing `:party` to trigger the emoji picker 🎉
* Type `/` somewhere in the text to invoke a **slash command**.
* Click this button {[Editor: Toggle Vim Mode]} to toggle Vim mode
* Open this site on your phone or tablet and... it just works!
* Are you using a browser with **PWA support** (e.g., any Chromium-based
browser or recent version of Safari)? Click on that little icon to the right of your location bar that says “Install SilverBullet” to give SB its own window frame and desktop icon, like it is a stand-alone app. Now, unplug your network cable and reload the page. It still works!