mirror of
https://github.com/joomla-docker/docker-joomla.git
synced 2024-11-18 02:55:13 +00:00
Merge pull request #63 from J0WI/update-sh
Replace update.php with update.sh and Dockerfile templates
This commit is contained in:
commit
3690067e8f
12
.travis.yml
12
.travis.yml
@ -3,16 +3,16 @@ services: docker
|
||||
|
||||
env:
|
||||
- VARIANT=php5.6/apache
|
||||
- VARIANT=php7.0/apache
|
||||
- VARIANT=php7.1/apache
|
||||
- VARIANT=php7.2/apache
|
||||
- VARIANT=php5.6/fpm
|
||||
- VARIANT=php7.0/fpm
|
||||
- VARIANT=php7.1/fpm
|
||||
- VARIANT=php7.2/fpm
|
||||
- VARIANT=php5.6/fpm-alpine
|
||||
- VARIANT=php7.0/apache
|
||||
- VARIANT=php7.0/fpm
|
||||
- VARIANT=php7.0/fpm-alpine
|
||||
- VARIANT=php7.1/apache
|
||||
- VARIANT=php7.1/fpm
|
||||
- VARIANT=php7.1/fpm-alpine
|
||||
- VARIANT=php7.2/apache
|
||||
- VARIANT=php7.2/fpm
|
||||
- VARIANT=php7.2/fpm-alpine
|
||||
|
||||
install:
|
||||
|
80
Dockerfile-alpine.template
Normal file
80
Dockerfile-alpine.template
Normal file
@ -0,0 +1,80 @@
|
||||
FROM php:%%PHP_VERSION%%-%%VARIANT%%
|
||||
LABEL maintainer="Michael Babker <michael.babker@joomla.org> (@mbabker)"
|
||||
|
||||
# Disable remote database security requirements.
|
||||
ENV JOOMLA_INSTALLATION_DISABLE_LOCALHOST_CHECK=1
|
||||
|
||||
# entrypoint.sh dependencies
|
||||
RUN apk add --no-cache \
|
||||
bash
|
||||
|
||||
# Install PHP extensions
|
||||
RUN set -ex; \
|
||||
\
|
||||
apk add --no-cache --virtual .build-deps \
|
||||
$PHPIZE_DEPS \
|
||||
autoconf \
|
||||
bzip2-dev \
|
||||
libjpeg-turbo-dev \
|
||||
libmcrypt-dev \
|
||||
libmemcached-dev \
|
||||
libpng-dev \
|
||||
openldap-dev \
|
||||
pcre-dev \
|
||||
postgresql-dev \
|
||||
; \
|
||||
\
|
||||
docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \
|
||||
docker-php-ext-configure ldap; \
|
||||
docker-php-ext-install \
|
||||
bz2 \
|
||||
gd \
|
||||
ldap \
|
||||
mcrypt \
|
||||
mysqli \
|
||||
pdo_mysql \
|
||||
pdo_pgsql \
|
||||
pgsql \
|
||||
zip \
|
||||
; \
|
||||
\
|
||||
# pecl will claim success even if one install fails, so we need to perform each install separately
|
||||
pecl install APCu-%%APCU_VERSION%%; \
|
||||
pecl install memcached-%%MEMCACHED_VERSION%%; \
|
||||
pecl install redis-%%REDIS_VERSION%%; \
|
||||
\
|
||||
docker-php-ext-enable \
|
||||
apcu \
|
||||
memcached \
|
||||
redis \
|
||||
; \
|
||||
\
|
||||
runDeps="$( \
|
||||
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \
|
||||
| tr ',' '\n' \
|
||||
| sort -u \
|
||||
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
|
||||
)"; \
|
||||
apk add --virtual .joomla-phpext-rundeps $runDeps; \
|
||||
apk del .build-deps
|
||||
|
||||
VOLUME /var/www/html
|
||||
|
||||
# Define Joomla version and expected SHA1 signature
|
||||
ENV JOOMLA_VERSION %%VERSION%%
|
||||
ENV JOOMLA_SHA1 %%SHA1%%
|
||||
|
||||
# Download package and extract to web volume
|
||||
RUN curl -o joomla.tar.bz2 -SL https://github.com/joomla/joomla-cms/releases/download/${JOOMLA_VERSION}/Joomla_${JOOMLA_VERSION}-Stable-Full_Package.tar.bz2 \
|
||||
&& echo "$JOOMLA_SHA1 *joomla.tar.bz2" | sha1sum -c - \
|
||||
&& mkdir /usr/src/joomla \
|
||||
&& tar -xf joomla.tar.bz2 -C /usr/src/joomla \
|
||||
&& rm joomla.tar.bz2 \
|
||||
&& chown -R www-data:www-data /usr/src/joomla
|
||||
|
||||
# Copy init scripts and custom .htaccess
|
||||
COPY docker-entrypoint.sh /entrypoint.sh
|
||||
COPY makedb.php /makedb.php
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
CMD ["%%CMD%%"]
|
82
Dockerfile-debian.template
Normal file
82
Dockerfile-debian.template
Normal file
@ -0,0 +1,82 @@
|
||||
FROM php:%%PHP_VERSION%%-%%VARIANT%%
|
||||
LABEL maintainer="Michael Babker <michael.babker@joomla.org> (@mbabker)"
|
||||
|
||||
# Disable remote database security requirements.
|
||||
ENV JOOMLA_INSTALLATION_DISABLE_LOCALHOST_CHECK=1
|
||||
%%VARIANT_EXTRAS%%
|
||||
# Install PHP extensions
|
||||
RUN set -ex; \
|
||||
\
|
||||
savedAptMark="$(apt-mark showmanual)"; \
|
||||
\
|
||||
apt-get update; \
|
||||
apt-get install -y --no-install-recommends \
|
||||
libbz2-dev \
|
||||
libjpeg-dev \
|
||||
libldap2-dev \
|
||||
libmcrypt-dev \
|
||||
libmemcached-dev \
|
||||
libpng-dev \
|
||||
libpq-dev \
|
||||
; \
|
||||
\
|
||||
docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \
|
||||
debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \
|
||||
docker-php-ext-configure ldap --with-libdir="lib/$debMultiarch"; \
|
||||
docker-php-ext-install \
|
||||
bz2 \
|
||||
gd \
|
||||
ldap \
|
||||
mcrypt \
|
||||
mysqli \
|
||||
pdo_mysql \
|
||||
pdo_pgsql \
|
||||
pgsql \
|
||||
zip \
|
||||
; \
|
||||
\
|
||||
# pecl will claim success even if one install fails, so we need to perform each install separately
|
||||
pecl install APCu-%%APCU_VERSION%%; \
|
||||
pecl install memcached-%%MEMCACHED_VERSION%%; \
|
||||
pecl install redis-%%REDIS_VERSION%%; \
|
||||
\
|
||||
docker-php-ext-enable \
|
||||
apcu \
|
||||
memcached \
|
||||
redis \
|
||||
; \
|
||||
\
|
||||
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
|
||||
apt-mark auto '.*' > /dev/null; \
|
||||
apt-mark manual $savedAptMark; \
|
||||
ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
|
||||
| awk '/=>/ { print $3 }' \
|
||||
| sort -u \
|
||||
| xargs -r dpkg-query -S \
|
||||
| cut -d: -f1 \
|
||||
| sort -u \
|
||||
| xargs -rt apt-mark manual; \
|
||||
\
|
||||
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
VOLUME /var/www/html
|
||||
|
||||
# Define Joomla version and expected SHA1 signature
|
||||
ENV JOOMLA_VERSION %%VERSION%%
|
||||
ENV JOOMLA_SHA1 %%SHA1%%
|
||||
|
||||
# Download package and extract to web volume
|
||||
RUN curl -o joomla.tar.bz2 -SL https://github.com/joomla/joomla-cms/releases/download/${JOOMLA_VERSION}/Joomla_${JOOMLA_VERSION}-Stable-Full_Package.tar.bz2 \
|
||||
&& echo "$JOOMLA_SHA1 *joomla.tar.bz2" | sha1sum -c - \
|
||||
&& mkdir /usr/src/joomla \
|
||||
&& tar -xf joomla.tar.bz2 -C /usr/src/joomla \
|
||||
&& rm joomla.tar.bz2 \
|
||||
&& chown -R www-data:www-data /usr/src/joomla
|
||||
|
||||
# Copy init scripts and custom .htaccess
|
||||
COPY docker-entrypoint.sh /entrypoint.sh
|
||||
COPY makedb.php /makedb.php
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
CMD ["%%CMD%%"]
|
@ -12,13 +12,13 @@ RUN apk add --no-cache \
|
||||
RUN set -ex; \
|
||||
\
|
||||
apk add --no-cache --virtual .build-deps \
|
||||
alpine-sdk \
|
||||
$PHPIZE_DEPS \
|
||||
autoconf \
|
||||
bzip2-dev \
|
||||
libjpeg-turbo-dev \
|
||||
libmcrypt-dev \
|
||||
libpng-dev \
|
||||
libmemcached-dev \
|
||||
libpng-dev \
|
||||
openldap-dev \
|
||||
pcre-dev \
|
||||
postgresql-dev \
|
||||
|
@ -12,13 +12,13 @@ RUN apk add --no-cache \
|
||||
RUN set -ex; \
|
||||
\
|
||||
apk add --no-cache --virtual .build-deps \
|
||||
alpine-sdk \
|
||||
$PHPIZE_DEPS \
|
||||
autoconf \
|
||||
bzip2-dev \
|
||||
libjpeg-turbo-dev \
|
||||
libmcrypt-dev \
|
||||
libpng-dev \
|
||||
libmemcached-dev \
|
||||
libpng-dev \
|
||||
openldap-dev \
|
||||
pcre-dev \
|
||||
postgresql-dev \
|
||||
|
@ -12,13 +12,13 @@ RUN apk add --no-cache \
|
||||
RUN set -ex; \
|
||||
\
|
||||
apk add --no-cache --virtual .build-deps \
|
||||
alpine-sdk \
|
||||
$PHPIZE_DEPS \
|
||||
autoconf \
|
||||
bzip2-dev \
|
||||
libjpeg-turbo-dev \
|
||||
libmcrypt-dev \
|
||||
libpng-dev \
|
||||
libmemcached-dev \
|
||||
libpng-dev \
|
||||
openldap-dev \
|
||||
pcre-dev \
|
||||
postgresql-dev \
|
||||
|
@ -12,12 +12,12 @@ RUN apk add --no-cache \
|
||||
RUN set -ex; \
|
||||
\
|
||||
apk add --no-cache --virtual .build-deps \
|
||||
alpine-sdk \
|
||||
$PHPIZE_DEPS \
|
||||
autoconf \
|
||||
bzip2-dev \
|
||||
libjpeg-turbo-dev \
|
||||
libpng-dev \
|
||||
libmemcached-dev \
|
||||
libpng-dev \
|
||||
openldap-dev \
|
||||
pcre-dev \
|
||||
postgresql-dev \
|
||||
|
106
update.php
106
update.php
@ -1,106 +0,0 @@
|
||||
<?php
|
||||
|
||||
// Fetch the current 3.x version from the downloads site API
|
||||
$ch = curl_init();
|
||||
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_URL, 'https://downloads.joomla.org/api/v1/latest/cms');
|
||||
|
||||
$result = curl_exec($ch);
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
if ($result === false)
|
||||
{
|
||||
echo 'Could not fetch version data, please check your connection.' . PHP_EOL;
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$data = json_decode($result, true);
|
||||
|
||||
foreach ($data['branches'] as $branch)
|
||||
{
|
||||
if ($branch['branch'] === 'Joomla! 3')
|
||||
{
|
||||
$version = $branch['version'];
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($version))
|
||||
{
|
||||
echo 'Joomla! 3.x version data not included in API response.' . PHP_EOL;
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$urlVersion = str_replace('.', '-', $version);
|
||||
|
||||
$filename = "Joomla_$version-Stable-Full_Package.tar.bz2";
|
||||
|
||||
// Fetch the SHA1 signature for the file
|
||||
$ch = curl_init();
|
||||
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_URL, "https://downloads.joomla.org/api/v1/signatures/cms/$urlVersion");
|
||||
|
||||
$result = curl_exec($ch);
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
if ($result === false)
|
||||
{
|
||||
echo 'Could not fetch signature data, please check your connection.' . PHP_EOL;
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$data = json_decode($result, true);
|
||||
|
||||
foreach ($data['files'] as $file)
|
||||
{
|
||||
if ($file['filename'] === $filename)
|
||||
{
|
||||
$signature = $file['sha1'];
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($signature))
|
||||
{
|
||||
echo 'tar.bz2 file SHA1 signature not included in API response.' . PHP_EOL;
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$phpVersions = [];
|
||||
$platforms = ['apache', 'fpm', 'fpm-alpine'];
|
||||
|
||||
/** @var DirectoryIterator $dir */
|
||||
foreach (new DirectoryIterator(__DIR__) as $dir)
|
||||
{
|
||||
if (substr($dir->getFilename(), 0, 3) === 'php')
|
||||
{
|
||||
$phpVersions[] = $dir->getFilename();
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($phpVersions as $phpVersion)
|
||||
{
|
||||
foreach ($platforms as $platform)
|
||||
{
|
||||
$dockerfile = __DIR__ . "/$phpVersion/$platform/Dockerfile";
|
||||
|
||||
$fileContents = file_get_contents($dockerfile);
|
||||
$fileContents = preg_replace('#ENV JOOMLA_VERSION [^ ]*\n#', "ENV JOOMLA_VERSION $version\n", $fileContents);
|
||||
$fileContents = preg_replace('#ENV JOOMLA_SHA1 [^ ]*\n#', "ENV JOOMLA_SHA1 $signature\n\n", $fileContents);
|
||||
|
||||
file_put_contents($dockerfile, $fileContents);
|
||||
|
||||
// To make management easier, we use these files for all variants
|
||||
copy(__DIR__ . '/docker-entrypoint.sh', __DIR__ . "/$phpVersion/$platform/docker-entrypoint.sh");
|
||||
copy(__DIR__ . '/makedb.php', __DIR__ . "/$phpVersion/$platform/makedb.php");
|
||||
}
|
||||
}
|
||||
|
||||
echo 'Dockerfile variants updated' . PHP_EOL;
|
87
update.sh
Executable file
87
update.sh
Executable file
@ -0,0 +1,87 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
|
||||
|
||||
phpVersions=( "$@" )
|
||||
if [ ${#phpVersions[@]} -eq 0 ]; then
|
||||
phpVersions=( php*.*/ )
|
||||
fi
|
||||
phpVersions=( "${phpVersions[@]%/}" )
|
||||
|
||||
current="$(curl -fsSL 'https://downloads.joomla.org/api/v1/latest/cms' | jq -r '.branches[3].version')"
|
||||
urlVersion=$(echo $current | sed -e 's/\./-/g')
|
||||
sha1="$(curl -fsSL "https://downloads.joomla.org/api/v1/signatures/cms/$urlVersion" | jq -r --arg file "Joomla_${current}-Stable-Full_Package.tar.bz2" '.[] | .[] | select(.filename == $file).sha1')"
|
||||
|
||||
declare -A variantExtras=(
|
||||
[apache]='\n# Enable Apache Rewrite Module\nRUN a2enmod rewrite\n'
|
||||
[fpm]=''
|
||||
[fpm-alpine]=''
|
||||
)
|
||||
declare -A variantCmds=(
|
||||
[apache]='apache2-foreground'
|
||||
[fpm]='php-fpm'
|
||||
[fpm-alpine]='php-fpm'
|
||||
)
|
||||
declare -A variantBases=(
|
||||
[apache]='debian'
|
||||
[fpm]='debian'
|
||||
[fpm-alpine]='alpine'
|
||||
)
|
||||
declare -A pecl_versions=(
|
||||
[php5-APCu]='4.0.11'
|
||||
[php5-memcached]='2.2.0'
|
||||
[php5-redis]='3.1.6'
|
||||
[php7-APCu]='5.1.11'
|
||||
[php7-memcached]='3.0.4'
|
||||
[php7-redis]='3.1.6'
|
||||
)
|
||||
|
||||
travisEnv=
|
||||
for phpVersion in "${phpVersions[@]}"; do
|
||||
phpVersionDir="$phpVersion"
|
||||
phpVersion="${phpVersion#php}"
|
||||
phpMajorVersion=$(echo $phpVersionDir | cut -d. -f1)
|
||||
|
||||
for variant in apache fpm fpm-alpine; do
|
||||
dir="$phpVersionDir/$variant"
|
||||
mkdir -p "$dir"
|
||||
|
||||
extras="${variantExtras[$variant]}"
|
||||
cmd="${variantCmds[$variant]}"
|
||||
base="${variantBases[$variant]}"
|
||||
|
||||
entrypoint='docker-entrypoint.sh'
|
||||
|
||||
(
|
||||
set -x
|
||||
|
||||
sed -r \
|
||||
-e 's!%%VERSION%%!'"$current"'!g' \
|
||||
-e 's!%%SHA1%%!'"$sha1"'!g' \
|
||||
-e 's!%%PHP_VERSION%%!'"$phpVersion"'!g' \
|
||||
-e 's!%%VARIANT%%!'"$variant"'!g' \
|
||||
-e 's!%%VARIANT_EXTRAS%%!'"$extras"'!g' \
|
||||
-e 's!%%APCU_VERSION%%!'"${pecl_versions[$phpMajorVersion-APCu]}"'!g' \
|
||||
-e 's!%%MEMCACHED_VERSION%%!'"${pecl_versions[$phpMajorVersion-memcached]}"'!g' \
|
||||
-e 's!%%REDIS_VERSION%%!'"${pecl_versions[$phpMajorVersion-redis]}"'!g' \
|
||||
-e 's!%%CMD%%!'"$cmd"'!g' \
|
||||
"Dockerfile-${base}.template" > "$dir/Dockerfile"
|
||||
|
||||
cp -a "$entrypoint" "$dir/docker-entrypoint.sh"
|
||||
cp -a "makedb.php" "$dir/makedb.php"
|
||||
|
||||
if [ $phpVersionDir = "php7.2" ]; then
|
||||
sed \
|
||||
-e '/libmcrypt-dev/d' \
|
||||
-e '/mcrypt/d' \
|
||||
-i $dir/Dockerfile
|
||||
fi
|
||||
)
|
||||
|
||||
travisEnv+='\n - VARIANT='"$dir"
|
||||
done
|
||||
done
|
||||
|
||||
travis="$(awk -v 'RS=\n\n' '$1 == "env:" { $0 = "env:'"$travisEnv"'" } { printf "%s%s", $0, RS }' .travis.yml)"
|
||||
echo "$travis" > .travis.yml
|
Loading…
Reference in New Issue
Block a user