https://blog.ban.app/self-hosting-ghost-with-docker-compose/ * Home * Banano * @ConstiGoeldel * Search Menu Article DevOps Self-hosting my Ghost blog with docker-compose on a Raspberry Pi for free Constantin Goeldel 26 Jun 2022 * 3 min read Quick write-up of setting up this blog. Get the code on Github I've set up personal blogs with WordPress (never doing that again) and Gatsby (nice but I'm not looking into building everything from scratch) so Ghost seemed like the perfect candidate. It's fully open source and built with JavaScript so I can add any features I might find lacking in the future. As I'm a financially-not-so-independent student and into hosting things on my own, I just had to deploy Ghost on my Raspberry Pi. Here's everything you need to to it as quickly as possible: Email Ghost needs access to an email delivery provider for signup and newsletters to work. Ghost recommends using Mailgun which seems fine although their pricing structure is intransparent at times. Sign up at mailgun.com, you'll unfortunately have to add your credit card info although you won't be charged. Afterwards, make sure to cancel their free trial (or set a reminder to do so) as you will be charged 35$/month after the three-month trial period ends. The pay-as-you-go plan includes 1000 free emails a month and will be cheaper for a long time. Then, follow their tutorials to set up your custom domain and take note of your SMTP and API-credentials. If you need to buy a domain, use a registrar like Cloudflare, United Domains or Namecheap as they offer significantly better rates than market leader GoDaddy. Now it's time to set up Ghost itself. Ghost First, make sure to install Docker on your system. I'm running Ubuntu Server on my Pi but any Linux-based distribution will work. When installing Docker, there are many options to choose from; I can recommend the convenience script. curl -fsSL https://get.docker.com -o get-docker.sh sudo sh get-docker.sh Then create a new directory and change into it and add the configuration file: mkdir blog cd blog nano docker-compose.yml If you have git installed, you get also get the file by cloning the gist. git clone https://gist.github.com/a058177bfb5b54f9631c5886d356b7bf.git Add your personal SMTP host, user and password. Then, run docker-compose up -d Depending on your docker installation, you might have to use "docker compose" without the hyphen. Once the container has successfully started, visit localhost:3000/ ghost in your browser to log into the Ghost admin panel. There your can create post, change themes and configure most settings. Make sure to add your Mailgun API-key and domain to enable newsletter sending: Configuring Newsletters Custom domain By now, you should have your own domain, but how do you point it to your newly created newsletter? If you have a static IPv4 or IPv6 address, simply add a new type A record in your DNS settings of your domain registrar and change the port in the docker-compose file to 80. In order to get HTTPS-Encryption, use the exellent Certbot Project. For more advanced setups, have a look at something like the NGINX proxy manager in conjunction with Cloudflare caching. But if you are like me and your Raspberry Pi is sitting behind your router's firewall, you can't use this approach as your IP-address is changing all the time. One great solution is to use a tunnel: Both Ngrok and Cloudflare offer this service, which encrypts and proxies traffic from your domain to your device, even through your router and NAT. Obviously, this opens up an attack vector into your home network so be sure to carefully consider what services you use this for. In my experience, I have found Ngrok to be easier to set up but Cloudflare to be more powerful, so I'll leave the choice up to you. Follow their respective guides to create a tunnel, connect it to your docker container at (per default) port 3333 and point your domain at the other end. One advantage of this approach is that these providers take care of the SSL-Certificate for you and Cloudflare also adds caching and DDOS-protection. Comments I like to have comments on my site but there weren't many great options out there that didn't also cost way too much money or collect a ton of user data. I finally found Commento, which is fully open-source and can also be self-hosted. This is a great guide on how to install it. When it comes to networking, either follow the guids approach or just use a second tunnel pointing to the commento port. After installing, simply include the snippet Commento provides you with in an HTML block. If you have any issues setting this up, let me know in the comments. Otherwise, have fun with your completely free, self-hosted Ghost blog! What do you think? Share Topic DevOps Coding Show Comments Ideas for decentralized computing for everyone Whenever I wanted to deploy my own software projects, there comes a... 16 Jun 2022 [ ] Topics Coding: 4 Madagaskar: 2 DevOps: 2 Constantin Goeldel (c) 2022 * Sign up Published with Ghost * Theme Attila * System theme