13 Jun 2020

V1 Blog setup

This is a test

This guide has all the step that I use to create this blog.

List of technologies used in this project:

  • Jekyll
  • less encrypt
  • NGinex
  • docker
  • ubuntu
  • docker-compose

The Diagram of the stack is:

stack

Technologies

Jekyll :

Jekyll is a Ruby framework to create static pages and blogs in a simple way. And the communita has create a lot of templates. This blog is base in the theme Type-on-Strap with my ome configuration.

The project file configuration is:

BlogNotes.dev
├── _data  # configuration data in YML format
├── _drafts # drafts post
├── _includes # all HTML/Markdown parts of layouts
├── _layouts # all the layouts used to generate pages
├── _posts # All posts in the blog
├── _sass # all the pre-process style sheet
├── _site # The full site compile
├── assets # The extra files for extra functionalities in the web page
│   ├── css # sass file or css
│   ├── data # data of the post or other web pages
│   ├── fonts # fonts used in the all teh blog
│   ├── img # Images
│   └── js # javascript
└── pages # the main pages
_config.yml # main configuration file
index.md # home page

The gem configuration is:

source "https://rubygems.org"
gem "jekyll"

# plugins
group :jekyll_plugins do
  gem "jekyll-paginate"
  gem "jekyll-feed"
  gem "jekyll-seo-tag"
end

Nginx:

upstream blognotes {
    server blognotes:4001 weight=1;
}

server {
    listen 80;
    server_name blognotes.dev;
    server_tokens off;

    location /.well-known/acme-challenge/ {
        root /var/www/certbot;
    }

    location / {
        return 301 https://$host$request_uri;
    }
}

server {
    listen 443 ssl;
    server_name blognotes.dev;
    server_tokens off;

    ssl_certificate /etc/letsencrypt/live/blognotes.dev/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/blognotes.dev/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf;
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

    location / {
        proxy_pass  http://blognotes;
        proxy_set_header    Host                $http_host;
        proxy_set_header    X-Real-IP           $remote_addr;
        proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
    }
}

docker:

Docker file for

FROM jekyll/jekyll:latest

ENV APP_HOME /srv/jekyll

CMD [ "jekyll", "serve" ]

ubuntu:

I use a virtual machine with ubuntu 18.06

docker-compose:

version: '3'

services:
  blog:
    hostname: blognotes
    build:
      context: ./Blognotes/docs
      dockerfile: ./Dockerfile
    depends_on:
      - nginx
      - certbot
    ports:
      - '4001:4000'
    volumes:
      - ./Blognotes/docs:/srv/jekyll
  nginx:
    image: nginx
    restart: unless-stopped
    volumes:
      - ./data/nginx:/etc/nginx/conf.d
      - ./data/certbot/conf:/etc/letsencrypt
      - ./data/certbot/www:/var/www/certbot
    ports:
      - '80:80'
      - '443:443'
    command: '/bin/sh -c ''while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g "daemon off;"'''
  certbot:
    image: certbot/certbot
    restart: unless-stopped
    volumes:
      - ./data/certbot/conf:/etc/letsencrypt
      - ./data/certbot/www:/var/www/certbot
    entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"

let's encrypt:

init-letsencrypt.sh is possible to download from this link

 ./init-letsencrypt.sh

reference:

[1] - nginx and let's encrypt

[2] - Blog Template

© 2019 Jsuarez.Dev