forked from PrestaShop/docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
144 additions
and
2,057 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/sh | ||
set -eu | ||
|
||
error() { | ||
printf "\e[1;31m%s\e[0m" "${1:-Unknown error}" | ||
exit "${2:-1}" | ||
} | ||
|
||
[ -z "$PHP_ENV" ] && error "PHP_ENV is not set" 2 | ||
[ -z "$PHP_VERSION" ] && error "PHP_VERSION is not set" 3 | ||
|
||
PS_PHP_EXT="bcmath fileinfo gd intl mbstring pdo_mysql simplexml soap zip"; | ||
PHP_GD_CONFIG="--with-jpeg"; | ||
#gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ --with-webp=/usr/include | ||
|
||
if [ "7.1" = "$PHP_VERSION" ]; then | ||
PS_PHP_EXT="$PS_PHP_EXT mcrypt"; | ||
PHP_GD_CONFIG="--with-gd --with-jpeg --with-jpeg-dir --with-zlib-dir"; | ||
elif [ "7.2" = "$PHP_VERSION" ] || [ "7.3" = "$PHP_VERSION" ]; then | ||
PHP_GD_CONFIG="--with-jpeg-dir --with-zlib-dir"; | ||
fi | ||
|
||
# shellcheck disable=SC2086 | ||
docker-php-ext-configure gd $PHP_GD_CONFIG | ||
# shellcheck disable=SC2086 | ||
docker-php-ext-install $PS_PHP_EXT; | ||
|
||
if [ "production" = "$PHP_ENV" ]; then | ||
mv "${PHP_INI_DIR}/php.ini-production" "${PHP_INI_DIR}/php.ini" | ||
rm -f "${PHP_INI_DIR}/php.ini-development"; | ||
else | ||
mv "${PHP_INI_DIR}/php.ini-development" "${PHP_INI_DIR}/php.ini" | ||
rm -f "${PHP_INI_DIR}/php.ini-production"; | ||
sed -i 's/memory_limit = .*/memory_limit = -1/' "${PHP_INI_DIR}/php.ini" | ||
fi | ||
|
||
# Remove php assets that might have been installed by package unaware of $PHP_INI_DIR | ||
rm -rf /etc/php* /usr/lib/php* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,92 +7,94 @@ ARG PHP_FLAVOUR | |
# ================================== | ||
FROM php:${PHP_FLAVOUR} AS alpine-base-prestashop | ||
ARG PS_VERSION | ||
ARG PS_FOLDER=/var/www/html | ||
|
||
ENV PS_DOMAIN="<to be defined>" \ | ||
DB_SERVER="<to be defined>" \ | ||
DB_PORT=3306 \ | ||
DB_NAME=prestashop \ | ||
DB_USER=root \ | ||
DB_PASSWD=admin \ | ||
DB_PREFIX=ps_ \ | ||
[email protected] \ | ||
ADMIN_PASSWD=prestashop_demo \ | ||
PS_LANGUAGE=en \ | ||
PS_COUNTRY=GB \ | ||
PS_ALL_LANGUAGES=0 \ | ||
PS_INSTALL_AUTO=0 \ | ||
PS_ERASE_DB=0 \ | ||
PS_INSTALL_DB=0 \ | ||
PS_DEV_MODE=0 \ | ||
PS_HOST_MODE=0 \ | ||
PS_DEMO_MODE=0 \ | ||
PS_ENABLE_SSL=0 \ | ||
PS_HANDLE_DYNAMIC_DOMAIN=0 \ | ||
PS_FOLDER_ADMIN=admin \ | ||
PS_FOLDER_INSTALL=install \ | ||
PHP_ENV=production | ||
|
||
# The PHP configuration script | ||
COPY ./assets/php-configuration.sh /tmp/ | ||
|
||
# Install base tools | ||
RUN \ | ||
apk --no-cache add -U \ | ||
bash less vim geoip git tzdata zip curl \ | ||
nginx nginx-mod-http-headers-more nginx-mod-http-geoip \ | ||
nginx-mod-stream nginx-mod-stream-geoip ca-certificates \ | ||
libmcrypt gnu-libiconv-libs php81-common && \ | ||
rm -rf /var/cache/apk/* | ||
|
||
# Install PHP requirements | ||
# see: https://olvlvl.com/2019-06-install-php-ext-source | ||
ENV GD_DEPS="zlib-dev libjpeg-turbo-dev libpng-dev" | ||
ENV ZIP_DEPS="libzip-dev" | ||
ENV INTL_DEPS="icu-dev" | ||
RUN apk --no-cache add -U $GD_DEPS $ZIP_DEPS $INTL_DEPS \ | ||
&& docker-php-ext-configure gd --with-jpeg \ | ||
&& docker-php-ext-install gd pdo_mysql zip intl; | ||
# docker-php-ext-enable opcache | ||
|
||
RUN docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ --with-webp=/usr/include | ||
RUN docker-php-ext-install iconv intl pdo_mysql mbstring soap gd zip bcmath | ||
|
||
RUN docker-php-source extract \ | ||
&& if [ -d "/usr/src/php/ext/mysql" ]; then docker-php-ext-install mysql; fi \ | ||
&& if [ -d "/usr/src/php/ext/mcrypt" ]; then docker-php-ext-install mcrypt; fi \ | ||
&& if [ -d "/usr/src/php/ext/opcache" ]; then docker-php-ext-install opcache; fi \ | ||
&& docker-php-source delete | ||
ca-certificates geoip tzdata zip curl jq make \ | ||
gnu-libiconv php-common mariadb-client oniguruma-dev \ | ||
zlib-dev libzip-dev libjpeg-turbo-dev libpng-dev \ | ||
icu-dev libmcrypt-dev libxml2 libxml2-dev \ | ||
&& /tmp/php-configuration.sh \ | ||
&& apk del make \ | ||
&& rm -rf /var/cache/apk/* | ||
|
||
# The PrestaShop docker entrypoint | ||
COPY config_files/docker_run.sh /tmp/ | ||
COPY ./assets/docker_run.sh /tmp/ | ||
|
||
# Handling a dynamic domain | ||
COPY config_files/docker_updt_ps_domains.php /tmp/ | ||
# Probably, or at least its usage must be described in the README file | ||
# COPY ./assets/docker_updt_ps_domains.php /tmp/ | ||
|
||
# PHP env for dev / demo modes | ||
COPY config_files/defines_custom.inc.php /tmp/ | ||
RUN chown www-data:www-data /tmp/defines_custom.inc.php | ||
# COPY ./assets/defines_custom.inc.php /tmp/ | ||
# RUN chown www-data:www-data /tmp/defines_custom.inc.php | ||
|
||
# Apache configuration | ||
RUN if [ -x "$(command -v apache2-foreground)" ]; then a2enmod rewrite; fi | ||
|
||
# PHP configuration | ||
COPY config_files/php.ini /usr/local/etc/php/ | ||
|
||
# @TODO check opcache | ||
# RUN echo '\ | ||
# opcache.interned_strings_buffer=16\n\ | ||
# opcache.load_comments=Off\n\ | ||
# opcache.max_accelerated_files=16000\n\ | ||
# opcache.save_comments=Off\n\ | ||
# ' >> /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini | ||
|
||
# Disable IPv6 | ||
# RUN echo "net.ipv6.conf.all.disable_ipv6 = 1" | tee /etc/sysctl.conf | ||
RUN if [ -x "$(command -v apache2-foreground)" ]; then \ | ||
a2enmod rewrite;\ | ||
fi | ||
|
||
# ========================================= | ||
# Stage 2/3: PrestaShop sources downloader | ||
# ========================================= | ||
FROM alpine-base-prestashop AS alpine-download-prestashop | ||
ARG PS_VERSION | ||
ENV PS_FOLDER=/tmp/prestashop | ||
|
||
RUN apk --no-cache add -U git jq make | ||
|
||
# Get PrestaShop source code | ||
RUN if [[ "$PS_VERSION" == "nightly" ]]; then \ | ||
git clone --depth 1 'https://github.com/PrestaShop/PrestaShop.git' /tmp/prestashop; \ | ||
rm -rf /tmp/prestashop/.git; \ | ||
make install; \ | ||
echo "Unsupported yet: https://prestashop.slack.com/archives/C03LFE4KV6K/p1703170152828039" \ | ||
&& exit 1; \ | ||
else \ | ||
DOWNLOAD_URL=$(curl -s -L --request GET 'https://api.github.com/repos/prestashop/prestashop/releases/latest' | jq -r '.assets[] | select(.name | contains(".zip")) | .browser_download_url'); \ | ||
curl -s -L -o /tmp/prestashop.zip "${DOWNLOAD_URL}"; \ | ||
unzip -n -q /tmp/prestashop.zip -d /tmp/prestashop; \ | ||
curl -s -L -o /tmp/prestashop.zip "https://github.com/PrestaShop/PrestaShop/releases/download/${PS_VERSION}/prestashop_${PS_VERSION}.zip"; \ | ||
fi | ||
|
||
# Extract the souces | ||
RUN mkdir -p "$PS_FOLDER" /tmp/unzip-ps \ | ||
&& unzip -n -q /tmp/prestashop.zip -d /tmp/unzip-ps \ | ||
&& ([ -f /tmp/unzip-ps/prestashop.zip ] \ | ||
&& unzip -n -q /tmp/unzip-ps/prestashop.zip -d "$PS_FOLDER" \ | ||
|| mv /tmp/unzip-ps/prestashop/* "$PS_FOLDER") | ||
|
||
# ============================ | ||
# Stage 3/3: Production image | ||
# ============================ | ||
FROM alpine-base-prestashop | ||
ARG PS_FOLDER=/var/www/html | ||
ARG PS_FOLDER=/var/www/html/prestashop | ||
|
||
LABEL maintainer="PrestaShop Core Team <[email protected]>" | ||
|
||
ENV PS_VERSION $PS_VERSION | ||
|
||
# Copy the PrestaShop sources | ||
COPY --chown=www-data:www-data --from=alpine-download-prestashop /tmp/prestashop ${PS_FOLDER}/prestashop | ||
COPY --chown=www-data:www-data --from=alpine-download-prestashop /tmp/prestashop ${PS_FOLDER} | ||
|
||
CMD ["/tmp/docker_run.sh"] |
Oops, something went wrong.