Tutorial & Dockerfile: Self-hosted Steem blog under $1 a year

in #tutorial6 years ago (edited)

This is a tutorial which includes an open-source Docker image I wrote for the purpose of setting up self-steem.

SelfSteem is an open source project for hosting a copy of your Steem blog written by @almost-digital.

Check out my blog at https://kirkbride.me for a running example of this setup.


Step #1 - Domain

Two cheap options for domains. The second requires access to a .edu email address but allows you to get a domain for free.

Step #2 - Hosting

For what we're doing Amazon's AWS free-tier is sufficient to host a t2.micro instance of EC2. Sign up and create t2.micro instance running any OS that supports Docker, I'm using Ubuntu 16.04.

The micro instance won't nessisarily handle a huge amount of requests if your blog gets big but we can combine it with caching in step #4, which will drastically lower the amount of user requests that actually make it to the server.

Step #3 Open port 80 on EC2 instance

If you're using EC2 your instance will have a section called "security group" when you highlight it in the console:

Screenshot from 2018-09-03 22-23-46.png

In my case it's called launch-wizard-12. Click on the name.

At the bottom of the next page you should see something like this, with the inboud tab selected click edit:
Screenshot from 2018-09-03 22-26-47.png

Add a new inboud rule using the http type:

Screenshot from 2018-09-03 22-20-52.png

Step #4 DNS, SSL, & CDN

Cloudflare provides custom DNS, SSL, and CDN all for free.

DNS = Domain Name Server (A server which matches human readable domain names to IP addresses)

SSL = Secure Sockets Layer (Encryption layer which ensures secure connection between server and user)

CDN = Content Delivery Network (A network of servers with caching spread-out geographically in order to increase page load speed and reliability)

Screenshot from 2018-09-03 21-20-51.png

This step can be divided into the following sub-steps, most of which Name Cheap will walk you through during the signup process:

  • Point NameCheap DNS to CloudFlare
  • Ensure standard caching is enabled (should be default)
  • Point CNAME on CloudFlare to url of your AWS intance, using CNAME flattening
  • Turn on https everywhere.

Note: CNAME flattening is a method used by CloudFlare to allow you to use a domain (in this case the domain of your EC2 instance) as a CNAME entry. Normally you'd need to use an IP address here.

By enabling caching user's will be served your content from the CloudFlare data servers.

This means your AWS micro server only receives requests when a user goes to a new post, or when a post hasn't been visited in a while, in which case an updated version is saved to cache.

download.png

Step #5 Install Docker

To complete this step you first need to ssh into the EC2 instance. You can read about how to do that here.

Once you're connected to the EC2 instance install Docker. For this step I'll just link a tutorial for installing Docker on Ubuntu. If you're using a different OS search for a tutorial for installing Docker on that OS.

Step #6 Run Docker-SelfSteem

Making sure you're connected to your EC2 instance via ssh first clone the Docker image:

git clone https://github.com/kirkins/docker-selfsteem

Change directory into the new folder:

cd docker-selfsteem

Edit the config.json with your own username, title and author settings. This can be done with any terminal text editor, if you don't know any run nano the easiest to use:

nano config.json

Once you've saved config.json with your information build the image:

sudo docker build -t docker-selfsteem .

Next run the image with:

sudo docker run -d -p 80:8080 docker-selfsteem

Note: You can run multiple instances for different users by running additional containers on different ports for example 8888:8080. You would then need to route additional domains or subdomains to the relevant ports using DNS, and ensure the ports allow incoming requests on your EC2's security group (see step #3).

All done

If you followed the above steps your steem blog should be live on your domain.

Sort:  

Wow, great tutorial. Thanks for sharing this.

Coin Marketplace

STEEM 0.16
TRX 0.16
JST 0.030
BTC 58237.47
ETH 2479.72
USDT 1.00
SBD 2.38