Build i3-gaps in Docker

Automated way

So, the very automated way:

1
2
3
git clone git@github.com:mgor/docker-ubuntu-i3-gaps-builder.git
cd docker-ubuntu-i3-gaps-builder/
make

Packages available in packages/.

Build environment

First, get the build environment and start it:

1
2
3
git clone git@github.com:mgor/docker-ubuntu-pkg-builder.git
cd docker-ubuntu-pkg-builder
make

Dependencies

Install the needed dependencies:

1
2
3
4
5
6
7
8
apt update
apt install libxcb1-dev libxcb-keysyms1-dev \
libpango1.0-dev libxcb-util0-dev libxcb-icccm4-dev \
libyajl-dev libstartup-notification0-dev \
libxcb-randr0-dev libev-dev libxcb-cursor-dev \
libxcb-xinerama0-dev libxcb-xkb-dev libxkbcommon-dev \
libxkbcommon-x11-dev
apt-get build-dep i3

Build

Get i3-gaps from github[0].

1
2
git clone https://www.github.com/Airblader/i3 i3-gaps
cd i3-gaps

If you want to run on the stable branch:

1
2
git checkout gaps
git pull

Build the packages:

1
debuild -i -us -uc -b

If successful, the packages will be in ../. Transfer them to your host and install.

Run production WordPress site in docker for development

I have a couple of WordPress sites that I wanted to create local development environments in docker for, here are some tips on how to get it to work.

I use the official MySQL and WordPress docker images. The directory structure is as follows:

.
├── env
│ ├── config
│ │ ├── 01production_dump.sql
│ │ ├── 02update-development-site.sh.sh
│ │ └── php.ini-development
│ └── dev-env.sh
└── src
└── wp-content
├── plugins
├── themes
└── uploads

dev-env.sh:

#!/usr/bin/env bash
DATABASE_CONTAINER="dev-db"
WEBSERVER_CONTAINER="dev-web"
MYSQL_ROOT_PASSWORD="my-secret"
MYSQL_USER="dev"
MYSQL_PASSWORD="dev"
MYSQL_DATABASE="wordpress"
docker pull wordpress:latest
docker pull mysql:${MYSQL_VERSION}
docker inspect d${DATABASE_CONTAINER} &> /dev/null || docker create \
-v /var/lib/mysql \
--name d${DATABASE_CONTAINER} \
mysql:${MYSQL_VERSION} \
/bin/true
docker inspect ${DATABASE_CONTAINER} &> /dev/null && docker start ${DATABASE_CONTAINER}
docker inspect ${DATABASE_CONTAINER} &> /dev/null || docker run --name ${DATABASE_CONTAINER} \
-e MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} \
-e MYSQL_USER=${MYSQL_USER} \
-e MYSQL_PASSWORD=${MYSQL_PASSWORD} \
-e MYSQL_DATABASE=${MYSQL_DATABASE} \
--volumes-from d${DATABASE_CONTAINER} \
-v $(pwd)/config/:/docker-entrypoint-initdb.d/ \
-d mysql:${MYSQL_VERSION}
test $? -ne 0 && { echo "Failed to start database container."; exit 1; }
docker inspect ${WEBSERVER_CONTAINER} &> /dev/null && docker start ${WEBSERVER_CONTAINER}
docker inspect ${WEBSERVER_CONTAINER} &> /dev/null || docker run --name ${WEBSERVER_CONTAINER} \
--link ${DATABASE_CONTAINER}:mysql \
-v $(pwd)/config/php.ini-development:/usr/local/etc/php/php.ini \
-v $(realpath $(pwd)/../src)/wp-content/uploads:/var/www/html/wp-content/uploads \
-v $(realpath $(pwd)/../src)/wp-content/themes/my-custom-theme/:/var/www/html/wp-content/themes/my-custom-theme/ \
-v $(realpath $(pwd)/../src)/wp-content/plugins/:/var/www/html/wp-content/plugins/ \
-e WORDPRESS_DB_USER=${MYSQL_USER} \
-e WORDPRESS_DB_PASSWORD=${MYSQL_PASSWORD} \
-e WORDPRESS_DB_NAME=${MYSQL_DATABASE} \
-e WORDPRESS_TABLE_PREFIX="wp_" \
-p 80:80 -d wordpress:4
test $? -ne 0 && { echo "Failed to start webserver container."; exit 1; }

update-development-site.sh:

#!/usr/bin/env bash
cmd="mysql -u ${MYSQL_USER} --password=${MYSQL_PASSWORD} ${MYSQL_DATABASE} -e"
table_prefix=$($cmd "show tables;" -N -B 2>/dev/null | tail -1 | awk -F\_ '{print $1}')
$cmd "update ${table_prefix}_options set option_value = 'http://localhost' where option_name in ('siteurl', 'home');" 2>/dev/null

production_dump.sql is a MySQL dump of the production database, add a “use wordpress-site;” statement in the beginning so that the backup is imported into the correct database.