- This document references this post with a few updates regarding the git remote set up
- set up digital ocean droplet w/ dokku installed
- add ssh key
ssh-keygen -t rsa
- with proper dns configured w/ url: (first set up the url by following these directions)
- go to your droplet's IP address and give the app url your hostname
- add two A records, (
@
and*
) to direct the url to your IP address (this can be done w/ digital ocean's dns or with the dns managing the domain. For staging, you'll only need to set up one A record pointing towards your subdomain)
- in repo of project:
- add
.env
file with:BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-php
- update as of Feb 22, 2019: the
.env
file seems to undercut the git remote setup. Instead, you can use dokku to setup your buildpack:dokku config:set <appname> BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-php
, just remember to rebuild ($ dokku ps:rebuild APPNAME
). For reference, see the last response here
- update as of Feb 22, 2019: the
- add
Procfile
file with:web: vendor/bin/heroku-php-apache2 -i custom_php.ini
- add
custom_php.ini
file with:
extension=mbstring.so
memory_limit=512M
cgi.fix_pathinfo = 0;
upload_max_filesize = 40M
post_max_size = 41M
- add
.htaccess
file modified with (as of kirby v3, you can use the generated .htaccess too):
# Kirby .htaccess
# rewrite rules
<IfModule mod_rewrite.c>
# enable awesome urls. i.e.:
# http://yourdomain.com/about-us/team
RewriteEngine on
# make sure to set the RewriteBase correctly
# if you are running the site in a subfolder.
# Otherwise links or the entire site will break.
#
# If your homepage is http://yourdomain.com/mysite
# Set the RewriteBase to:
#
# RewriteBase /mysite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)\.([0-9a-z]{32})\.(js|css)$ $1.$3 [L]
# block text files in the content folder from being accessed directly
RewriteRule ^content/(.*)\.(txt|md|mdown)$ index.php [L]
# block all files in the site folder from being accessed directly
RewriteRule ^site/(.*) index.php [L]
# block all files in the kirby folder from being accessed directly
RewriteRule ^kirby/(.*) index.php [L]
# make panel links work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^panel/(.*) panel/index.php [L]
# make site links work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php [L]
</IfModule>
# Add caching
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 10 days"
ExpiresByType text/css "access plus 1 week"
ExpiresByType text/plain "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 week"
ExpiresByType application/x-icon "access plus 1 year"
</IfModule>
# Additional recommended values
# Remove comments for those you want to use.
#
# AddDefaultCharset UTF-8
#
# php_flag short_open_tag on
- add
composer.json
file with:{ "require": { "php": "~5.6.23", "ext-mbstring": "*", "ext-gd": "*" } }
- install composer
- run
composer update
orphp composer.phar update
- add a git Remote
$ git remote add production dokku@SERVERIP:APPNAME
where SERVERIP and APPNAME are your digital ocean droplet IP and app titles- if you have other ssh's, you will need to set up your ~/.ssh/config file:
this will allow git to know which SSH key to useHost SERVERIP User dokku Hostname SERVERIP IdentityFile ~/.ssh/YOURSSHPRIVATEKEY
git push production
will push to your remote- if you get errors, ssh into your droplet (
ssh root@SERVERIP -i ~/.ssh/YOURSSHPRIVATEKEYPATH
) and turn on TRACEdokku trace on
- Persistent storage for your content folder and panel:
- ssh in (
ssh root@SERVERIP -i ~/.ssh/YOURSSHPRIVATEKEYPATH
) - for general (technically content and accounts wont overwrite each other):
$ dokku storage:mount APPNAME /var/lib/dokku/data/storage:/app/content
$ dokku storage:mount APPNAME /var/lib/dokku/data/storage:/app/site/accounts
- for more specific:
$ dokku storage:mount APPNAME /var/lib/dokku/data/storage/content:/app/content
$ dokku storage:mount APPNAME /var/lib/dokku/data/storage/accounts:/app/site/accounts
- then,
$ dokku ps:rebuild APPNAME
- further info on persistant storage can be found here. Recommedned for kirby to do persistant storage for:
- app/content
- app/site/accounts
- app/site/config
- app/assets/fonts
once you're done (and before you can properly view your site), you will need to ssh/sftp in and setup the base files (i.e. the
app/config/config.php
,app/content/site.txt
, and the font files)
- HTTPS?
- dokku plugin for let's encrypt, or the Medium Article.
- also, dont forget to add your regular domain
dokku domains:add YOURAPPNAME YOURDOMAIN.COM
before encrypting!
- due to updates, the
custom_php.ini
file may be overridden by dokku'snginx.conf
file (limiting maximum file size). A work around was posted here and essentially outlines the following code:
### Customizing via configuration files included by the default templates
The default nginx.conf- templates will include everything from your apps `nginx.conf.d/` subdirectory in the main `server {}` block (see above):
include $DOKKU_ROOT/$APP/nginx.conf.d/*.conf;
. That means you can put additional configuration in separate files, for example to limit the uploaded body size to 50 megabyte, do
mkdir /home/dokku/APPNAME/nginx.conf.d/
echo 'client_max_body_size 50M;' > /home/dokku/APPNAME/nginx.conf.d/upload.conf
chown dokku:dokku /home/dokku/APPNAME/nginx.conf.d/upload.conf
service nginx reload
(taken from https://github.com/dokku-alt/dokku-alt/issues/195#issuecomment-75092205).
-
digital ocean occasionally has packages you need to update. reference here
sudo apt-get update && sudo apt-get dist-upgrade
-
As of 3/16/2020: New changes in heroku buildpack with php's new
7.4.3
version mean that we also have to add a custom buildpack step to our process. Notes found here,and here but essentially:
dokku buildpacks:add <APPNAME> https://github.com/heroku/heroku-buildpack-apt
dokku buildpacks:add <APPNAME> https://github.com/heroku/heroku-buildpack-php.git
# and to view:
dokku buildpacks:list <APPNAME>
-
You'll want to remove the
BUILDPACK_URL
set in thedokku config:list <APPNAME>
config -
then you'll need to add an
Aptfile
with:
libonig-dev
libonig4
Then restart the dokku app with the dokku ps:rebuild <APPNAME>
command from above.
(May 15, 2020) Additionally, you'll want to update herokuish to circumvent this problem (Needs to be tested whether we need the steps above w the buildpacks
command or if it can be done without)
docker rmi gliderlabs/herokuish:latest --force
docker pull gliderlabs/herokuish:latest