Running a serverless blog for my company website
When I started my company, I was looking for a blogging platform which I can use easily and at the same time it can be managed more easily. So the choice which I was learning towards was to have a Serverless Blogging website. Parameters were to have something on which I can easily write and I don’t have to do anything to manage the infrastructure of the website. After going through many blogging platforms and reading a lot of articles, I’d decided to go with Jekyll
Jekyll is a simple, blog-aware, static site generator for personal, project, or organization sites. Written in Ruby by Tom Preston-Werner, GitHub’s co-founder, it is distributed under the open source MIT license.
So Here’s a DIY article on how can you setup your own Serverless Blogging Platform with near to
- First we’ll need to install
sudo apt-get install ruby-full build-essential zlib1g-dev echo '# Install Ruby Gems to ~/gems' >> ~/.bashrc echo 'export GEM_HOME="$HOME/gems"' >> ~/.bashrc echo 'export PATH="$HOME/gems/bin:$PATH"' >> ~/.bashrc source ~/.bashrc
Quick Start Instructions
Let’s get started with installation:
gem install bundler jekyll
This shoudl install
Jekyll which is required to setup your own bloggin platform.
Create your Blogging website
Now, let’s create our own website.
jekyll new my_awesome_site cd my_awesome_site
Jekyll is a static fle generator so we would have to build a site before we can view any content.
Jekyll buildwould build the site and copy the new posts/contents into
Jekyll servewould start a local web server at
Alternatively during the development time you can run below command to rebuild your website with every changes which gets saved.
bundle exec jekyll serve # => Now browse to http://localhost:4000
Setting up a template
Being an OpenSource project, You would find a lot of prebuilt templates which you can use for your blogging website. Head to - JekyllThemes
Quick way to setup -
git clone https://github.com/daattali/beautiful-jekyll.git cd beautiful-jekyll/ sudo bundle install bundle exec jekyll serve
Now, that my blogging platform is ready, I want to deploy the website using my command line without me running a serious upload operations.
So I setup my CI/CD Pipeline on Gitlab CI which would trigger everytime I upload my blog into my gitlab repo.
This is how my
.gitlab-ci.yml file looks like.
image: ruby:2.3 stages: - build - deploy cache: paths: - vendor key: "$CI_BUILD_REPO" before_script: - gem install bundler build_jekyll: stage: build only: - master script: - bundle install --path=vendor/ - bundle exec jekyll build artifacts: paths: - _site/ deploy_production: image: "python:latest" stage: deploy when: manual dependencies: - build_jekyll before_script: - pip install awscli # Install the SDK script: - aws s3 cp _site s3://$AWS_BUCKET/blog --recursive --exclude ".git/*" --exclude ".gitlab-ci.yml" --acl public-read - aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths "/blog/*" environment: name: production url: http://datavizz.in/blog
That’s all and my blogging setup was ready.In between I didn’t covered on how to create S3 bucket and what configurations you should do to host your website on S3 which can be found here
Don’t forget to leave down your review and do give me your comments on what you would like to see next!