Running hugo on Openshift

· Read in about 2 min · (264 Words)

Running Hugo on Openshift

I moved my blog/site from Ghost to hugo. Since Ghost is a Nodejs app, it was easy to deploy in Openshift. But hugo, a static site generator was not. I looked at hacking up the Jekyll cartridge, but in the end decided to build my own. Maybe I’ll convert this into a cartridge at some point. This isn’t really mean to be a script. Mostly a recipe for you to follow along. It’s not annotated; there’s nothing particularly cryptic going on here.

rhc app-create $NAME diy
git rm *
git commit -m "Remove DIY stuff"
hugo new site .
echo "/public" > .gitignore
mkdir bin
cp ~/bin/hugo bin/
git add *
git commit -m "Adding hugo site"
cat << EOF > .openshift/action_hooks/build

rm -rf $OPENSHIFT_REPO_DIR/public
chmod 755 .openshift/action_hooks/build
cat << EOF > .openshift/action_hooks/start
# The logic to start up your application should be put in this
# script. The application will work only if it binds to
nohup $OPENSHIFT_REPO_DIR/bin/hugo \
	--destination=$OPENSHIFT_REPO_DIR/public \
	--watch=false \
	--appendPort=false \
	--disableLiveReload=true \
	--baseURL="http://my-base-url/" \
	server |& /usr/bin/logshifter -tag diy &
cat << EOF > .openshift/action_hooks/stop

# The logic to stop your application should be put in this script.
if [ -z "$(ps -ef | grep hugo | grep -v grep)" ]
    client_result "Application is already stopped"
    kill `ps -ef | grep hugo | grep -v grep | awk '{ print $2 }'` > /dev/null 2>&1
git add .openshift/action_hooks/*
git commit -m "updating action_hooks"
git push