Home Home Lab Wiki install and update
Post
Cancel

Home Lab Wiki install and update

This is a guide to install jekyll, make a post, update it and push to docker. It’s what this site is built on!

Install Dependencies

1
2
sudo apt update
sudo apt install ruby-full build-essential zlib1g-dev git

To avoid installing RubyGems packages as the root user:

1
2
3
4
echo '# Install Ruby Gems to ~/gems' >> ~/.bashrc
echo 'export GEM_HOME="$HOME/gems"' >> ~/.bashrc
echo 'export PATH="$HOME/gems/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

Install Jekyll bundler

1
gem install jekyll bundler

Creating a site based on Chirpy Starter

Visit https://github.com/cotes2020/jekyll-theme-chirpy#quick-start

Sign in to GitHub and browse to Chirpy Starter, click the button Use this template > Create a new repository, and name the new repository USERNAME.github.io, where USERNAME represents your GitHub username.

MAKE SURE IT’S PUBLIC

After creating a site based on the template, clone your repo

1
git clone git@<YOUR-USER-NAME>/<YOUR-REPO-NAME>.git

then install your dependencies

1
2
cd repo-name
bundle

This should install all the dependencies for the site to run. Later it can be built as a docker image and served via nginx or something else. This is just to test it.

Jekyll Commands

Serving your site from an VM to the entire network.

1
bundle exec jekyll s --host 0.0.0.0

Once finished testing you can then build it into production

Building your site in production mode

1
JEKYLL_ENV=production bundle exec jekyll b

This will build all the pages and output the production site to _site

Building with Docker

Create a Dockerfile with the following

1
2
FROM nginx:stable-alpine
COPY _site /usr/share/nginx/html # basically coping the _site to the nginx folder to be served out

Build site in production mode

1
JEKYLL_ENV=production bundle exec jekyll b

Then build your image

docker build .

This is a CD pipline for gitlab

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
stages:
  - test
  - publish
  - deploy

variables:
  TAG_LATEST: <YourServerIP>:5000/homelab:latest
  TAG_COMMIT: <YourServerIP>:5000/homelab:$CI_COMMIT_SHORT_SHA
  DOCKER_NAME: homelab-wiki
  JEKYLL_ENV: production
  GIT_STRATEGY: clone
  GIT_DEPTH: 0

cache: &global_cache
  key: $CI_PROJECT_NAME
  paths:
    - vendor/ruby
  policy: pull-push

build:
  image: ruby:2.7
  stage: test
  artifacts:
    paths:
      - _site
    expire_in: 1 week
  cache:
    <<: *global_cache
  retry: 2
  script:
    - gem install bundler
    - bundle config set --local path 'vendor/ruby'
    - bundle install
    - JEKYLL_ENV=production bundle exec jekyll b


publish:
  image: docker:latest
  stage: publish
  services:
    - docker:dind
  script:
    # - docker build -t alfred-api .
    - docker build -t $TAG_COMMIT -t $TAG_LATEST .
    - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN <YourServerIP>:5000
    - docker push $TAG_COMMIT
    - docker push $TAG_LATEST

deploy:
  image: alpine:latest
  stage: deploy
  retry: 2
  # tags:
  #   - deployment
  script:
    - chmod 600 $ID_RSA
    - apk update && apk add openssh-client
    - ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN <YourServerIP>:5000"
    - ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker pull $TAG_COMMIT"
    - ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker container rm -f $DOCKER_NAME || true"
    - ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker run -d --restart always -p 4000:80 --name $DOCKER_NAME $TAG_COMMIT"
  environment:
    name: production
    url: http://<YourServerIP>
  only:
    - main

Creating a Post

All posts need to start with the following

1
2
3
4
5
6
---
title: TITLE
date: YYYY-MM-DD HH:MM:SS +/-TTTT
categories: [TOP_CATEGORIE, SUB_CATEGORIE]
tags: [TAG]     # TAG names should always be lowercase
---

Naming Conventions Jekyll uses a naming convention for pages and posts

Create a file in _posts with the format

YEAR-MONTH-DAY-title.md For example:

2022-05-23-homelab-docs.md 2022-05-34-hardware-specs.md

Jekyll can delay posts which have the date/time set for a point in the future determined by the “front matter” section at the top of your post file. Check the date & time as well as time zone if you don’t see a post appear shortly after re-build..

Local Linking of Files Image from asset:

1
2
... which is shown in the screenshot below:
![A screenshot](/assets/screenshot.jpg)

Linking to a file

1
... you can [download the PDF](/assets/diagram.pdf) here.

Lists

1
2
3
* d
* d
* d

Programming syntax

1
2
3
4
5
```python
print(hello)
if something > somethingelse:
    print(hahah)
# ``` comment this out

External images

1
![img-decription](https://media.licdn.com/dms/image/C4E22AQHbCjagzP7BSQ/feedshare-shrink_800/0/1676679133006?e=1679529600&v=beta&t=_YA8-s_uYGCMq-Y1Z1i2k-Xb9D5UyzSO_vdxdfLWqKw)
This post is licensed under CC BY 4.0 by the author.
Trending Tags