Arturo Linares

I've been using WSL2 to develop Drupal sites for some months now, and has been a surprise to me how well it works. I have native Linux speed and great tools (I use Sublime through X server and VS Code).

Read more...

I'm using the game bar to create quick screencasts. The only problem is that the videos are too big to show only a few clicks. So, to quickly optimize a video for sharing I need to transcode it as easy as possible.

Creating a context menu in explorer would be ideal. This menu action will execute VLC to transcode the video.

I'm using this tool to easily create a context menu:

FileActionsManager

The paths need to be adjusted we're on Windows and VLC is a ported application. So I wrote a script to handle that (in PHP because I have it installed it and I don't know anything about PowerShell):

if (!isset($argv[1])) {
  echo "Usage: {$argv[0]} <video>";
  die;
}
$path = $argv[1];
$path = str_replace('\\', '/', $path);
$path = preg_replace('/^C:/', '', $path);

$cmd = <<<CMD
"C:\\Program Files\\VideoLAN\\VLC\\vlc.exe" "-I dummy" "%s" ":sout=#transcode{vcodec=h264,scale=Automático,width=720,acodec=mpga,ab=128,channels=2,samplerate=44100,scodec=none}:std{access=file{no-overwrite},mux=mp4,dst='%s-small.mp4'}" "vlc://quit"
CMD;
$cmd = sprintf($cmd, $argv[1], $path);
system($cmd);

To actually create the menu entry that runs the php script, run:

FileActionsConsole.exe add mp4 compress_video "Compress Video (720p)" "\"C:\tools\php74\php.exe\" \"/Users/user/bin/compress-video.php\" \"%1\
""

TL;DR: Needed a way to easily deploy and manage legacy and new sites without spending a lot of money. Dokku gives me the awesome Heroku developer experience on a cheap VPS box.

Since I started working on the web, I've been publishing small sites. Usually I use these pet projects to try out new technologies, so most of them don't share the same technology. Some are almost 10 years old. Of course, I don't have the time to maintain them and their owners are not interested in spend more resources to bring them up-to-date. So I'm stuck maintaining the hosting for very different projects.

To save on expenses and time I used to host them all in one cheap VPS, but things were becoming complicated as language versions become deprecated. Keeping them in a shared environment is a challenge because different applications use different versions of PHP, databases (some use mysql, others Postgres). I even have .NET core sites running.

This year I decided to find a better solution, where I can keep all together and still make it easy to deploy or create resources on the server. So I tried Azure, AWS, Heroku and several others.

The best ones, of course, were not cheap. I think Heroku is still one of the best one in terms of developer experience. So looking around I came to know Dokku, which is an open source platform similar to Heroku (and it even uses their Buildpacks).

What's in a Buildpack

Heroku works using Buildpacks. You can picture them as the instructions on how to build and deploy an application. Dokku use these Buildpacks too to create container images and run them.

But, what about the ones with specific requirements? I have some sites that require wkhtmltopdf. Well, it turns out that it is possible to customize the image that Dokku builds by using deploy scripts that run at different stages in the deployment process.

OK, How does it look like?

To deploy a new PHP application that uses a MySQL database, this would be enough (assuming you installed and configured the Dokku bash client):

# Create a database
dokku mysql:create myphp_db
# Create a new application
dokku apps:create myphp_app
# Allow the application access the database
dokku mysql:link myphp_db myphp_app
# Deply the application
git push dokku master

Dokku identifies it is a PHP application if it finds a composer.json file. In it, you can specify the PHP version to use and if you need special extensions, like bcmath.

For example:

"require": {
  "php": ">=7.1",
  "ext-bcmath": "*"
}

You can then configure your PHP application to read the database connection details using environment variables. Once a database is linked to your application you will have in the DATABASE_URL environment variable a full DSN to connect to it. If you need to, you can declare more environment variables like this, not necessarily related to the database:

dokku config:set MYSQL_DBNAME=myphpapp MYSQL_USERNAME=mysql ...

Advantages

  1. The developer experience. It allows me to manage sites and its resources without leaving the terminal. The experience is very similar to Heroku.

  2. It can be fully automated. For example, pulling database dumps to a development environment, schedule nightly backups and SSL certificate renewals.

  3. Zero downtime deployments.

Kubernetes

But... Dokku works using docker... that's so 2014. Dokku is already working on Kubernetes support (and should be functional at this point), although I don't mind to use and old technology if it works. However, I wish it could use podman to avoid the security risk of having a docker daemon running.

#devops

I normally work on different and very active projects in several testing environments. I needed a simple and fast way to generate visual regression tests between them, or even to just to compare my local environment to an integration server. However, it was cumbersome to edit backstop configuration files frequently just to change servers, thus I created a tool that simplifies the task a lot:

https://github.com/arturolinares/easy-vrt

Read more...

#git

Some useful commands to find commits using Git:

Read more...

Surfae Duo

This week Microsoft unveiled their Surface Phone, called Surface Duo. It looks great and I think it puts the company back in the innovators list.

Read more...

I started having some issues when using git inside a Linux VM while setting up an experimental Drupal development environment. I wasn't able to clone repositories because I was getting some errors saying the remote host hanged unexpectedly, or couldn't push changes. However I was able to clone shallow repos, but strangely Bitbucket and Gitlab seemed to be more prone to these errors.

Read more...

#drupal

Recently I wrote on how I replaced my MacBook Pro with a PC and still being productive when developing on several Drupal environments.While Pop_OS! is a wonderful Linux distro, I decided to give Windows a try. The primary reasons were the usual: hardware.

Read more...

A common request I’ve received lately when building sites in Drupal is to make the background of the page title configurable to allow the user upload and change it.

Read more...

Last time I tried to create from scratch a Drupal instance that used a Solr server wasn’t as easy as I expected. Maybe command line tools for installing modules have spoiled me and I just expected that running something like drupal module:install solr would configure everything for me.

Here is how I made it work, but please consider I’m not a Solr expert. If you know a better way to do this please let me know.

Read more...