-
Notifications
You must be signed in to change notification settings - Fork 182
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
24 changed files
with
4,790 additions
and
6 deletions.
There are no files selected for viewing
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,69 @@ | ||
FROM php:8.4-apache | ||
LABEL maintainer="PrestaShop Core Team <[email protected]>" | ||
|
||
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 | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y libmcrypt-dev \ | ||
libjpeg62-turbo-dev \ | ||
libpcre3-dev \ | ||
libpng-dev \ | ||
libwebp-dev \ | ||
libfreetype6-dev \ | ||
libxml2-dev \ | ||
libicu-dev \ | ||
libzip-dev \ | ||
default-mysql-client \ | ||
wget \ | ||
unzip \ | ||
libonig-dev | ||
|
||
RUN rm -rf /var/lib/apt/lists/* | ||
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 | ||
|
||
# Prepare install and CMD script | ||
COPY config_files/ps-extractor.sh config_files/docker_run.sh config_files/docker_nightly_run.sh config_files/docker_branch_run.sh /tmp/ | ||
|
||
# If handle dynamic domain | ||
COPY config_files/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 | ||
|
||
# Apache configuration | ||
RUN if [ -x "$(command -v apache2-foreground)" ]; then a2enmod rewrite; fi | ||
|
||
# PHP configuration | ||
COPY config_files/php.ini /usr/local/etc/php/ | ||
|
||
# Run | ||
CMD ["/tmp/docker_run.sh"] |
32 changes: 32 additions & 0 deletions
32
base/images/8.4-apache/config_files/defines_custom.inc.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
/** | ||
* Copyright since 2007 PrestaShop SA and Contributors | ||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Open Software License (OSL 3.0) | ||
* that is bundled with this package in the file LICENSE.md. | ||
* It is also available through the world-wide-web at this URL: | ||
* https://opensource.org/licenses/OSL-3.0 | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to [email protected] so we can send you a copy immediately. | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer | ||
* versions in the future. If you wish to customize PrestaShop for your | ||
* needs please refer to https://devdocs.prestashop-project.org/ for more information. | ||
* | ||
* @author PrestaShop SA and Contributors <[email protected]> | ||
* @copyright Since 2007 PrestaShop SA and Contributors | ||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) | ||
*/ | ||
if ((bool) getenv('PS_DEV_MODE')) { | ||
define('_PS_MODE_DEV_', (bool) getenv('PS_DEV_MODE')); | ||
} | ||
// FYI: Defining env var _PS_HOST_MODE_ as true also works natively | ||
if ((bool) getenv('PS_HOST_MODE')) { | ||
define('_PS_HOST_MODE_', (bool) getenv('PS_HOST_MODE')); | ||
} |
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,62 @@ | ||
#!/bin/bash | ||
|
||
# Clone repository | ||
if [ ! -f /var/www/html/composer.json ]; then | ||
echo Clone PrestaShop $PS_BRANCH | ||
git clone -b $PS_BRANCH https://github.com/PrestaShop/PrestaShop.git /var/www/html | ||
chown -R www-data:www-data /var/www/html | ||
fi | ||
|
||
# Install composer | ||
if [ ! -f /usr/local/bin/composer ]; then | ||
echo "\n* Install composer ..."; | ||
mkdir -p /var/www/.composer | ||
chown -R www-data:www-data /var/www/.composer | ||
runuser -g www-data -u www-data -- php -r "copy('https://getcomposer.org/installer', '/tmp/composer-setup.php');" && php /tmp/composer-setup.php --no-ansi --install-dir=/usr/local/bin --filename=composer && rm -rf /tmp/composer-setup.php | ||
if [ ! -f /usr/local/bin/composer ]; then | ||
echo Composer installation failed | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# Install vendor dependencies (vendor are always installed) | ||
if [ ! -f /var/www/html/vendor/autoload.php ]; then | ||
echo "\n* Running composer ..."; | ||
pushd /var/www/html | ||
# Execute composer as default user so that we can set the env variables to increase timeout, also disable default_socket_timeout for php | ||
COMPOSER_PROCESS_TIMEOUT=600 COMPOSER_IPRESOLVE=4 php -ddefault_socket_timeout=-1 /usr/local/bin/composer install --ansi --prefer-dist --no-interaction --no-progress | ||
# Update the owner of composer installed folders to be www-data | ||
chown -R www-data:www-data vendor modules themes | ||
popd | ||
fi | ||
|
||
# Build assets unless make is disabled (which can b the case when we only need PHP dependencies in CI) | ||
# If auto install is enabled though we must build the assets | ||
if [ "${DISABLE_MAKE}" != "1" ] || [ "${PS_INSTALL_AUTO}" == "1"]; then | ||
mkdir -p /var/www/.npm | ||
chown -R www-data:www-data /var/www/.npm | ||
|
||
echo "\n* Install node $NODE_VERSION..."; | ||
export NVM_DIR=/usr/local/nvm | ||
mkdir -p $NVM_DIR \ | ||
&& curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash \ | ||
&& . $NVM_DIR/nvm.sh \ | ||
&& nvm install $NODE_VERSION \ | ||
&& nvm alias default $NODE_VERSION \ | ||
&& nvm use default | ||
|
||
export NODE_PATH=$NVM_DIR/versions/node/v$NODE_VERSION/bin | ||
export PATH=$PATH:$NODE_PATH | ||
|
||
pushd /var/www/html | ||
echo "\n* Build assets ..."; | ||
runuser -g www-data -u www-data -- /usr/bin/make assets | ||
|
||
echo "\n* Wait for assets built..."; | ||
runuser -g www-data -u www-data -- /usr/bin/make wait-assets | ||
popd | ||
else | ||
echo "\n* Build of assets was disabled..."; | ||
fi | ||
|
||
/tmp/docker_run.sh |
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,16 @@ | ||
#!/bin/sh | ||
|
||
# Download nightly build | ||
if [ ! -d /tmp/data-ps ]; then | ||
gsutil cp `gsutil ls gs://prestashop-core-nightly/ | grep -E 'develop.+\.zip$$' | tail -1` /tmp/prestashop.zip | ||
|
||
mkdir -p /tmp/data-ps | ||
unzip -q /tmp/prestashop.zip -d /tmp/data-ps/ | ||
|
||
bash /tmp/ps-extractor.sh /tmp/data-ps | ||
|
||
# Remove downloaded zip | ||
rm /tmp/prestashop.zip | ||
fi | ||
|
||
/tmp/docker_run.sh |
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,148 @@ | ||
#!/bin/sh | ||
|
||
if [ "$DB_SERVER" = "<to be defined>" -a $PS_INSTALL_AUTO = 1 ]; then | ||
echo >&2 'error: You requested automatic PrestaShop installation but MySQL server address is not provided ' | ||
echo >&2 ' You need to specify DB_SERVER in order to proceed' | ||
exit 1 | ||
elif [ "$DB_SERVER" != "<to be defined>" -a $PS_INSTALL_AUTO = 1 ]; then | ||
RET=1 | ||
while [ $RET -ne 0 ]; do | ||
echo "\n* Checking if $DB_SERVER is available..." | ||
mysql -h $DB_SERVER -P $DB_PORT -u $DB_USER -p$DB_PASSWD -e "status" > /dev/null 2>&1 | ||
RET=$? | ||
|
||
if [ $RET -ne 0 ]; then | ||
echo "\n* Waiting for confirmation of MySQL service startup"; | ||
sleep 5 | ||
fi | ||
done | ||
echo "\n* DB server $DB_SERVER is available, let's continue !" | ||
fi | ||
|
||
# From now, stop at error | ||
set -e | ||
|
||
if [ ! -f ./config/settings.inc.php ] && [ ! -f ./install.lock ]; then | ||
|
||
echo "\n* Setting up install lock file..." | ||
touch ./install.lock | ||
|
||
echo "\n* Reapplying PrestaShop files for enabled volumes ..."; | ||
|
||
if [ -d /tmp/data-ps/prestashop ]; then | ||
# init if empty | ||
echo "\n* Copying files from tmp directory ..."; | ||
cp -n -R -T -p /tmp/data-ps/prestashop/ /var/www/html | ||
else | ||
echo "\n* No files to copy from tmp directory ..."; | ||
fi | ||
|
||
if [ -f /tmp/defines_custom.inc.php ]; then | ||
cp -n -p /tmp/defines_custom.inc.php /var/www/html/config/defines_custom.inc.php | ||
fi | ||
|
||
if [ -d /tmp/pre-install-scripts/ ]; then | ||
echo "\n* Running pre-install script(s)..." | ||
|
||
for i in `ls /tmp/pre-install-scripts/`;do | ||
/tmp/pre-install-scripts/$i | ||
done | ||
else | ||
echo "\n* No pre-install script found, let's continue..." | ||
fi | ||
|
||
if [ $PS_FOLDER_INSTALL != "install" ] && [ -d /var/www/html/install ]; then | ||
echo "\n* Renaming install folder as $PS_FOLDER_INSTALL ..."; | ||
mv /var/www/html/install /var/www/html/$PS_FOLDER_INSTALL/ | ||
fi | ||
|
||
if [ $PS_FOLDER_ADMIN != "admin" ] && [ -d /var/www/html/admin ]; then | ||
echo "\n* Renaming admin folder as $PS_FOLDER_ADMIN ..."; | ||
mv /var/www/html/admin /var/www/html/$PS_FOLDER_ADMIN/ | ||
fi | ||
|
||
if [ $PS_HANDLE_DYNAMIC_DOMAIN = 1 ]; then | ||
cp /tmp/docker_updt_ps_domains.php /var/www/html | ||
sed -ie "s/DirectoryIndex\ index.php\ index.html/DirectoryIndex\ docker_updt_ps_domains.php\ index.php\ index.html/g" $APACHE_CONFDIR/conf-available/docker-php.conf | ||
fi | ||
|
||
if [ $PS_ERASE_DB = 1 ]; then | ||
echo "\n* Drop mysql database..."; | ||
echo "\n* Dropping existing database $DB_NAME..." | ||
mysql -h $DB_SERVER -P $DB_PORT -u $DB_USER -p$DB_PASSWD -e "drop database if exists $DB_NAME;" | ||
fi | ||
|
||
if [ $PS_INSTALL_DB = 1 ]; then | ||
echo "\n* Create mysql database..."; | ||
echo "\n* Creating database $DB_NAME..." | ||
mysqladmin -h $DB_SERVER -P $DB_PORT -u $DB_USER create $DB_NAME -p$DB_PASSWD --force; | ||
fi | ||
|
||
if [ $PS_INSTALL_AUTO = 1 ]; then | ||
echo "\n* Installing PrestaShop, this may take a while ..."; | ||
|
||
if [ "$PS_DOMAIN" = "<to be defined>" ]; then | ||
export PS_DOMAIN=$(hostname -i) | ||
fi | ||
|
||
echo "\n* Launching the installer script..." | ||
runuser -g www-data -u www-data -- php -d memory_limit=-1 /var/www/html/$PS_FOLDER_INSTALL/index_cli.php \ | ||
--domain="$PS_DOMAIN" --db_server=$DB_SERVER:$DB_PORT --db_name="$DB_NAME" --db_user=$DB_USER \ | ||
--db_password=$DB_PASSWD --prefix="$DB_PREFIX" --firstname="John" --lastname="Doe" \ | ||
--password="$ADMIN_PASSWD" --email="$ADMIN_MAIL" --language=$PS_LANGUAGE --country=$PS_COUNTRY \ | ||
--all_languages=$PS_ALL_LANGUAGES --newsletter=0 --send_email=0 --ssl=$PS_ENABLE_SSL | ||
|
||
if [ $? -ne 0 ]; then | ||
echo 'warning: PrestaShop installation failed.' | ||
else | ||
echo "\n* Removing install folder..." | ||
rm -r /var/www/html/$PS_FOLDER_INSTALL/ | ||
fi | ||
fi | ||
|
||
if [ -d /tmp/post-install-scripts/ ]; then | ||
echo "\n* Running post-install script(s)..." | ||
|
||
for i in `ls /tmp/post-install-scripts/`;do | ||
/tmp/post-install-scripts/$i | ||
done | ||
else | ||
echo "\n* No post-install script found, let's continue..." | ||
fi | ||
|
||
echo "\n* Setup completed, removing lock file..." | ||
rm ./install.lock | ||
|
||
elif [ ! -f ./config/settings.inc.php ] && [ -f ./install.lock ]; then | ||
|
||
echo "\n* Another setup is currently running..." | ||
sleep 10 | ||
exit 42 | ||
|
||
elif [ -f ./config/settings.inc.php ] && [ -f ./install.lock ]; then | ||
|
||
echo "\n* Shop seems setup but remaining install lock still present..." | ||
sleep 10 | ||
exit 42 | ||
|
||
else | ||
echo "\n* PrestaShop Core already installed..."; | ||
fi | ||
|
||
if [ $PS_DEMO_MODE -ne 0 ]; then | ||
echo "\n* Enabling DEMO mode ..."; | ||
sed -ie "s/define('_PS_MODE_DEMO_', false);/define('_PS_MODE_DEMO_',\ true);/g" /var/www/html/config/defines.inc.php | ||
fi | ||
|
||
echo "\n* Almost ! Starting web server now\n"; | ||
|
||
if [ -d /tmp/init-scripts/ ]; then | ||
echo "\n* Running init script(s)..." | ||
for i in `ls /tmp/init-scripts/`;do | ||
/tmp/init-scripts/$i | ||
done | ||
else | ||
echo "\n* No init script found, let's continue..." | ||
fi | ||
|
||
exec apache2-foreground |
Oops, something went wrong.