Skip to content
Daoud Clarke edited this page Jul 31, 2022 · 7 revisions

You will need a webserver with root access.

wget https://raw.githubusercontent.com/dokku/dokku/v0.27.7/bootstrap.sh
DOKKU_TAG=v0.27.7 bash bootstrap.sh
  • Set up SSH key and domain:
# usually your key is already available under the current user's `~/.ssh/authorized_keys` file
cat ~/.ssh/authorized_keys | dokku ssh-keys:add admin

# you can use any domain you already have access to
# this domain should have an A record or CNAME pointing at your server's IP
dokku domains:set-global <YOUR_DOMAIN>

# you can also use the ip of your server
dokku domains:set-global <YOUR_IP_ADDRESS>
  • Set secrets:
dokku config:set api.mwmbl.org MWMBL_APPLICATION_KEY=<S3_APPLICATION_KEY> MWMBL_KEY_ID=<S3_KEY_ID>

The secrets are the keys for storing data in long-term storage, which needs to implement S3 interface (currently we are using Backblaze).

  • Install and configure Postgresql, ensuring to set shared memory to 1g:
dokku plugin:install https://github.com/dokku/dokku-postgres.git postgres
dokku postgres:create mwmbl-database -s 1g
dokku postgres:link mwmbl-database api.mwmbl.org
  • From your local machine, in a local copy of the git repo:
git remote add dokku dokku@<REMOTE_DOMAIN_OR_IP_ADDRESS>:api.mwmbl.org
git push dokku master

This should deploy master to your remote machine.

  • Set up storage
mkdir /data
dokku storage:mount api.mwmbl.org /data:/app/storage

Debugging

  • On the remote machine, check the logs to see it is working:
dokku logs api.mwmbl.org -t
  • Start an interactive shell on the remote machine and get the database URL:
docker exec -it api.mwmbl.org.web.1 /bin/bash
  • In the running Docker image
apt install postgresql-client
  • Get the database URL from the running Docker image:
echo $DATABASE_URL
  • Directly run postgres client on the Docker image
docker exec -e PGPASSWORD=<PASSWORD> -it api.mwmbl.org.web.1 psql -h dokku-postgres-mwmbl-database -U postgres mwmbl_database

Setting up SSL

dokku plugin:install https://github.com/dokku/dokku-letsencrypt.git
dokku letsencrypt:enable api.mwmbl.org