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 next feature release of phpBB 3 will be 3.3/Proteus.
Forum rules
Please do not post support questions regarding installing, updating, or upgrading phpBB 3.2.x. If you need support for phpBB 3.2.x please visit the 3.2.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: 27
Joined: Wed Aug 20, 2014 4:50 pm
Location: Belgium

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

Post by martti » Mon Apr 23, 2018 7:00 am

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: 1781
Joined: Thu Mar 02, 2006 4:29 pm
Location: Earth
Contact:

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

Post by DavidIQ » Mon Apr 23, 2018 8:25 pm

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: 734
Joined: Tue Nov 01, 2005 9:50 pm
Location: Milano (I) Frankfurt (D)
Contact:

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

Post by 3Di » Tue Apr 24, 2018 9:18 am

Want to compensate me for my interest? Don't ask me, just do it
I'm available for custom phpBB jobs, you can PM me the details.
New: my Live Board, Extensions and Tools for phpBB - Men at works.

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

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

Post by martti » Thu Apr 26, 2018 8:38 am

That's great!

Post Reply