install dokku, visit in browser to complete install genrate ssh key for github actions/dokku server using ssh-keygen, and copy the private key to the github repo secrets.
dokku apps:create front-end dokku git:initialize front-end dokku git:set front-end deploy-branch main; dokku docker-options:add front-end build --file=/home/dokku/front-end/Dockerfile;
HOOK: vi front-end/hooks/pre-receive
#!/usr/bin/env bash
set -e
set -o pipefail
curl https://raw.githubusercontent.com/KarmaComputing/salon-booking-guru/main/front-end/Dockerfile > /home/dokku/front-end/Dockerfile
cat | DOKKU_ROOT="/home/dokku" dokku git-hook front-end
On local: do first push to trigger initial app build.
git remote add dokku-front-end dokku@:front-end
git push dokku-front-end main
Visit application front-end.dokku.karmacomputing.co.uk
dokku apps:create database dokku git:initialize database dokku git:set database deploy-branch main; dokku docker-options:add database build --file=/home/dokku/database/Dockerfile;
HOOK: vi database/hooks/pre-receive
#!/usr/bin/env bash
set -e
set -o pipefail
curl https://raw.githubusercontent.com/KarmaComputing/salon-booking-guru/main/database/Dockerfile > /home/dokku/database/Dockerfile
cat | DOKKU_ROOT="/home/dokku" dokku git-hook database
On local: do first push to trigger initial app build.
git remote add dokku-database dokku@:database
git push dokku-database main
dokku apps:create api dokku git:initialize api dokku git:set api deploy-branch main; dokku docker-options:add api build --file=/home/dokku/api/Dockerfile;
HOOK: vi api/hooks/pre-receive
#!/usr/bin/env bash
set -e
set -o pipefail
curl https://raw.githubusercontent.com/KarmaComputing/salon-booking-guru/main/api/Dockerfile > /home/dokku/api/Dockerfile
cat | DOKKU_ROOT="/home/dokku" dokku git-hook front-end
On local: do first push to trigger initial app build.
git remote add dokku-api dokku@:api
git push dokku-api main
On the dokku server rebuild:
dokku ps:rebuild api
- generate a key with ssh-keygen
- copy the public key in ~/.ssh/authorized_keys # yes really
- Add the key to dokku
cat ~/.ssh/id_rsa.pub | dokku ssh-keys:add github
dokku@dokku:~$ dokku docker-options:report front-end
=====> front-end docker options information
Docker options build: --file=/home/dokku/salon-booking-guru/front-end/Dockerfile
Docker options deploy: --restart=on-failure:10
Docker options run:
Add to /home/dokku/front-end/hooks/pre-receive
:
mkdir -p /home/dokku/front-end && curl https://raw.githubusercontent.com/KarmaComputing/salon-booking-guru/main/front-end/Dockerfile > /home/dokku/front-end/Dockerfile
If you need to reset / clear the options
- take a copy of all existing settings
dokku docker-options:report front-end
- Clear the options
dokku docker-options:clear
- Add the settings back you want for each stage
e.g.
dokku docker-options:add front-end deploy --restart=on-failure:10
dokku config:set api SALON_BOOKING_GURU_DB_HOST=database.web
dokku config:set api SALON_BOOKING_GURU_DB_PORT=5432
dokku config:set api SALON_BOOKING_GURU_DB_PASSWORD="changeme"
dokku config:set api SALON_BOOKING_GURU_DB_DBNAME="salon_booking_guru"
dokku config:set api SALON_BOOKING_GURU_DB_USER="postgres"
Verify settings:
dokku config:show api
dokku config:set database POSTGRES_PASSWORD="changeme"
dokku config:set database POSTGRES_DB=salon_booking_guru
dokku network:create mynetwork
dokku network:set database attach-post-create mynetwork dokku network:set api attach-post-create mynetwork
dokku ps:rebuild database dokku ps:rebuild api # or must re-push if never previously successful
Warning: This will remove all dokku apps on the dokku server, by force.
dokku apps:list | tail -n +2 | xargs --max-args 1 dokku apps:destroy --force
dokku domains:report