From 8b7c5243d1604be55e96d81aa1b87253665ec42a Mon Sep 17 00:00:00 2001 From: shockrah Date: Mon, 8 Feb 2021 20:43:59 -0800 Subject: [PATCH] +New post +New color for code text(lightgreen) *Removing check in upload.sh for file(filtering via find -type f) --- pages/index.md | 7 ++++ partials/header.html | 2 +- posts/docker-ftw.md | 78 ++++++++++++++++++++++++++++++++++++++++++++ root/style.css | 4 +++ upload.sh | 6 ++-- 5 files changed, 92 insertions(+), 5 deletions(-) create mode 100644 posts/docker-ftw.md diff --git a/pages/index.md b/pages/index.md index 5e7c669..454e44d 100644 --- a/pages/index.md +++ b/pages/index.md @@ -1,6 +1,13 @@ # Definitely not a blog ## I swear +## **[Auto Deploying to VPS and Neocities with Docker](/post/docker-ftw.html)** + +> _February 08, 2021_ + +> All under Gitlab's CI/CD System + + ## **[Making Ice Cream at Home](/post/ice-cream.html)** > _July 24, 2020_ diff --git a/partials/header.html b/partials/header.html index 6b349bf..ec570db 100644 --- a/partials/header.html +++ b/partials/header.html @@ -8,7 +8,7 @@ - + diff --git a/posts/docker-ftw.md b/posts/docker-ftw.md new file mode 100644 index 0000000..8d69473 --- /dev/null +++ b/posts/docker-ftw.md @@ -0,0 +1,78 @@ +# Using Gitlab CI For VPS and Neocites Deployment + +_I'll make this one short_: Deploying to a VPS is pretty easy when its already configured with Nginx to serve static content, but Neocities is a slight worse pain. Several scripts later I've figured out how to 100% automate pushing to both. + + +## Docker + +A few notes about this docker file: + +* Could be made way smaller if using Alpine + +* Setting up Pandoc on alpine is way more effort on Alpine because you have to compile it yourself as its not in the official Alpine repos + +* gensite is a script I wrote for building markdown based sites with Pandoc with 0 deps + +``` +FROM debian:sid-slim + +RUN apt-get update && apt-get install -y git pandoc +# For more easily logging into ionos +RUN apt-get install -y sshpass +RUN apt-get install -y curl + +RUN git clone https://gitlab.com/shockrah/site-generator /tmp/gensite +RUN cd /tmp/gensite && ./install.sh g +RUN rm -rf /tmp/gensite +``` + +## Gitlab's CI Script + +It should be noted there are more environment variables set in Gitlab's WebUI to make this script work but basically everything is there. + + +``` +image: shockrah/website:1.3 + +stages: + - build + - deploy + +variables: + SHOPTS: "-o StrictHostKeyChecking=no" + + +before_script: + - eval $(ssh-agent -s) + - echo "${SSH_PRIVATE_KEY}" | ssh-add - > /dev/null + - mkdir -p ~/.ssh/ + - chmod 700 ~/.ssh/ + +build-site: + stage: build + + script: + bash ./build.sh + + artifacts: + expire_in: 10 mins + paths: ["./.mirror"] + +deploy-vps: + stage: deploy + + script: + - ssh $SHOPTS root@shockrah.xyz "rm -rf /var/www/website" + - scp $SHOPTS -r .mirror root@shockrah.xyz:/var/www/website/ + +deploy-neocities: + stage: deploy + + script: + # First the html + - bash upload.sh -h + # then we do the media files + - bash upload.sh -M + +``` + diff --git a/root/style.css b/root/style.css index 9e3618a..c75f437 100644 --- a/root/style.css +++ b/root/style.css @@ -12,6 +12,10 @@ a { color: white; } +code { + color: lightgreen; +} + blockquote { border-left: 10px solid #1f8dd6; } diff --git a/upload.sh b/upload.sh index 7e47e64..b71318a 100755 --- a/upload.sh +++ b/upload.sh @@ -32,11 +32,9 @@ _upload_media() { } _upload_all_media() { - for file in $(find media);do + for file in $(find media -type f);do echo Uploading media: $file - if [ -f $file ];then - curl -H "$auth" -F "$file=@$file" $url/api/upload > /dev/null - fi + curl -H "$auth" -F "$file=@$file" $url/api/upload -s > /dev/null done }