Enable Docker Wordpress image to start new WordPress container directly with SQLite
It has been very silent around the sqlite integration. I think a lot more people might test it, if the setup would not require an additional external database to start. I tried to create a Dockerfile using FROM Wordpress:latest, but it seems there are a couple of challenges.
To get a smooth experience, we need
- Integration of the required SQLite dependencies into the Docker WordPress image (
Dockerfile) (sqlite3,libsqlite3-dev,php-sqlite3,pdo_sqlite?) - Enable install of WP SQLite plugin during first startup, maybe by using an ENV VAR (
docker-entrypoint.sh) - Skip required MYSQL during setup, maybe by using an ENV VAR (
setup-config.php) - Add the necessary SQLite settings, maybe by using an ENV VAR (probably in
setup-config.php)
It doesn't look too complicated to me, it just needs a coordinated effort. Who can implement those changes (shell, php) and who is controlling those files to update them? How is the regular process? Who needs to agree to this?
The Docker Wordpress image size is 230MB, I don't think the SQL dependencies of around 1-3MB really matter. And I assume if not used, they should not introduce any kind of security issue.
Imagine you can spin up a new Wordpress with a simple example docker-compose.yml for wordpress:
services:
wordpress:
image: wordpress
restart: always
ports:
- 8080:80
environment:
WORDPRESS_USE_SQLITE: true
volumes:
- wordpress:/var/www/html
It seems the process is a lot easier than I thought, check the docker-wordpress-sqlite repo (via Reddit):
# Dockerfile
ARG TAG=apache
FROM wordpress:${TAG}
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ENV WORDPRESS_SOURCE_DIR="/usr/src/wordpress"
ENV WORDPRESS_TARGET_DIR="/var/www/html"
# Install the latest version of sqlite-database-integration
RUN export SQLITE_PLUGIN_VERSION=$(curl -sI "https://github.com/WordPress/sqlite-database-integration/releases/latest" | grep -i location | awk -F'/' '{print $NF}' | tr -d '\r') && \
mkdir -p ${WORDPRESS_SOURCE_DIR}/wp-content/mu-plugins/sqlite-database-integration && \
curl -L "https://github.com/WordPress/sqlite-database-integration/archive/refs/tags/${SQLITE_PLUGIN_VERSION}.tar.gz" | \
tar xz --strip-components=1 -C ${WORDPRESS_SOURCE_DIR}/wp-content/mu-plugins/sqlite-database-integration
# Configure sqlite-database-integration
RUN mv "${WORDPRESS_SOURCE_DIR}/wp-content/mu-plugins/sqlite-database-integration/db.copy" "${WORDPRESS_SOURCE_DIR}/wp-content/db.php" && \
sed -i "s#{SQLITE_IMPLEMENTATION_FOLDER_PATH}#${WORDPRESS_TARGET_DIR}/wp-content/mu-plugins/sqlite-database-integration#" "${WORDPRESS_SOURCE_DIR}/wp-content/db.php" && \
sed -i "s#{SQLITE_PLUGIN}#${WORDPRESS_TARGET_DIR}/wp-content/mu-plugins/sqlite-database-integration/load.php#" "${WORDPRESS_SOURCE_DIR}/wp-content/db.php"
Maybe all we need to do is wait till this plugin merges into Wordpress core, so we don't have to do anything