Deploy PostgREST to Dokku

Create a new app

dokku apps:create pgrest-myproject

Add a port mapping from 3000 (PostgREST container) to 80 (host).

dokku ports:add pgrest-myproject http:80:3000

Create a new PostgreSQL database using the dokku-postgres plugin and link it to our project.

dokku postgres:create pgrest-myproject
dokku posgres:link pgrest-myproject pgrest-myproject

A new environment variable will be created:

=====> pgrest-myproject
DATABASE_URL: postgres://postgres:alongpass@dokku-postgres-pgrest-myproject:5432/pgrest_myproject

But we need to define the same value in a variable named PGRST_DB_URI so PostgREST can access the database.

dokku config:set pgrest-myproject PGRST_DB_URI="postgres://postgres:alongpass@dokku-postgres-pgrest-myproject:5432/pgrest_myproject"

Pull and deploy the Docker image from dockerhub.

docker pull postgrest/postgrest:latest
docker tag postgrest/postgrest:latest dokku/postgrest:latest
dokku git:from-image pgrest-myproject dokku/postgrest:latest

Add a Let’s Encrypt TLS certificate with the Dokku letsencrypt plugin.

dokku letsencrypt:set pgrest-myproject email <your-email>
dokku letsencrypt:enable pgrest-myproject

Ubuntu Desktop personal setup

This is how I customize a clean Ubuntu install.

Essentials

First we install the essentials.

sudo apt install curl vim fish tmux

SSH keys

ssh-keygen -t ed25519 -C "user@domain.com"

Copy public key to paste as needed:

xclip -sel clip < ~/.ssh/id_ed25519.pub

Folder structure

Update the folder structure. Basically changing the defaults locations of folders like ~/Downloads and ~/Desktop.

Create new folders.

cd ~
mkdir work dl docs media tpl pub \
  media/{music,books,pics,vids,screens,torrents}

Make Ubuntu use our new folders. Edit ~/.config/user-dirs.dir and update the file so it looks like this:

XDG_DESKTOP_DIR="$HOME/desk"
XDG_DOWNLOADS_DIR="$HOME/dl"
XDG_TEMPLATES_DIR="$HOME/tpl"
XDG_PUBLICSHARE_DIR="$HOME/pub"
XDG_DOCUMENTS_DIR="$HOME/docs"
XDG_MUSIC_DIR="$HOME/media/music"
XDG_PICTURES_DIR="$HOME/media/pics"
XDG_VIDEOS_DIR="$HOME/media/vids"

Fish configuration

Make fish the default shell

Install Fisher.

Install z:

fisher install jethrokuan/z

Ubuntu configuration

Add Spanish:

  • Settings
    • Region & Language
    • Input Sources
    • Add Spanish
  • Appearance
    • Dark
    • Dock
      • Auto-hide the Dock: On
      • Position on screen: Bottom

Install GNOME tweaks

sudo apt install gnome-tweaks

With GNOME Tweaks activate:

  • Top Bar
    • Activities Overview Hot Corner
    • Battery Percentage
    • Weekday
  • Workspaces
    • Static Workspaces
      • Number of Workspaces: 5
      • Workspaces span displays

GNOME Terminal configuration

Download and install the Dracula theme for GNOME Terminal.

Restart your terminal to reflect the changes.

Tmux configuration

Update ./config/tmux/tmux.conf:

set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'dracula/tmux'
set -g @dracula-plugins 'git, network-ping, attached-clients, network-vpn, weather, time'
set -g @dracula-show-left-icon 'uwu'

run -b '~/.tmux/plugins/tpm/tpm'

Install Node

Install n:

curl -L https://git.io/n-install | bash

Install Python

Install pyenv using pyenv-installer.

Be sure to install the build environment dependencies:

  • https://github.com/pyenv/pyenv/wiki#suggested-build-environment

Install poetry.

How to resize a disk on Ubuntu server 20.04

I had an issue with my Thinkpad x220; when I installed Ubuntu, I had only 100GB available out of 1000 GB. So it ran out of available space quickly.

To resize to all the space available, I ran these commands:

lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv

resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv

Sources: