Skip to content

Commit

Permalink
GenerRRRRR-ate image files from source!
Browse files Browse the repository at this point in the history
  • Loading branch information
FriendsOfREDAXO-T committed Dec 27, 2023
1 parent eac26cd commit fd393ec
Show file tree
Hide file tree
Showing 4 changed files with 332 additions and 332 deletions.
174 changes: 87 additions & 87 deletions images/5-edge/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,115 +2,115 @@ FROM php:8.3-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 \
locales \
unzip \
; \
rm -rf /var/lib/apt/lists/*
apt-get update; \
apt-get install -y --quiet --no-install-recommends \
ghostscript \
locales \
unzip \
; \
rm -rf /var/lib/apt/lists/*

# generate locales
RUN set -eux; \
echo "de_DE.UTF-8 UTF-8" >> /etc/locale.gen; \
echo "en_GB.UTF-8 UTF-8" >> /etc/locale.gen; \
echo "es_ES.UTF-8 UTF-8" >> /etc/locale.gen; \
echo "it_IT.UTF-8 UTF-8" >> /etc/locale.gen; \
echo "nl_NL.UTF-8 UTF-8" >> /etc/locale.gen; \
echo "pt_BR.UTF-8 UTF-8" >> /etc/locale.gen; \
echo "sv_SE.UTF-8 UTF-8" >> /etc/locale.gen; \
locale-gen
echo "de_DE.UTF-8 UTF-8" >> /etc/locale.gen; \
echo "en_GB.UTF-8 UTF-8" >> /etc/locale.gen; \
echo "es_ES.UTF-8 UTF-8" >> /etc/locale.gen; \
echo "it_IT.UTF-8 UTF-8" >> /etc/locale.gen; \
echo "nl_NL.UTF-8 UTF-8" >> /etc/locale.gen; \
echo "pt_BR.UTF-8 UTF-8" >> /etc/locale.gen; \
echo "sv_SE.UTF-8 UTF-8" >> /etc/locale.gen; \
locale-gen

# 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 \
libwebp-dev \
libavif-dev \
libzip-dev \
; \
# install developer extensions
apt-get install -y --quiet --no-install-recommends \
git \
msmtp \
msmtp-mta \
; \
# 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 \
--with-webp \
--with-avif \
; \
docker-php-ext-install -j "$(nproc)" \
exif \
gd \
intl \
pdo_mysql \
zip \
; \
# install imagick
# https://pecl.php.net/package/imagick
# pecl install imagick-3.7.0; \
# docker-php-ext-enable imagick; \
# rm -r /tmp/pear; \
# \
# 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.template
apt-mark auto '.*' > /dev/null; \
apt-mark manual $savedAptMark; \
ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
| awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); print so }' \
| sort -u \
| xargs -r dpkg-query --search \
| 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/*
\
# 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 \
libwebp-dev \
libavif-dev \
libzip-dev \
; \
# install developer extensions
apt-get install -y --quiet --no-install-recommends \
git \
msmtp \
msmtp-mta \
; \
# 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 \
--with-webp \
--with-avif \
; \
docker-php-ext-install -j "$(nproc)" \
exif \
gd \
intl \
pdo_mysql \
zip \
; \
# install imagick
# https://pecl.php.net/package/imagick
# pecl install imagick-3.7.0; \
# docker-php-ext-enable imagick; \
# rm -r /tmp/pear; \
# \
# 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.template
apt-mark auto '.*' > /dev/null; \
apt-mark manual $savedAptMark; \
ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
| awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); print so }' \
| sort -u \
| xargs -r dpkg-query --search \
| 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/*

# install composer
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer

# 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'; \
} > /usr/local/etc/php/conf.d/opcache-recommended.ini
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'; \
} > /usr/local/etc/php/conf.d/opcache-recommended.ini

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

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

# fetch REDAXO, validate checksum and extract to tmp folder
RUN set -e; \
curl -Ls -o redaxo.zip https://github.com/redaxo/redaxo/releases/download/5.15.1/redaxo_5.15.1.zip; \
echo "7936b2055b670377be97f8c8a4e90ce46f0a6ad7 *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
curl -Ls -o redaxo.zip https://github.com/redaxo/redaxo/releases/download/5.15.1/redaxo_5.15.1.zip; \
echo "7936b2055b670377be97f8c8a4e90ce46f0a6ad7 *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/
Expand Down
158 changes: 79 additions & 79 deletions images/5-edge/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,98 +2,98 @@
set -euo pipefail

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

else

echo >&2 "👉 Start REDAXO setup..."
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 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."
# 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."

# install REDAXO via cli command if available (REDAXO 5.9+)
if php redaxo/bin/console setup:run; then
# install REDAXO via cli command if available (REDAXO 5.9+)
if php redaxo/bin/console setup:run; then

# 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."
# 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}");
# 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
fi
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
fi

# update file owner and group of writable folders (cache, data)
chown -R www-data:www-data redaxo/cache redaxo/data;
# update file owner and group of writable folders (cache, data)
chown -R www-data:www-data redaxo/cache redaxo/data;

# done!
echo >&2 " "
echo >&2 "🚀 REDAXO setup successful."
echo >&2 " "
# 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..."
# 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
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
Expand Down
Loading

0 comments on commit fd393ec

Please sign in to comment.