From e66a4f0834fbb2a7fa5372ceda3f83bde83f737b Mon Sep 17 00:00:00 2001 From: Winston Smith Date: Tue, 5 Dec 2023 09:16:30 +0100 Subject: [PATCH] chore: better folder structure --- .gitignore | 1 + Dockerfile | 1 + README.md | 15 ++++++++++++--- data/entrypoint.sh => entrypoint.sh | 6 +++--- .../descriptions}/blog_description.txt | 0 5 files changed, 17 insertions(+), 6 deletions(-) rename data/entrypoint.sh => entrypoint.sh (89%) rename {data => jekyll/descriptions}/blog_description.txt (100%) diff --git a/.gitignore b/.gitignore index 1e8f8b2..2ed9ae2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .env +!jekyll/descriptions/blog_description jekyll/** diff --git a/Dockerfile b/Dockerfile index 5d98590..1a3ffe4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,7 @@ FROM ruby:3.2.2 RUN useradd -ms /bin/bash --uid 1000 jekyll RUN mkdir -p -m 0755 /app/jekyll RUN mkdir -p -m 0755 /opt/jekyll +COPY ./entrypoint.sh /opt/jekyll VOLUME $PWD/data:/opt/jekyll RUN chmod +x /opt/jekyll/ && \ chown -R 1000:1000 /opt/jekyll && \ diff --git a/README.md b/README.md index 5930698..e332afd 100644 --- a/README.md +++ b/README.md @@ -9,13 +9,15 @@ Counting on my modest shell scripting skills, I managed to give life to an abomi ## How to use it ? -- Edit `./data/.env` to fit your needs. -- Create `./data/_description.txt`, with the wanted website description. +- Edit `./data/.env` to fit your needs. A sample is provided. +- Create `./jekyll/descriptions/_description.txt`, with the wanted website description. **Be carefull to remove whitespaces at line start**. It will not properly indented when put in the `_config.yml`, fudging up the description format. + Some sed hackity-hack are done but I can't assure you that it will be easy on your eyes afterwards... - Build the image via the provided `docker-compose.yml` file. - Run the service. -Jekyll is started by default in "production mode", a.k.a. it will just build static files. If you want your files to be served by jekyll for testing needs, just change `JEKYLL_ENV` to anything other that `production`. +Jekyll is started by default in "production mode", a.k.a. it will just build static files from `./jekyll/$BLOG_NAME/` content and put in `./jekyll/$BLOG_NAME/_site` which you would serve via your prefered reverse-proxy. +If you want your files to be served by jekyll (for testing needs, enjoying the glorious live-reload feature), just change `JEKYLL_ENV` to anything other that `production`. Variables in .env and the site description are updated at container restart. **Keep in mind that changing your site name (with `BLOG_NAME` var) will fudge up all reference files (site description, site path etc.).** @@ -23,3 +25,10 @@ Variables in .env and the site description are updated at container restart. This software is provided as-is and is the offspring of a humble sysadmin mind, constantly learning new things. It will be improved the time beeing. + +## TO-DO + +- Properly configure the live-reload port feature. +- More robust code +- More easier to use +- templates diff --git a/data/entrypoint.sh b/entrypoint.sh similarity index 89% rename from data/entrypoint.sh rename to entrypoint.sh index 31a6a4e..532bf43 100755 --- a/data/entrypoint.sh +++ b/entrypoint.sh @@ -46,10 +46,10 @@ update_config() { update_description() { initial_description=$(sed -n '/^description/,/^baseurl/p' ${SITE_PATH}/_config.yml | sed '/^description/d' | sed '/^baseurl: ""/d' | sed 's/^[[:space:]]*//' | sed '/^description:/,/^baseurl:/ { /^description:/n; /^baseurl:/! { /^$/d; } }') - current_description=$(sed 's/^[[:space:]]*//' /opt/jekyll/${BLOG_NAME}_description.txt) - [[ "$initial_description" != "$current_description" && ! -z $current_description ]] && { + current_description=$(sed 's/^[[:space:]]*//' /app/jekyll/descriptions/${BLOG_NAME}_description.txt) + [[ "$initial_doptescription" != "$current_description" && ! -z $current_description ]] && { echo "Config change detected on site description: updating _config.yml" - sed -i "/^description/,/^baseurl:/!b;//!d;/^description/r /opt/jekyll/${BLOG_NAME}_description.txt" ${SITE_PATH}/_config.yml + sed -i "/^description/,/^baseurl:/!b;//!d;/^description/r /app/jekyll/descriptions/${BLOG_NAME}_description.txt" ${SITE_PATH}/_config.yml sed -i '/^description:/,/^baseurl:/ { /^description:/n; /^baseurl:/! s/^[^[:space:]]/ &/; }' ${SITE_PATH}/_config.yml } || { echo "No change or empty variable for site $BLOG_NAME description, continuing..." diff --git a/data/blog_description.txt b/jekyll/descriptions/blog_description.txt similarity index 100% rename from data/blog_description.txt rename to jekyll/descriptions/blog_description.txt