Skip to content

Commit

Permalink
Alpine 3.19 and Dockerfile PHP Version ARG (#8)
Browse files Browse the repository at this point in the history
* feat: alpine 3.19

* fix: php version

* fix: php version arg

* fix: add missing $_phpv
  • Loading branch information
MPThLee authored Dec 15, 2023
1 parent 932c6ce commit aa1727c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
34 changes: 21 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
ARG MEDIAWIKI_VERSION=1.39.5
ARG ALPINE_VERSION=3.18
ARG ALPINE_VERSION=3.19
ARG PHP_VERSION=81

# Download mediawiki
FROM alpine:$ALPINE_VERSION as builder
ARG MEDIAWIKI_VERSION
ARG PHP_VERSION

RUN mkdir -p /tmp/composer /tmp/mediawiki
COPY --from=ghcr.io/shinycolorswiki/mediawiki-extension-downloader:latest /app /tmp/mediawiki-extension-downloader
Expand All @@ -13,13 +15,16 @@ COPY config/extension-list.json /tmp/mediawiki-extension-downloader.json
RUN apk add --update --no-cache \
curl tar gzip \
# PHPs
php81 php81-fpm \
php${PHP_VERSION} php${PHP_VERSION}-fpm \
# Mediawiki requirements
php81-session php81-openssl php81-json php81-mbstring php81-fileinfo php81-intl php81-calendar php81-xml \
php${PHP_VERSION}-session php${PHP_VERSION}-openssl php${PHP_VERSION}-json php${PHP_VERSION}-mbstring php${PHP_VERSION}-fileinfo \
php${PHP_VERSION}-intl php${PHP_VERSION}-calendar php${PHP_VERSION}-xml \
# Mediawiki configuration requirements.
php81-curl php81-mysqli php81-mysqlnd php81-gd php81-dom php81-ctype php81-iconv php81-zlib php81-xmlreader \
php${PHP_VERSION}-curl php${PHP_VERSION}-mysqli php${PHP_VERSION}-mysqlnd php${PHP_VERSION}-gd php${PHP_VERSION}-dom php${PHP_VERSION}-ctype \
php${PHP_VERSION}-iconv php${PHP_VERSION}-zlib php${PHP_VERSION}-xmlreader \
# Mediawiki caching and extensions requirements
php81-simplexml php81-tokenizer php81-xmlwriter php81-opcache php81-phar php81-pecl-apcu php81-pecl-redis php81-pcntl php81-posix \
php${PHP_VERSION}-simplexml php${PHP_VERSION}-tokenizer php${PHP_VERSION}-xmlwriter php${PHP_VERSION}-opcache php${PHP_VERSION}-phar \
php${PHP_VERSION}-pecl-apcu php${PHP_VERSION}-pecl-redis php${PHP_VERSION}-pcntl php${PHP_VERSION}-posix \
# Composer
composer

Expand All @@ -34,28 +39,31 @@ RUN /tmp/mediawiki-extension-downloader --config /tmp/mediawiki-extension-downlo

COPY config/wiki/composer.local.json /tmp/mediawiki/
WORKDIR /tmp/mediawiki
RUN COMPOSER_HOME=/tmp/composer composer update --no-dev
RUN COMPOSER_HOME=/tmp/composer /usr/bin/php$PHP_VERSION /usr/bin/composer.phar update --no-dev

# NO I WON'T USE PHP IMAGE SINCE IT'S TOO BIG
FROM alpine:$ALPINE_VERSION
ARG PHP_VERSION

# LuaSandbox package is added on (edge, as of v3.18) community branch. we need to add for luasandbox.
RUN echo "@edgecommunity https://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories && \
apk add --update --no-cache \
# LuaSandbox package is added on community branch (as of v3.19) ).
RUN apk add --update --no-cache \
# Basic utils
curl imagemagick rsvg-convert diffutils ffmpeg sudo lua tar bzip2 zstd bash mariadb-client \
# Web server
nginx \
# See https://github.com/krallin/tini.
tini \
# PHPs
php81 php81-fpm \
php${PHP_VERSION} php${PHP_VERSION}-fpm \
# Mediawiki requirements
php81-session php81-openssl php81-json php81-mbstring php81-fileinfo php81-intl php81-calendar php81-xml \
php${PHP_VERSION}-session php${PHP_VERSION}-openssl php${PHP_VERSION}-json php${PHP_VERSION}-mbstring php${PHP_VERSION}-fileinfo \
php${PHP_VERSION}-intl php${PHP_VERSION}-calendar php${PHP_VERSION}-xml \
# Mediawiki configuration requirements.
php81-curl php81-mysqli php81-mysqlnd php81-gd php81-dom php81-ctype php81-iconv php81-zlib php81-xmlreader php81-pecl-luasandbox@edgecommunity \
php${PHP_VERSION}-curl php${PHP_VERSION}-mysqli php${PHP_VERSION}-mysqlnd php${PHP_VERSION}-gd php${PHP_VERSION}-dom php${PHP_VERSION}-ctype \
php${PHP_VERSION}-iconv php${PHP_VERSION}-zlib php${PHP_VERSION}-xmlreader php${PHP_VERSION}-pecl-luasandbox \
# Mediawiki caching and extensions requirements
php81-simplexml php81-tokenizer php81-xmlwriter php81-opcache php81-phar php81-pecl-apcu php81-pecl-redis php81-pcntl php81-posix
php${PHP_VERSION}-simplexml php${PHP_VERSION}-tokenizer php${PHP_VERSION}-xmlwriter php${PHP_VERSION}-opcache php${PHP_VERSION}-phar \
php${PHP_VERSION}-pecl-apcu php${PHP_VERSION}-pecl-redis php${PHP_VERSION}-pcntl php${PHP_VERSION}-posix

# Make folder and copy mediawiki into here.
RUN mkdir /srv/wiki && chown nginx:www-data /srv/wiki && \
Expand Down
8 changes: 4 additions & 4 deletions run
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ sleep $seconds

if [ -z "${MEDIAWIKI_SKIP_INSTALL:-}" ]; then
echo "Start install mediawiki..."
DB_NAME="$(php -r 'require "/setting/secret.php"; echo $wgDBname;')"
DB_HOSTNAME="$(php -r 'require "/setting/secret.php"; echo $wgDBserver;')"
DB_USERNAME="$(php -r 'require "/setting/secret.php"; echo $wgDBuser;')"
DB_PASSWORD="$(php -r 'require "/setting/secret.php"; echo $wgDBpassword;')"
DB_NAME="$(php$_phpv -r 'require "/setting/secret.php"; echo $wgDBname;')"
DB_HOSTNAME="$(php$_phpv -r 'require "/setting/secret.php"; echo $wgDBserver;')"
DB_USERNAME="$(php$_phpv -r 'require "/setting/secret.php"; echo $wgDBuser;')"
DB_PASSWORD="$(php$_phpv -r 'require "/setting/secret.php"; echo $wgDBpassword;')"
php$_phpv /srv/wiki/w/maintenance/install.php \
--scriptpath '/w' \
--dbtype mysql \
Expand Down

0 comments on commit aa1727c

Please sign in to comment.