Skip to content

Instantly share code, notes, and snippets.

@trueqap
Created May 10, 2025 08:32
Show Gist options
  • Save trueqap/8fbed42b44a5f9d974d1d4980e3f080c to your computer and use it in GitHub Desktop.
Save trueqap/8fbed42b44a5f9d974d1d4980e3f080c to your computer and use it in GitHub Desktop.
Talos Manager Installation on Dokku

Talos Manager Installation on Dokku

This guide describes how to deploy the Talos Manager application on Dokku using the official Docker Image.

Prerequisites

  • A server running Dokku (min. v0.28.0)
  • Dokku Postgres plugin installed
  • Dokku Letsencrypt plugin installed (if you want SSL)
  • SSH access to your Dokku server

1. Installing the Postgres plugin (if not already installed)

sudo dokku plugin:install https://github.com/dokku/dokku-postgres.git

2. Installing the Letsencrypt plugin (if not installed and you want SSL)

sudo dokku plugin:install https://github.com/dokku/dokku-letsencrypt.git

3. Creating the application and database

# Create the application
dokku apps:create talos-manager

# Create and link the Postgres database
dokku postgres:create talos-manager-db
dokku postgres:link talos-manager-db talos-manager

4. Creating an SSH key for bootstrapping

Talos Manager requires an SSH key for bootstrapping servers. Create and configure it:

# Generate SSH key in PEM format
ssh-keygen -m PEM -t rsa -b 4096 -P "" -f ~/.ssh/talos-manager.pem -C talos-manager

# Add the public key to the appropriate places
# 1. Hetzner Robot: https://robot.hetzner.com/key/index -> New key
# 2. Hetzner Cloud: https://console.hetzner.cloud/ -> Select Project -> Security -> Add SSH Key

5. Setting up the Docker image and environment variables

# Function to generate random strings for secrets
function random_string() { 
  cat /dev/urandom | LC_ALL=C tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1
}

# Set up the official Docker image
dokku docker-options:add talos-manager deploy,run "--pull=always"
dokku git:from-image talos-manager reclaimthestack/talos-manager:latest

# Configure Rails environment variables
dokku config:set talos-manager \
  RAILS_ENV=production \
  RAILS_MAX_THREADS=20 \
  SECRET_KEY_BASE=$(random_string) \
  AR_ENCRYPTION_PRIMARY_KEY=$(random_string) \
  AR_ENCRYPTION_DETERMINISTIC_KEY=$(random_string) \
  AR_ENCRYPTION_KEY_DERIVATION_SALT=$(random_string)

# Hetzner Cloud API token (if you're using Hetzner cloud servers)
dokku config:set talos-manager HETZNER_CLOUD_API_TOKEN=<hetzner-cloud-api-token>

# Hetzner webservice API credentials (if you're using dedicated servers)
dokku config:set talos-manager HETZNER_WEBSERVICE_USER=<username> HETZNER_WEBSERVICE_PASSWORD=<password>

# Set the application host
dokku config:set talos-manager HOST=<your-dokku-domain>

# Add the SSH private key for bootstrapping (base64 encoded, without line breaks)
dokku config:set --encoded talos-manager SSH_PRIVATE_KEY="$(base64 -w0 ~/.ssh/talos-manager.pem)"

# Set HTTP basic auth password to protect the app
dokku config:set talos-manager BASIC_AUTH_PASSWORD=$(random_string)

6. Setting up the domain and deploying

# Add your domain
dokku domains:add talos-manager <your-domain>

# Deploy the application
dokku ps:restart talos-manager

7. Setting up SSL (optional)

# Set email for Let's Encrypt notifications
dokku config:set --global DOKKU_LETSENCRYPT_EMAIL=<your-email>

# Enable SSL
dokku letsencrypt:enable talos-manager

# Set up auto-renewal
dokku letsencrypt:auto-renew talos-manager

8. Setting up system-wide auto-renewal

# Set up cron job
ssh root@<your-dokku-server> "dokku letsencrypt:cron-job --add"

Upgrading the Version

To upgrade the Talos Manager version:

# Upgrade to a specific version
dokku git:from-image talos-manager reclaimthestack/talos-manager:<version>

# Or always use the latest version
dokku git:from-image talos-manager reclaimthestack/talos-manager:latest

Troubleshooting

Database Issues

If you encounter problems with database migrations, you can reset the database:

# Stop the application
dokku ps:stop talos-manager

# Delete and recreate the database schema
dokku postgres:connect talos-manager-db -c 'DROP SCHEMA public CASCADE; CREATE SCHEMA public;'

# Load the schema
dokku run talos-manager bundle exec rails db:schema:load DISABLE_DATABASE_ENVIRONMENT_CHECK=1

# Restart the application
dokku ps:start talos-manager

Viewing Logs

# View application logs
dokku logs talos-manager

# Continuously monitor logs
dokku logs talos-manager -t

Useful Commands

# Restart the application
dokku ps:restart talos-manager

# Stop the application
dokku ps:stop talos-manager

# Start the application
dokku ps:start talos-manager

# List environment variables
dokku config:show talos-manager
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment