Deployment with Git on a PaaS (i.e. Dokku)

General discussion of development ideas and the approaches taken in the 3.x branch of phpBB. The current feature release of phpBB 3 is 3.3/Proteus.
Forum rules
Please do not post support questions regarding installing, updating, or upgrading phpBB 3.3.x. If you need support for phpBB 3.3.x please visit the 3.3.x Support Forum on phpbb.com.

If you have questions regarding writing extensions please post in Extension Writers Discussion to receive proper guidance from our staff and community.
Post Reply
User avatar
martti
Registered User
Posts: 45
Joined: Wed Aug 20, 2014 4:50 pm
Location: Belgium

Deployment with Git on a PaaS (i.e. Dokku)

Post by martti »

phpBB nowadays is much geared towards shared hosting:
  • Without access to the CLI.
  • Uploading files yourself (including everything in /vendor).
However, these days it has become cheap and easy to set up your own VPS in the cloud and do deployments wit Git. This can be done for example by installing Dokku on your VPS. Dokku provides Heroku-style git deployments but is a open source, single server PaaS variant.
Deploying a new version of phpBB becomes then as easy as pulling the latest version of phpBB with Git and then pushing it to your VPS. Composer runs on the VPS post-push to install everything in /vendor directory. Additionally, you can define in composer the entire PHP environment. (PHP version and PHP extensions) and Dokku (or simular) will take care of providing it.

1.) Dokku, Heroku and Symfony (nowadays) discourage you to store any configuration (config.php) in a file but highly suggest environment variables for security and ease. (See the links)

Usually, (Dokku, Heroku, Symfony) the environment variable for connecting to the database is called DATABASE_URL. You don't have to copy paste any password and username, host, port and database name.

I did a test with Dokku yesterday with a fresh install and I modified my config.php to:

Code: Select all

<?php

$parsed = parse_url(getenv('DATABASE_URL'));

$dbms = 'phpbb\\db\\driver\\postgres';
$dbhost = $parsed['host'];
$dbport = $parsed['port'];
$dbname = trim($parsed['path'], '/');
$dbuser = $parsed['user'];
$dbpasswd = $parsed['pass'];
$table_prefix = 'phpbb_';
$phpbb_adm_relative_path = 'adm/';
$acm_type = 'phpbb\\cache\\driver\\file';

@define('PHPBB_INSTALLED', true);
@define('PHPBB_DISPLAY_LOAD_TIME', true);
@define('DEBUG', true);
@define('DEBUG_CONTAINER', true);
It felt somehow retarded I was forced to set the database credentials manually with the install script only to remove them later to replace it with my own config.php which reads the DATABASE_URL directly.
You can't set the config.php beforehand and then generate the tables. The install script wants to write the config.php itself. Maybe install with a CLI command (without generating config.php) would be a good addition?
Note: the install script forced me to set a table prefix. Why can't it be left without prefix?

2.) Storage of files: Dokku and other Heroku style PaaS use a ephemeral file system (see the links). Every deployment an entirely new docker container gets launched with only the files that are present in the git repository. All files that were uploaded to the local filesystem are destroyed (i.e. attachments). So you can't use the local filesystem for storing files except for cache files. It would be better if phpBB is storage agnostic. This extension seems to provide a solution if you want to use AWS S3. (See the link of the extension for a good explanation why storage should be agnostic).

Looking forward your comments.

User avatar
DavidIQ
Customisations Team Leader
Customisations Team Leader
Posts: 1904
Joined: Thu Mar 02, 2006 4:29 pm
Location: Earth
Contact:

Re: Deployment with Git on a PaaS (i.e. Dokku)

Post by DavidIQ »

1.) There is a install/phpbbcli.php script for that it looks like.
2.) https://tracker.phpbb.com/browse/PHPBB3-15649 (although that doesn't take care of the other directories, although I'm pretty sure there is merged work for allowing to change those in 3.3/master branch)
Image

User avatar
3Di
Registered User
Posts: 951
Joined: Tue Nov 01, 2005 9:50 pm
Location: Milano 🇮🇹 Frankfurt 🇩🇪
Contact:

Re: Deployment with Git on a PaaS (i.e. Dokku)

Post by 3Di »

🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades

User avatar
martti
Registered User
Posts: 45
Joined: Wed Aug 20, 2014 4:50 pm
Location: Belgium

Re: Deployment with Git on a PaaS (i.e. Dokku)

Post by martti »

That's great!

Post Reply