Jekyll testing
After a long time of silence on this Blog, I wanted to write a post about a different way of 3D printing maps [Comming soon (tm)].
Since I switched from my Hackintosh to a new Mac Mini, I had to reinstall all the necessary tools and stuff to generate the files for this static page. While revisiting the steps to take, I stumbled across a docker container that has everything I needed in a nice and packaged form.
In this post, I will document the process I am using to generate this site.
Preparing everything
On my old setup The files have been handled by Gitea already so there was nothing to be changed. VSCode makes it really easy to work with a git Repository.
All my Docker containers nowadays run on a very efficient ThinClient already, which I wanted to use for this.
My plan was to use the Jekyll Docker, and then automatically grab the most recent files from Gitea, to generate a testing and building environment.
Script to handle everything
After playing around and getting the Container to generate the website from manually copied files, I started to automate things a bit.
In the end, I came up with a simple way to generate and test everything.
I connect via SSH to my docker host and simply run “bash JekyllBuild.sh start” to bring up the Container, getting the latest files from Gitea, install all the necessary Gems and finally serve the website.
When changing something in the repository, I can run “bash JekyllBuild.sh update” to get the latest state and rebuild the website.
Finally, after making sure everything is fine, I use “bash JekyllBuild.sh build” to stop everything and build all the files to put on HERE to bring them to you.
This has been my first real use case for a Bash Script, and I am quite happy with what it can do.
[Edit] After some feedback I added the -h/help section
#!/bin/sh bash
# stop: stopping the Container Jekyll
# start: start the container for testing
# update: renew the post and image files from gitea
# build: Build the files for the web
if [ -n "$1" ]
then
echo Parameter found
else
printf "\nNo Parameter provided. specify what you want to do. start, stop, update, build\n\n"
exit
fi
if [ $1 = "stop" ]
then
echo stop container
docker container stop Jekyll
fi
if [ $1 = "-h" -o $1 = "help" ]
then
#Helpinfos
printf " -----------------------------Help-------------------------------------- \n"
printf " -h or help\t Shows this help \n"
printf " stop \t\t Will stop the Jekyll container \n"
printf " start \t\t Will start the Jekyll container for testing. initial renewal from git \n"
printf " update \t Will renew all the files from git \n"
printf " build \t\t Builds all the files for the Web version \n"
fi
if [ $1 = "start" ]
then
rm -r /srv/Docker/Jekyll/Daten/*
cd Daten
wget http://192.168.0.153:4000/Sebastian/Jekyll_Blog/archive/master.zip -O master.zip
unzip -o master.zip
chown sebastian:sebastian jekyll_blog -R
echo starting the container with the server. This may take up to 30s!
docker run -d --rm --name=Jekyll --volume="/srv/Docker/Jekyll/Daten/jekyll_blog:/srv/jekyll:Z" --network=host jekyll/jekyll jekyll serve -P 4040 -H 192.168.0.153
fi
if [ $1 = "update" ]
then
cd Daten
rm -r jekyll_blog/_posts/*
rm -r jekyll_blog/assets/img/Posts/*
wget http://192.168.0.153:4000/Sebastian/Jekyll_Blog/archive/master.zip -O master.zip
unzip -o master.zip
chown sebastian:sebastian jekyll_blog -R
echo Updated all the posts. Only the posts with images!
fi
if [ $1 = "build" ]
then
docker container stop Jekyll
echo wait 10s to completely stop the container
sleep 10
rm -r /srv/Docker/Jekyll/Daten/*
cd Daten
wget http://192.168.0.153:4000/Sebastian/Jekyll_Blog/archive/master.zip -O master.zip
unzip -o master.zip
chown sebastian:sebastian jekyll_blog -R
echo starting the build
docker run --rm --name=Jekyll --volume="/srv/Docker/Jekyll/Daten/jekyll_blog:/srv/jekyll:Z" --network=host jekyll/jekyll jekyll build
echo Building is finished. you can now move the files of the _site folder to the Webserver
fi