Skip to content

Loudbooks/CodeBook

Repository files navigation

CodeBook

A fork of PasteBook centered around code.

Prerequisites

Docker. Both the frontend and backend are to be installed with Docker. You can learn more here.

Installation

The following is a guide to get CodeBook running on your system under your domain with SSL. All of this was tested on Ubuntu Linux.

Preparation

Download docker-compose.yml here.

Configuration

Caution

Do not modify docker-compose.yml. You will break things.

Create a file by the name of .env in the same directory as docker-compose.yml. Add the following.

TITLE=
DESCRIPTION=
DISABLE_NEW=
FAVICON_URL=
MAX_PAYLOAD_SIZE=

All of the following are optional. You can leave it all blank, or not even have a .env file at all.

TITLE - The title to be used around CodeBook.

DESCRIPTION - The description to be used in embeds and on the home page of CodeBook.

DISABLE_NEW - Disables the new paste page. API is still accessible.

FAVICON_URL - The URL that the favicon will be provided with.

MAX_PAYLOAD_SIZE - The maximum paste size in megabytes.

Note

If you're testing locally with a numerical IP, you can add the BACKEND_PORT field. Please note that running with a numerical IP is NOT supported. You may run into issues.

Creation

Run the following.

sudo systemctl enable docker
sudo docker compose up -d

Awesome! CodeBook is now running.

Nginx Configuration

In order to run CodeBook under a domain, you will need to use a reverse proxy. The following will serve as a guide to setting up Nginx.

Prerequisites

  • CodeBook is fully installed with the instructions above.
  • A working Nginx installation. Learn more here.
  • A working Certbot installation. Learn more here.

Nginx Preparation

Navigate to /etc/nginx/sites-enabled.

Domain Preparation

You will need to create a DNS A record pointing to your machine with the root and with the api. prefix. I use CloudFlare.

Configuration

Download codebook.conf here and place it in /etc/nginx/sites-enabled.

<DOMAIN> - Change this to your domain name. For example, mine is codebook.dev.

Note

You can easily replace all instances of <DOMAIN> with your domain with the following command. In this example, I used codebook.dev. Make sure to use yours.

DOMAIN=codebook.dev && sudo sed -i "s/<DOMAIN>/${DOMAIN}/g" /etc/nginx/sites-available/codebook.conf

SSL Configuration

Run the following, with <DOMAIN> changed to your domain.

sudo certbot certonly --standalone -d <DOMAIN> -d api.<DOMAIN>

Committing Changes

Run the following.

systemctl restart nginx

Updating CodeBook

Run the following commands in succession.

docker compose stop
docker compose pull
docker compose up -d

Final Notes

Wow. There was a lot that can go wrong there. I'm not an expert. If you need help, you can email me at [email protected] or find me elsewhere.

💜