Skip to content

Enable Docker Wordpress image to start new WordPress container directly with SQLite #175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
bluepuma77 opened this issue Mar 13, 2025 · 2 comments

Comments

@bluepuma77
Copy link

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

  1. Integration of the required SQLite dependencies into the Docker WordPress image (Dockerfile)
    (sqlite3, libsqlite3-dev, php-sqlite3, pdo_sqlite?)
  2. Enable install of WP SQLite plugin during first startup, maybe by using an ENV VAR (docker-entrypoint.sh)
  3. Skip required MYSQL during setup, maybe by using an ENV VAR (setup-config.php)
  4. 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
@bluepuma77
Copy link
Author

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"

@hawm
Copy link

hawm commented Apr 1, 2025

Maybe all we need to do is wait till this plugin merges into Wordpress core, so we don't have to do anything

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants