/pre-dokku-server-setup

Initial Ubuntu VPS server setup prior to installation of Dokku

Primary LanguageShellMIT LicenseMIT

Ubuntu Server Setup for Dokku

Initial Ubuntu VPS server setup prior to installation of Dokku.

ShellCheck last commit Commitizen friendly License

Introduction

This script uses Jason Hee's excellent Ubuntu setup script as a starting point for provisioning Ubuntu Servers in preparation for installation of Dokku.

Why not just use Jason Hee's script ๐Ÿค”?

Jason Hee's script is perfect! What this script does is that it adds a bunch of extra useful things such as ...

... so if you're not interested in these things and just want to quickly get up and running with Dokku, then use Jason Hee's script.

Note: the script doesn't install Dokku, you have to restart the server after running this script, and login as the newly created user, then install Dokku like this:

# v0.27.6 was the latest tag at the time this README was initially written
# change to whatever the latest version will be when you read this
wget https://raw.githubusercontent.com/dokku/dokku/v0.27.6/bootstrap.sh && \
sudo DOKKU_TAG=v0.27.6 bash bootstrap.sh

Getting Started

  1. spin up a VPS using your preferred service provider (DigitalOcean, Hetzner, Linode, Vultr, etc.), ensuring that you

    • set the server's hostname to the domain that you'll be using as global domain on Dokku. This will ensure /etc/hostname and the hostname command respond correctly (something Dokku relies on).
    • specify an SSH key when bootstrapping your VPS
  2. Configure DNS.

    • You'll need an A record for the naked domain (the "@" one) pointing to your IP with the lowest TTL possible
    • You'll need a wildcard A record (use '*') pointing to your IP with the lowest TTL possible
  3. SSH into your server, clone this repository (& submodules) into your home directory, and run the setup script:

    cd ~
    git clone --recurse-submodules https://github.com/engineervix/pre-dokku-server-setup.git \
    && cd pre-dokku-server-setup \
    && bash setup.sh

    Note: If you run the script with no arguments, it will neither setup postfix on your server nor download texlive-full. The following optional arguments are available (for help, you can simply run bash setup.sh -h or bash setup.sh --help):

    --mailjet   # setup postfix with MailJest
    --sendgrid  # setup postfix with Sendgrid
    --texlive   # install texlive-full

    Note: if you select both --mailjet and --sendgrid, the script will terminate with an exit 1 code, and you'd have to try again.

When the setup script is run, you will be prompted

  • to enter the username of the new user account

  • to add a public ssh key (which should be from your local machine) for the new account. You can display it on your local terminal via (assuming it's called id_rsa.pub and it's in the ~/.ssh/ directory.

    Feel free to change the path / name if you saved it in a different location / named it differently) ...

    cat ~/.ssh/id_rsa.pub

    ... then copy it and paste it in the terminal on your server.

    Note ยป If you don't have an existing key and you would like to generate one, or perhaps you already have one and would like to generate another ssh key from your local machine:

    ssh-keygen -t ed25519 -C "your_email@example.com"
  • to specify a timezone for the server. It will be set to 'Africa/Lusaka' if you do not specify a value.

  • When setting up Postfix and configuring System Updates and Notification Settings, you'll be asked for

    • the System Administrator's email address (to receive notifications)
    • the email address that'll be associated with sending emails. You need to use a Mailjet OR Sendgrid verified email address for this.

    This script assumes that the email address you supply is associated with your Mailjet/Sendgrid domain. myhostname is therefore extracted from this email address. So, if your "mail_from" email address is josh@example.co.zm, then example.co.zm will be used as myhostname in the Postfix setup.

Post setup actions

Supported Ubuntu versions

Jason Hee's excellent Ubuntu setup script has been tested against Ubuntu 14.04, Ubuntu 16.04, Ubuntu 18.04, Ubuntu 20.04 and 22.04. However, this project primarily targets Ubuntu 20.04 and Ubuntu 22.04 (It'll most likely also work on 18.04).

Running tests

Tests are run against a set of Vagrant VMs. To run the tests, run the following in the project's directory:

./tests/tests.sh

Author

๐Ÿ‘ค Victor Miti

Contributing ๐Ÿค

Contributions, issues and feature requests are most welcome!

Feel free to check the issues page and take a look at the contributing guide before you get started

Show your support

Please give a โญ๏ธ if you found this project helpful!

License ๐Ÿ“

Copyright ยฉ 2022 Victor Miti.

This project is licensed under the terms of the MIT license.