GithubHelp home page GithubHelp logo

johanvandegriff / blog.johanv.xyz Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 22 KB

My personal blog

Home Page: https://blog.johanv.xyz/

License: GNU Affero General Public License v3.0

Dockerfile 3.45% Shell 96.55%
writefreely docker dokku bash sed

blog.johanv.xyz's Introduction

blog.johanv.xyz

This is my blog that uses WriteFreely deployed to Dokku.

Here's a blog post describing how I set up my entire website with dokku: How I Created johanv.xyz. I have duplicated the instructions for just the blog subdomain here, and this version will be the one I keep updated. Note: this guide uses johanv.xyz as the domain name, so when following the instructions, just substitute your domain name wherever you see it. Also, let me know if you find a mistake in this documentation.

Installation

Getting a Dokku Server Running

Rent a cloud server

I'm using a DigitalOcean droplet for $5 a month, choosing the operating system image with dokku pre-installed. However, you can just as easily get a Debian based cloud server from any provider and install it yourself. And you can always self-host by installing Debian on an old computer, connecting it to your router, and port forwarding ports 22, 80, and 443 from the router to the computer. There are pros and cons to each approach, which is beyond the scope of this README -- you can find plenty of info online.

Rent a Domain Name

I got johanv.xyz on NameSilo for only a few dollars a year. Then point the domain name to the IP address of your cloud server with a DNS A record. If you are using DigitalOcean, or another provider that can manage DNS records, you can do what I did: point the nameservers of your domain registrar (NameSilo for me) to your cloud provider (DigitalOcean for me). Then the DNS records are managed by DigitalOcean and you can set up the A record there to point to your cloud server.

Install Dokku

Based on this guide.

Update and install Docker, Dokku, and dependencies.

ssh [email protected] #replace this with your server's ip address
apt update
apt dist-upgrade

# Install the prerequisites
apt install -qq -y apt-transport-https

# Install Docker
wget -nv -O - https://get.docker.com/ | sh

# Add Dokku apt repository
wget -nv -O - https://packagecloud.io/gpg.key | sudo apt-key add -
export SOURCE="https://packagecloud.io/dokku/dokku/ubuntu/"
echo "deb $SOURCE trusty main" | sudo tee /etc/apt/sources.list.d/dokku.list
apt update -qq

# Install Dokku, when asked, select YES to enable web setup
apt-get install -qq -y dokku
dokku plugin:install-dependencies --core

#OLD: apt install -qq -y dokku herokuish sshcommand plugn

reboot

Complete the following step as soon as possible, or someone else will eventually! :)

Create an ssh key:

ssh-keygen -b 4096
cat ~/.ssh/id_rsa.pub

To execute dokku commands on the server, you will have to first run ssh-add ~/.ssh/id_rsa locally. You'll have to run this command every time you reboot your local computer.

Go to your domain name in a browser, and you will see a dokku setup page. Copy and paste in the SSH public key (NOT private key) from before. Enter your domain name, and check the box labelled "use virtualhost naming for apps."

Installing the Blog

I followed this tutorial by Evan Walsh.

Clone the Repo

git clone https://gitlab.com/johanvandegriff/blog.johanv.xyz.git

You will want to edit config.ini and change the site's name and URL. I set it to a single-user instance, so you may want to change it back to a multi-user setup.

I also used a bash script to patch the docker image, adding a footer with my email address, among other things. You will want to change the email address to your own, or remove it (I don't want to get random emails because you left it as mine. :) The address is obfuscated, so it's kind of awkward to change, but I have published the PHP code I used to generate it. There are tons of other ways to obfuscate email addresses as well.

Deploy to Dokku

ssh [email protected] apps:create blog

# Set up persistent storage to preserve the database and keys when rebuilding the app:
ssh [email protected] mkdir -p /var/lib/dokku/data/storage/writefreely/{db,keys}
ssh [email protected] chown -R bin:bin /var/lib/dokku/data/storage/writefreely/
#https://github.com/dokku/dokku/issues/2215

ssh [email protected] storage:mount blog /var/lib/dokku/data/storage/writefreely/keys:/go/keys
ssh [email protected] storage:mount blog /var/lib/dokku/data/storage/writefreely/db:/go/db
ssh [email protected] proxy:ports-set blog http:80:8080

# Push the app to Dokku:
git remote add dokku [email protected]:blog
git push dokku master #this build fails

#Now, the site is visible, but it displays an internal error. Initialize the instance:
ssh [email protected] run blog --help
ssh [email protected] run blog --init-db
ssh [email protected] run blog --gen-keys

# And rebuild the app:
ssh [email protected] ps:rebuild blog

# Set up the blog admin password. Put a real password instead of just "password"
ssh [email protected] run blog -create-admin johanv:password

HTTPS with Let's Encrypt

Enable HTTPS, or your admin password for the blog will be sent in plaintext and would be very easy to steal!

Fortunately, Dokku has a nice plugin that makes this easy:

ssh [email protected] dokku plugin:install https://github.com/dokku/dokku-letsencrypt.git
ssh [email protected] letsencrypt:cron-job --add #auto renew certs

Add HTTPS to the blog (replace [email protected] with your actual email):

ssh [email protected] config:set --no-restart blog [email protected]
ssh [email protected] letsencrypt blog

Credits

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.