Skip to content

Personal blog website with Markdown using a NextJS frontend and Axum (Rust) backend

Notifications You must be signed in to change notification settings

JorianWoltjer/jorianwoltjer.com

Repository files navigation

Personal blog website with Markdown using a NextJS frontend and Axum (Rust) backend

Setup

A .env file should be created with two strong randomly generated passwords for the database. The 'internal token' variable should only contain alphanumeric characters.

The following environment variables are required to use BuildKit with docker-compose:

export DOCKER_BUILDKIT=1
export COMPOSE_DOCKER_CLI_BUILD=1

Then running the following command will build and start the containers (note that it takes a few minutes to fully start up):

docker-compose up -d --build

# View logs temporarely
docker-compose logs --tail=10 --follow

Finally, use the password.sh script to set a strong password for logging in as an Admin.

See this gist to see how I automatically pull changes from GitHub push webhooks.

Development

Rebuild only one specific container while running:

docker-compose up --build --force-recreate --no-deps -d backend

Run database server for testing

docker run --name postgres-dev -p 5432:5432 -e POSTGRES_PASSWORD=postgres -d postgres

Run and create tables on local database

sqlx database drop && sqlx database create && sqlx migrate run

Transfer old MySQL data to new PostgreSQL format:

SELECT id, parent, url as slug, title, description, COALESCE(icon, img) as img, timestamp FROM folders;
SELECT id, title, text, img, href, category FROM projects;
SELECT id, url as slug, title, description, img, markdown, timestamp, parent as folder, points, views, featured, (hidden IS NOT NULL) as hidden FROM posts;
SELECT post as post_id, tag as tag_id FROM post_tags;

-- replace strings in *.sql files:
$ sed "s/\\\\'/''/g" | sed 's/\\"/"/g' | sed "s/\\\\r/'||chr(13)||'/g" | sed "s/\\\\n/'||chr(10)||'/g" | sed 's/\\\\/\\/g' | sed 's/\/img\/blog\///g'
-- *manually remove ` backticks from statements*
-- *manually set featured and hidden to ::bool*

Scripts

  • revalidate.sh: Revalidate a custom URL on the frontend
  • sign.sh: Create a HMAC signature for a specific hidden blog post ID

Resources

This website is a successor to my original jorianwoltjer.com (PHP) repository.