dokku – move wordpress site with duplicator


about dokku

Docker powered mini-Heroku. The smallest PaaS implementation you’ve ever seen.

Dokku allow us to run an app inside docker containers and scale easily -just like heroku does-

We have a microsite made with wordpress which we wanted to move inside dokku. The first thing you need is to install duplicator in your original website, create a package and build it, download the installer.php and the zip file.

We’ll use the dokku-wordpress script to generate the required files. It has the following requirements

A Dokku server. Tested on 0.7.2+
The dokku-mysql plugin
make installed locally
curl or wget installed locally

To install the dokku-mysql plugin just ssh into the dokku server and run

sudo dokku plugin:install mysql

Then clone the dokku-wordpress repository to your local machine, run the command and follow the instructions that are printed in the command line from the last command and take note of the DATABASE_URL when you link the database container

git clone
cd dokku-wordpress
make build APP_NAME=testapp SERVER_NAME=<ip or name>

# run the following commands on the server to setup the app:

dokku apps:create testapp

# setup plugins persistent storage

mkdir -p /var/lib/dokku/data/storage/testapp-plugins
chown 32767:32767 /var/lib/dokku/data/storage/testapp-plugins
dokku storage:mount testapp /var/lib/dokku/data/storage/testapp-plugins:/app/wp-content/plugins

# setup upload persistent storage

mkdir -p /var/lib/dokku/data/storage/testapp-uploads
chown 32767:32767 /var/lib/dokku/data/storage/testapp-uploads
dokku storage:mount testapp /var/lib/dokku/data/storage/testapp-uploads:/app/wp-content/uploads

# setup your mysql database and link it to your app

dokku mysql:create testapp-database
dokku mysql:link testapp-database testapp

# you will also need to set the proper environment variables for keys and salts
# the following were generated using the wordpress salt api:
# and use the following commands to set them up:

dokku config:set testapp AUTH_KEY='Q<z4;VJkx#Jd;tV^d?ex^jwM^z/|b.$w,f4x[/vgCSVXKhZ|aO1p,'
dokku config:set testapp SECURE_AUTH_KEY='>zR1uL02;5+pDRA%HEz!~ty])hV^@;-s-`-rk`W+)zfdeWQ&e=yZM.j)M0Q4}xk1'
dokku config:set testapp LOGGED_IN_KEY=':5W#<&PO*_B7<Cj?7aLrbq|8PoF?2ZR.?_DAki*e3Oh!+RM@Ga@q6:L~(p=!D,SyHwa$B5.Fk'
dokku config:set testapp LOGGED_IN_SALT='xv$Lq]/6bowHaMF@Eff5fL/ab,-pu,P,Jh4U{uiIE~>mog<.O9gDW2+!IOo$M*='
dokku config:set testapp NONCE_SALT='dj8^5?t=V-,nV7}-{*bnz7b7vb.=N1:~BrMC`-D{GLl(k[+}!hh#D[tk#TcG;7|'

# now, on your local machine, change directory to your new wordpress app, and push it up

cd testapp
git push dokku master

then you'll have a vanilla wordpress deployed in dokku.

You should have a directory generated in the cloned folder named after your app, get into it and delete all the files except the following (notice there are hidden files)


copy the files downloaded from duplicator inside this folder and deploy doing a git push dokku

open your app's url pointing to installer.php file and follow the instructions. Use the values from the DATABASE_URL generated earlier, if you didn't take note, you can get it by running the command

ssh -t dokku@<ip or name> config <appname>

use that values for the DB configuration step and continue with the setup.
for example if you have the following DATABASE_URL

the corresponding values would be


done! you should have cloned successfully your wordpress site into dokku.


mySQL – encontrar registros si el id esta en una cadena (columna)

En una tabla de wordpress se guarda un registro donde se concatenan los id’s de las imagenes adjuntas a un tipo de post, por ejemplo


para encontrar los posts (de tipo attachment) que corresponden a estos id’s podemos utilizar la función find_in_set de la siguiente manera

select p.post_title, concat('http://localhost/wp-content/uploads/', m.meta_value) image_url
from wptv_posts p 
join wptv_postmeta m on = m.post_id
where 1 = 1 
and m.meta_key = '_wp_attached_file'
and find_in_set(, 
(select m.meta_value
from wptv_posts p
join wptv_postmeta m on = m.post_id
where 1 = 1
 and = 27116
 and m.meta_key = 'image_to_attach'
 )) &gt; 0

en esta consulta utilizamos primero una subconsulta para encontrar la información ‘meta’, del post que nos interesa, donde estan las referencias a los archivos adjuntos y luego buscamos el atributo ‘_wp_attached_file’ para los registros encontrados para formar la ruta a las imagenes mediante la función concat.

Un ejemplo sin la subconsulta sería el siguiente

select p.post_title, concat('http://localhost/wp-content/uploads/', m.meta_value) image_url
from wptv_posts p 
join wptv_postmeta m on = m.post_id
where 1 = 1 
and m.meta_key = '_wp_attached_file'
and find_in_set(, 
'27954,27955,27956,27958,27960,27962,27964,') &gt; 0

La función find_in_set regresa el índice del elemento si lo encuentra en el arreglo de cadena, por ello filtramos los registros en que es mayor a cero (si se encontró).


Glassfish 4.1.0 disable monitoring on configuration file (domain.xml)

We have a glassfish instance for development purposes in which monitoring was activated on all modules. This caused it to start very slow. We couldn’t access the admin console either because the startup process was failing or taking too long. So, changing the configuration from the admin console wasn’t an option neither from the command line (CLI) with the asadmin command -because it needs the server to be up and running first-

So, you have to disable monitoring from the configuration file prior to attempting to start the server. The file is {jboss-home}/glassfish/domains/domain1/config/domain.xml

look for the lines

        <module-monitoring-levels connector-connection-pool="HIGH" jdbc-connection-pool="HIGH" ejb-container="HIGH" thread-pool="HIGH" jpa="HIGH"></module-monitoring-levels>

and change it to

        <module-monitoring-levels connector-connection-pool="OFF" jdbc-connection-pool="OFF" ejb-container="OFF" thread-pool="OFF" jpa="OFF"></module-monitoring-levels>

or remove them altogether like so


then start the server

asadmin start-domain –verbose


Ubuntu – /boot no space left on device


What to do when there’s no space left on device (boot partition)

First identify your current kernel with

uname -r

then list all other kernel images you have installed (except your current)

dpkg -l linux-{image,headers}-“[0-9]*” | awk ‘/^ii/{ print $2}’ | grep -v -e uname -r | cut -f1,2 -d"-" | grep -e ‘[0-9]’

you can try to remove them with the following command

dpkg -l linux-{image,headers}-“[0-9]*” | awk ‘/^ii/{ print $2}’ | grep -v -e uname -r | cut -f1,2 -d"-" | grep -e ‘[0-9]’ | xargs sudo apt-get -y purge

if that doesn’t work, you could try to remove them manually.

Identify kernel images you may remove with

sudo dpkg –list ‘linux-image*’|awk ‘{ if ($1==”ii”) print $2}’|grep -v uname -r

remove the files with using the older versions and, perhaps, leaving out the last 2 versions for having an option in case you need to boot with a previous kernel

rm -rf /boot/-4.4.0-{47,51,53,57}

fix missing dependencies with

sudo apt-get -f install

and finally clean up with

sudo apt-get autoremove


Ubuntu 16.04 – Rename multiple files

While I was working with a lot of reports, it made sense to use a standard file name for all the files. This was an afterthought, so it required me to rename the files. I was hoping Ubuntu Nautilus had this option, but for my current version -16.04- it doesn’t. That feature is expected to land in 17.04. in the meantime you can install nautilus-renamer which offers the same feature.

Just download the .deb package from the nautilus-renamer launchpad page and install it with

sudo dpkg -i nautilus-renamer_4.0-quantal_all.deb
sudo apt install -f
killall nautilus

It des not work if parent folders contain spaces in their name and it does not support unicode characters. I guess the nautilus version for 17.04 should work with these.

Then, just open a nautilus window and select a bunch of files, right click and select ‘rename…’ or just press F2.



DOKKU – Instalar dokku y ejecutar una aplicación

Dokku es tu propio Heroku, gracias a Docker. Es un servicio de PaaS (Platform as a Service) para que puedas desplegar (deployear) tus aplicaciones de la misma manera que lo haces en Heroku.

Instalar Dokku es muy sencillo, yo lo hice en una máquina virtual con Ubuntu 16.04 siguiendo la documentación

sudo DOKKU_TAG=v0.8.2 bash

Una vez instalado, abres un navegador con la dirección http://localhost para completar la instalación. Puedes dejar los valores por default o modificarlos de acuerdo a tu configuración. Por ejemplo, si no configuras la IP, el valor por default es la IP publica del servidor. Decidí configurar el servidor con una IP estática y ese fue el valor que puse en el instalador. En el campo Public Key debes poner la llave publica de la computadora desde la cual vas a realizar los deployments (tu máquina de desarrollo). Más adelante puedes agregar otras llaves.
Para obtener tu llave pública, si no tienes una, ejecuta el siguiente comando en tu máquina de desarrollo

ssh-keygen -t rsa

y guarda bien el passphrase que escojas.Luego copia el contenido del archivo ~/.ssh/id_rsa al campo Public Key

Una vez terminado ya puedes crear y deployear aplicaciones.

Para crear una nueva aplicación (vamos a utilizar el ejemplo ruby-rails-sample), primero creala en el servidor dokku mediante el comando

dokku apps:create ruby-rails-sample

luego en tu maquina de desarrollo, clona la aplicación (primero debes agregar tu llave publica a tu cuenta de github)

git clone

ingresa en la carpeta y agrega el repositorio remoto

cd ruby-rails-sample
git remote add dokku dokku@{dokku server ip}

sube la aplicación y mira como se inicia con el comando
gzip: stdin: unexpected end of file
! tar: Unexpected EOF in archive

git push dokku master

la primera vez no pude ejecutar la aplicación de manera exitosa, me aparecía un error

gzip: stdin: unexpected end of file
tar: Unexpected EOF in archive

este error esta documentado en la guía de errores y se debe a una conexión a internet lenta. Para solucionarlo, simplemente ejecuta los siguientes comandos en el servidor de dokku

dokku config:set --global CURL_TIMEOUT=600
dokku config:set --global CURL_CONNECT_TIMEOUT=30

y vuelve a publicar tu aplicación

git push dokku master