Skip to content
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

Add PHP 8 images #20

Merged
merged 9 commits into from
Jul 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions php8.0-rc/apache/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
FROM php:8.0-rc-apache

# install persistent PHP extensions (they won't get purged afterwards)
RUN set -eux; \
apt-get update; \
apt-get install -y --quiet --no-install-recommends \
ghostscript \
unzip \
; \
rm -rf /var/lib/apt/lists/*

# install PHP extensions
RUN set -ex; \
\
# mark packages as being manually installed
# see https://manpages.debian.org/stretch/apt/apt-mark.8.en.html
savedAptMark="$(apt-mark showmanual)"; \
\
# install via apt-get
# see https://manpages.debian.org/stretch/apt/apt-get.8.en.html
apt-get update; \
apt-get install -y --quiet --no-install-recommends \
libfreetype6-dev \
libjpeg-dev \
libmagickwand-dev \
libmcrypt-dev \
libpng-dev \
libzip-dev \
; \
\
# install and configure via docker-php-ext
# see https://github.com/docker-library/docs/tree/master/php#how-to-install-more-php-extensions
docker-php-ext-configure gd --with-freetype --with-jpeg; \
docker-php-ext-install -j "$(nproc)" \
gd \
intl \
pdo_mysql \
zip \
# delete output (except errors)
> /dev/null \
; \
\
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
# see https://github.com/docker-library/wordpress/blob/master/Dockerfile-debian.template
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/*

# enable OPcache
# see https://secure.php.net/manual/en/opcache.installation.php
RUN set -eux; \
docker-php-ext-enable opcache; \
{ \
echo 'opcache.memory_consumption=128'; \
echo 'opcache.interned_strings_buffer=8'; \
echo 'opcache.max_accelerated_files=4000'; \
echo 'opcache.revalidate_freq=2'; \
echo 'opcache.fast_shutdown=1'; \
} > /usr/local/etc/php/conf.d/opcache-recommended.ini

# enable apache modules
RUN set -eux; \
a2enmod expires headers rewrite

# create mount point for web root
VOLUME /var/www/html

# declare REDAXO version and checksum
ENV REDAXO_VERSION=5.11.0 REDAXO_SHA=66da3403fb8bb5eef86931fe4f959e1a4f3a26da

# fetch REDAXO, validate checksum and extract to tmp folder
RUN set -e; \
curl -Ls -o redaxo.zip https://github.com/redaxo/redaxo/releases/download/${REDAXO_VERSION}/redaxo_${REDAXO_VERSION}.zip; \
echo "${REDAXO_SHA} *redaxo.zip" | shasum -c -a 256; \
unzip -oq redaxo.zip -d /usr/src/redaxo; \
rm redaxo.zip; \
chown -R www-data:www-data /usr/src/redaxo

# copy and run entrypoint
COPY docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["docker-entrypoint.sh"]

# run CMD
CMD ["apache2-foreground"]
93 changes: 93 additions & 0 deletions php8.0-rc/apache/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/bin/bash
set -euo pipefail

if [[ -n "$(ls -A)" ]]; then
echo >&2 " "
echo >&2 "❌ ${PWD} is not empty! Skip REDAXO setup."
echo >&2 " "

else

echo >&2 "👉 Start REDAXO setup..."

# copy REDAXO to web root
cp -Rp /usr/src/redaxo/. ./ && \
echo >&2 "✅ REDAXO has been successfully copied to ${PWD}."

# copy default config
mkdir -p redaxo/data/core/ && \
cp -fp redaxo/src/core/default.config.yml redaxo/data/core/config.yml && \
echo >&2 "✅ Default configuration has been successfully copied."

# prepare database
# remember the docker database container takes some time to init!
echo >&2 "👉 Prepare database..."
repeat=10
while ! php redaxo/bin/console -q db:set-connection \
--host=$REDAXO_DB_HOST \
--database=$REDAXO_DB_NAME \
--login=$REDAXO_DB_LOGIN \
--password=$REDAXO_DB_PASSWORD 2> /dev/null || false; do
if [[ repeat -eq 0 ]]; then
echo >&2 "❌ Failed to connect database."
exit 1
fi
repeat=$((repeat - 1))
sleep 5
echo >&2 "⏳ Wait for database connection... ($repeat)"
done
echo >&2 "✅ Database has been has been successfully connected."

# run REDAXO setup
# hint: get options via `php redaxo/bin/console setup:run --help`
echo >&2 "👉 Run setup..."
setupArgs=(
"--agree-license"
"--db-createdb=no"
"--db-setup=normal"
);
[[ -n "$REDAXO_LANG" ]] && setupArgs+=("--lang=${REDAXO_LANG}");
[[ -n "$REDAXO_SERVER" ]] && setupArgs+=("--server=${REDAXO_SERVER}");
[[ -n "$REDAXO_SERVERNAME" ]] && setupArgs+=("--servername=${REDAXO_SERVERNAME}");
[[ -n "$REDAXO_ERROR_EMAIL" ]] && setupArgs+=("--error-email=${REDAXO_ERROR_EMAIL}");
[[ -n "$REDAXO_TIMEZONE" ]] && setupArgs+=("--timezone=${REDAXO_TIMEZONE}");
[[ -n "$REDAXO_DB_CHARSET" ]] && setupArgs+=("--db-charset=${REDAXO_DB_CHARSET}");
[[ -n "$REDAXO_DB_PASSWORD" ]] && setupArgs+=("--db-password=${REDAXO_DB_PASSWORD}"); # required again!
[[ -n "$REDAXO_ADMIN_USER" ]] && setupArgs+=("--admin-username=${REDAXO_ADMIN_USER}");
[[ -n "$REDAXO_ADMIN_PASSWORD" ]] && setupArgs+=("--admin-password=${REDAXO_ADMIN_PASSWORD}");

if php redaxo/bin/console setup:run -q -n "${setupArgs[@]}"; then
echo >&2 "✅ REDAXO has been successfully installed."
else
echo >&2 " "
echo >&2 "❌ REDAXO setup failed."
echo >&2 " "
exit 1
fi

# done!
echo >&2 " "
echo >&2 "🚀 REDAXO setup successful."
echo >&2 " "

# run custom setup (if available)
# hint: enables child images to extend the setup process
CUSTOM_SETUP="/usr/local/bin/custom-setup.sh";
if [[ -x "$CUSTOM_SETUP" ]]; then
echo >&2 "👉 Run custom setup..."

if "$CUSTOM_SETUP"; then
echo >&2 " "
echo >&2 "🚀 Custom setup successful."
echo >&2 " "
else
echo >&2 " "
echo >&2 "❌ Custom setup failed."
echo >&2 " "
exit 1
fi
fi
fi

# execute CMD
exec "$@"
28 changes: 28 additions & 0 deletions php8.0-rc/apache/hooks/post_push
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
set -e


# What is this post_push.sh?
# It's the template for the post_push hook we use to push all image tags to Docker Hub.
# https://docs.docker.com/docker-hub/builds/advanced/#custom-build-phase-hooks

# We provide these individual tags:

# X.X.X-phpX.X-apache
# X.X -phpX.X-apache
# X -phpX.X-apache

# We also provide general tags based on the default PHP version and the default variant:

# X.X.X
# X.X
# X


for tag in 5.11.0-php8.0-rc-apache 5.11-php8.0-rc-apache 5-php8.0-rc-apache; do

docker tag $IMAGE_NAME $DOCKER_REPO:$tag
docker push $DOCKER_REPO:$tag

echo "$DOCKER_REPO:$tag"
done
78 changes: 78 additions & 0 deletions php8.0-rc/fpm-alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
FROM php:8.0-rc-fpm-alpine

# install persistent PHP extensions (they won't get purged afterwards)
RUN apk add --no-cache \
bash \
# add perl-utils to include shasum
perl-utils \
sed \
unzip

# install PHP extensions
RUN set -ex; \
\
apk add --no-cache --virtual .build-deps \
$PHPIZE_DEPS \
freetype-dev \
# add icu-dev to be able to install intl extension
icu-dev \
libjpeg-turbo-dev \
libpng-dev \
libzip-dev \
; \
\
# install and configure via docker-php-ext
# see https://github.com/docker-library/docs/tree/master/php#how-to-install-more-php-extensions
docker-php-ext-configure gd --with-freetype --with-jpeg; \
docker-php-ext-install -j "$(nproc)" \
gd \
intl \
pdo_mysql \
zip \
# delete output (except errors)
> /dev/null \
; \
\
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 .redaxo-phpexts-rundeps $runDeps; \
apk del .build-deps

# enable OPcache
# see https://secure.php.net/manual/en/opcache.installation.php
RUN set -eux; \
docker-php-ext-enable opcache; \
{ \
echo 'opcache.memory_consumption=128'; \
echo 'opcache.interned_strings_buffer=8'; \
echo 'opcache.max_accelerated_files=4000'; \
echo 'opcache.revalidate_freq=2'; \
echo 'opcache.fast_shutdown=1'; \
} > /usr/local/etc/php/conf.d/opcache-recommended.ini



# create mount point for web root
VOLUME /var/www/html

# declare REDAXO version and checksum
ENV REDAXO_VERSION=5.11.0 REDAXO_SHA=66da3403fb8bb5eef86931fe4f959e1a4f3a26da

# fetch REDAXO, validate checksum and extract to tmp folder
RUN set -e; \
curl -Ls -o redaxo.zip https://github.com/redaxo/redaxo/releases/download/${REDAXO_VERSION}/redaxo_${REDAXO_VERSION}.zip; \
echo "${REDAXO_SHA} *redaxo.zip" | shasum -c -a 256; \
unzip -oq redaxo.zip -d /usr/src/redaxo; \
rm redaxo.zip; \
chown -R www-data:www-data /usr/src/redaxo

# copy and run entrypoint
COPY docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["docker-entrypoint.sh"]

# run CMD
CMD ["php-fpm"]
93 changes: 93 additions & 0 deletions php8.0-rc/fpm-alpine/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/bin/bash
set -euo pipefail

if [[ -n "$(ls -A)" ]]; then
echo >&2 " "
echo >&2 "❌ ${PWD} is not empty! Skip REDAXO setup."
echo >&2 " "

else

echo >&2 "👉 Start REDAXO setup..."

# copy REDAXO to web root
cp -Rp /usr/src/redaxo/. ./ && \
echo >&2 "✅ REDAXO has been successfully copied to ${PWD}."

# copy default config
mkdir -p redaxo/data/core/ && \
cp -fp redaxo/src/core/default.config.yml redaxo/data/core/config.yml && \
echo >&2 "✅ Default configuration has been successfully copied."

# prepare database
# remember the docker database container takes some time to init!
echo >&2 "👉 Prepare database..."
repeat=10
while ! php redaxo/bin/console -q db:set-connection \
--host=$REDAXO_DB_HOST \
--database=$REDAXO_DB_NAME \
--login=$REDAXO_DB_LOGIN \
--password=$REDAXO_DB_PASSWORD 2> /dev/null || false; do
if [[ repeat -eq 0 ]]; then
echo >&2 "❌ Failed to connect database."
exit 1
fi
repeat=$((repeat - 1))
sleep 5
echo >&2 "⏳ Wait for database connection... ($repeat)"
done
echo >&2 "✅ Database has been has been successfully connected."

# run REDAXO setup
# hint: get options via `php redaxo/bin/console setup:run --help`
echo >&2 "👉 Run setup..."
setupArgs=(
"--agree-license"
"--db-createdb=no"
"--db-setup=normal"
);
[[ -n "$REDAXO_LANG" ]] && setupArgs+=("--lang=${REDAXO_LANG}");
[[ -n "$REDAXO_SERVER" ]] && setupArgs+=("--server=${REDAXO_SERVER}");
[[ -n "$REDAXO_SERVERNAME" ]] && setupArgs+=("--servername=${REDAXO_SERVERNAME}");
[[ -n "$REDAXO_ERROR_EMAIL" ]] && setupArgs+=("--error-email=${REDAXO_ERROR_EMAIL}");
[[ -n "$REDAXO_TIMEZONE" ]] && setupArgs+=("--timezone=${REDAXO_TIMEZONE}");
[[ -n "$REDAXO_DB_CHARSET" ]] && setupArgs+=("--db-charset=${REDAXO_DB_CHARSET}");
[[ -n "$REDAXO_DB_PASSWORD" ]] && setupArgs+=("--db-password=${REDAXO_DB_PASSWORD}"); # required again!
[[ -n "$REDAXO_ADMIN_USER" ]] && setupArgs+=("--admin-username=${REDAXO_ADMIN_USER}");
[[ -n "$REDAXO_ADMIN_PASSWORD" ]] && setupArgs+=("--admin-password=${REDAXO_ADMIN_PASSWORD}");

if php redaxo/bin/console setup:run -q -n "${setupArgs[@]}"; then
echo >&2 "✅ REDAXO has been successfully installed."
else
echo >&2 " "
echo >&2 "❌ REDAXO setup failed."
echo >&2 " "
exit 1
fi

# done!
echo >&2 " "
echo >&2 "🚀 REDAXO setup successful."
echo >&2 " "

# run custom setup (if available)
# hint: enables child images to extend the setup process
CUSTOM_SETUP="/usr/local/bin/custom-setup.sh";
if [[ -x "$CUSTOM_SETUP" ]]; then
echo >&2 "👉 Run custom setup..."

if "$CUSTOM_SETUP"; then
echo >&2 " "
echo >&2 "🚀 Custom setup successful."
echo >&2 " "
else
echo >&2 " "
echo >&2 "❌ Custom setup failed."
echo >&2 " "
exit 1
fi
fi
fi

# execute CMD
exec "$@"
Loading