Skip to content

Commit

Permalink
Variants per database type (#1)
Browse files Browse the repository at this point in the history
* prepare to support variants per database type
* upload database dumps as release assets
* added support for MySQL
  • Loading branch information
gesinn-it-gea authored Dec 28, 2021
1 parent 720d3ab commit 4e7e06e
Show file tree
Hide file tree
Showing 13 changed files with 479 additions and 28 deletions.
56 changes: 49 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,40 @@ jobs:
strategy:
matrix:
mediawiki_version: [1.31, 1.35, 1.36, 1.37]
dbtype: [sqlite, mysql]
database_type: [sqlite, mysql]

services:
mysql:
image: mariadb:latest
env:
MYSQL_ROOT_PASSWORD: database
ports:
- 3306
options: --name mysql --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=10

steps:
- name: Check MySQL
run: |
mysql --version
mysql --host 127.0.0.1 --port ${{ job.services.mysql.ports['3306'] }} -uroot -pdatabase -e "SELECT @@VERSION"
- name: Checkout
uses: actions/checkout@v2

- name: Retrieve MediaWiki version
run: |
echo "TAG_NAME=$(cat ./${{ matrix.mediawiki_version }}/Dockerfile | sed -n -e 's/^.*FROM mediawiki://p')" >> $GITHUB_ENV
echo "TAG_NAME=$(cat ./${{ matrix.mediawiki_version }}/${{ matrix.database_type }}/Dockerfile | sed -n -e 's/^.*FROM mediawiki://p')" >> $GITHUB_ENV
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
driver-opts: network=host

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache/${{ matrix.mediawiki_version }}
path: /tmp/.buildx-cache/${{ matrix.mediawiki_version }}/${{ matrix.database_type }}
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
Expand All @@ -40,17 +56,43 @@ jobs:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

## Create a timestamp to disable cache for install.php RUN to force populating the database
- name: Get timestamp
id: date
run: echo "::set-output name=date::$(date +%s)"

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: ./
file: ./${{ matrix.mediawiki_version }}/Dockerfile
file: ./${{ matrix.mediawiki_version }}/${{ matrix.database_type }}/Dockerfile
network: host
allow: network.host
build-args: |
MYSQL_PORT=${{ job.services.mysql.ports['3306'] }}
CACHEBUST=${{ steps.date.outputs.date }}
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: gesinn/docker-mediawiki:${{ matrix.mediawiki_version }}, gesinn/docker-mediawiki:${{ env.TAG_NAME }}
cache-from: type=local,src=/tmp/.buildx-cache/${{ matrix.mediawiki_version }}
cache-to: type=local,dest=/tmp/.buildx-cache/${{ matrix.mediawiki_version }}
tags: gesinn/docker-mediawiki-${{ matrix.database_type }}:${{ matrix.mediawiki_version }}, gesinn/docker-mediawiki-${{ matrix.database_type }}:${{ env.TAG_NAME }}
cache-from: type=local,src=/tmp/.buildx-cache/${{ matrix.mediawiki_version }}/${{ matrix.database_type }}
cache-to: type=local,dest=/tmp/.buildx-cache/${{ matrix.mediawiki_version }}/${{ matrix.database_type }}

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}

- name: Dump MySQL database
run: |
mysql --host 127.0.0.1 --port ${{ job.services.mysql.ports['3306'] }} -uroot -pdatabase -e "SHOW DATABASES"
mysql --host 127.0.0.1 --port ${{ job.services.mysql.ports['3306'] }} -uroot -pdatabase -e "SHOW TABLES FROM wiki"
mysqldump -uroot -pdatabase --host 127.0.0.1 --port ${{ job.services.mysql.ports['3306'] }} --default-character-set=utf8 --single-transaction --quick --column-statistics=0 wiki -c | bzip2 -cz9 > mediawiki-mysql-${{ env.TAG_NAME }}.sql.bz2
if: matrix.database_type == 'mysql'

- name: Create Tag and upload MySQL dump as artifact
uses: ncipollo/release-action@v1
with:
tag: ${{ env.TAG_NAME }}
allowUpdates: true
artifacts: mediawiki-mysql-${{ env.TAG_NAME }}.sql.bz2
token: ${{ secrets.GITHUB_TOKEN }}
if: matrix.database_type == 'mysql'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
81 changes: 81 additions & 0 deletions 1.31/mysql/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
###################################################
# gesinn-it/docker-mediawiki:mw-1.31.16
#
# MEDIAWIKI_VERSION: MediaWiki Version
# COMPOSER_VERSION: Composer Major Version (1 or 2)
###################################################
FROM mediawiki:1.31.16

ARG MYSQL_PORT

# Fix owner
RUN chown -R www-data:www-data .

# Existential tools
RUN apt-get update && \
apt-get install -y \
sudo \
unzip \
less \
nano \
nodejs \
npm

# Install MySQL client for debugging
# RUN apt-get install -y default-mysql-client

# Test MySQL Connection
# RUN mysql --host 127.0.0.1 --port ${MYSQL_PORT} -uroot -pdatabase -e "SELECT @@VERSION"

# MySQL grant privileges
# RUN mysql --host 127.0.0.1 --port ${MYSQL_PORT} -uroot -pdatabase -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'database'"

# Test PHP and install pdo_mysql
RUN php -m && \
docker-php-ext-install pdo_mysql && \
php -m

# Bashrc Alias
RUN echo "alias ll='ls -la'" >> /etc/bash.bashrc && \
echo "alias ..='cd ..'" >> /etc/bash.bashrc && \
echo "alias ...='cd ...'" >> /etc/bash.bashrc

# Install Composer
RUN php -r "copy('https://getcomposer.org/installer', 'installer');" && \
php -r "copy('https://composer.github.io/installer.sig', 'expected');" && \
echo `cat expected` " installer" | sha384sum -c - && \
php installer --version=1.10.24 && \
rm -f installer expected && \
mv composer.phar /usr/local/bin/composer

# Install XDebug
RUN pecl install xdebug && \
bash -c "echo 'zend_extension=xdebug' >> /usr/local/etc/php/conf.d/99-xdebug.ini" && \
bash -c "echo 'xdebug.mode=coverage' >> /usr/local/etc/php/conf.d/99-xdebug.ini" && \
php -v

# Setup MediaWiki
## prevent caching
ARG CACHEBUST=1
RUN sudo -u www-data composer update && \
sudo -u www-data php maintenance/install.php \
--pass=wiki4everyone \
--server="http://localhost:8080" \
--scriptpath="" \
--dbserver=127.0.0.1:${MYSQL_PORT} \
--installdbuser=root \
--installdbpass=database \
--dbtype=mysql \
--dbname=wiki \
--dbuser=wiki \
--dbpass=wiki \
wiki WikiSysop

# Enable debug output, enable JS testing
RUN bash -c "echo 'error_reporting(E_ALL| E_STRICT);' >> LocalSettings.php" && \
bash -c "echo 'ini_set(\"display_errors\", 1);' >> LocalSettings.php" && \
bash -c 'echo "\$wgShowExceptionDetails = true;" >> LocalSettings.php' && \
bash -c 'echo "\$wgDevelopmentWarnings = true;" >> LocalSettings.php' && \
bash -c 'echo "\$wgEnableJavaScriptTest = true;" >> LocalSettings.php' && \
bash -c 'echo "\$wgDebugToolbar = true;" >> LocalSettings.php' && \
tail -n6 LocalSettings.php
File renamed without changes.
81 changes: 81 additions & 0 deletions 1.35/mysql/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
###################################################
# gesinn-it/docker-mediawiki:mw-1.35.5
#
# MEDIAWIKI_VERSION: MediaWiki Version
# COMPOSER_VERSION: Composer Major Version (1 or 2)
###################################################
FROM mediawiki:1.35.5

ARG MYSQL_PORT

# Fix owner
RUN chown -R www-data:www-data .

# Existential tools
RUN apt-get update && \
apt-get install -y \
sudo \
unzip \
less \
nano \
nodejs \
npm

# Install MySQL client for debugging
# RUN apt-get install -y default-mysql-client

# Test MySQL Connection
# RUN mysql --host 127.0.0.1 --port ${MYSQL_PORT} -uroot -pdatabase -e "SELECT @@VERSION"

# MySQL grant privileges
# RUN mysql --host 127.0.0.1 --port ${MYSQL_PORT} -uroot -pdatabase -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'database'"

# Test PHP and install pdo_mysql
RUN php -m && \
docker-php-ext-install pdo_mysql && \
php -m

# Bashrc Alias
RUN echo "alias ll='ls -la'" >> /etc/bash.bashrc && \
echo "alias ..='cd ..'" >> /etc/bash.bashrc && \
echo "alias ...='cd ...'" >> /etc/bash.bashrc

# Install Composer
RUN php -r "copy('https://getcomposer.org/installer', 'installer');" && \
php -r "copy('https://composer.github.io/installer.sig', 'expected');" && \
echo `cat expected` " installer" | sha384sum -c - && \
php installer --version=2.1.14 && \
rm -f installer expected && \
mv composer.phar /usr/local/bin/composer

# Install XDebug
RUN pecl install xdebug && \
bash -c "echo 'zend_extension=xdebug' >> /usr/local/etc/php/conf.d/99-xdebug.ini" && \
bash -c "echo 'xdebug.mode=coverage' >> /usr/local/etc/php/conf.d/99-xdebug.ini" && \
php -v

# Setup MediaWiki
## prevent caching
ARG CACHEBUST=1
RUN sudo -u www-data composer update && \
sudo -u www-data php maintenance/install.php \
--pass=wiki4everyone \
--server="http://localhost:8080" \
--scriptpath="" \
--dbserver=127.0.0.1:${MYSQL_PORT} \
--installdbuser=root \
--installdbpass=database \
--dbtype=mysql \
--dbname=wiki \
--dbuser=wiki \
--dbpass=wiki \
wiki WikiSysop

# Enable debug output, enable JS testing
RUN bash -c "echo 'error_reporting(E_ALL| E_STRICT);' >> LocalSettings.php" && \
bash -c "echo 'ini_set(\"display_errors\", 1);' >> LocalSettings.php" && \
bash -c 'echo "\$wgShowExceptionDetails = true;" >> LocalSettings.php' && \
bash -c 'echo "\$wgDevelopmentWarnings = true;" >> LocalSettings.php' && \
bash -c 'echo "\$wgEnableJavaScriptTest = true;" >> LocalSettings.php' && \
bash -c 'echo "\$wgDebugToolbar = true;" >> LocalSettings.php' && \
tail -n6 LocalSettings.php
File renamed without changes.
81 changes: 81 additions & 0 deletions 1.36/mysql/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
###################################################
# gesinn-it/docker-mediawiki:mw-1.36.3
#
# MEDIAWIKI_VERSION: MediaWiki Version
# COMPOSER_VERSION: Composer Major Version (1 or 2)
###################################################
FROM mediawiki:1.36.3

ARG MYSQL_PORT

# Fix owner
RUN chown -R www-data:www-data .

# Existential tools
RUN apt-get update && \
apt-get install -y \
sudo \
unzip \
less \
nano \
nodejs \
npm

# Install MySQL client for debugging
# RUN apt-get install -y default-mysql-client

# Test MySQL Connection
# RUN mysql --host 127.0.0.1 --port ${MYSQL_PORT} -uroot -pdatabase -e "SELECT @@VERSION"

# MySQL grant privileges
# RUN mysql --host 127.0.0.1 --port ${MYSQL_PORT} -uroot -pdatabase -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'database'"

# Test PHP and install pdo_mysql
RUN php -m && \
docker-php-ext-install pdo_mysql && \
php -m

# Bashrc Alias
RUN echo "alias ll='ls -la'" >> /etc/bash.bashrc && \
echo "alias ..='cd ..'" >> /etc/bash.bashrc && \
echo "alias ...='cd ...'" >> /etc/bash.bashrc

# Install Composer
RUN php -r "copy('https://getcomposer.org/installer', 'installer');" && \
php -r "copy('https://composer.github.io/installer.sig', 'expected');" && \
echo `cat expected` " installer" | sha384sum -c - && \
php installer --version=2.1.14 && \
rm -f installer expected && \
mv composer.phar /usr/local/bin/composer

# Install XDebug
RUN pecl install xdebug && \
bash -c "echo 'zend_extension=xdebug' >> /usr/local/etc/php/conf.d/99-xdebug.ini" && \
bash -c "echo 'xdebug.mode=coverage' >> /usr/local/etc/php/conf.d/99-xdebug.ini" && \
php -v

# Setup MediaWiki
## prevent caching
ARG CACHEBUST=1
RUN sudo -u www-data composer update && \
sudo -u www-data php maintenance/install.php \
--pass=wiki4everyone \
--server="http://localhost:8080" \
--scriptpath="" \
--dbserver=127.0.0.1:${MYSQL_PORT} \
--installdbuser=root \
--installdbpass=database \
--dbtype=mysql \
--dbname=wiki \
--dbuser=wiki \
--dbpass=wiki \
wiki WikiSysop

# Enable debug output, enable JS testing
RUN bash -c "echo 'error_reporting(E_ALL| E_STRICT);' >> LocalSettings.php" && \
bash -c "echo 'ini_set(\"display_errors\", 1);' >> LocalSettings.php" && \
bash -c 'echo "\$wgShowExceptionDetails = true;" >> LocalSettings.php' && \
bash -c 'echo "\$wgDevelopmentWarnings = true;" >> LocalSettings.php' && \
bash -c 'echo "\$wgEnableJavaScriptTest = true;" >> LocalSettings.php' && \
bash -c 'echo "\$wgDebugToolbar = true;" >> LocalSettings.php' && \
tail -n6 LocalSettings.php
File renamed without changes.
Loading

0 comments on commit 4e7e06e

Please sign in to comment.