Skip to content

Commit 98cbd46

Browse files
authored
Merge pull request #450 from PrestaShop/php85
Added support for PHP 8.5
2 parents 0d5700f + d860575 commit 98cbd46

20 files changed

+4785
-0
lines changed

base/images/8.5-apache/Dockerfile

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Debian Trixie provides a package of the MySQL client that prevent the connexion to succeed for SSL reasons
2+
# We stick to Bookworm until we find the solution
3+
FROM php:8.5-apache-bookworm
4+
LABEL maintainer="PrestaShop Core Team <[email protected]>"
5+
6+
ENV PS_DOMAIN="<to be defined>" \
7+
DB_SERVER="<to be defined>" \
8+
DB_PORT=3306 \
9+
DB_NAME=prestashop \
10+
DB_USER=root \
11+
DB_PASSWD=admin \
12+
DB_PREFIX=ps_ \
13+
14+
ADMIN_PASSWD=prestashop_demo \
15+
PS_LANGUAGE=en \
16+
PS_COUNTRY=GB \
17+
PS_ALL_LANGUAGES=0 \
18+
PS_INSTALL_AUTO=0 \
19+
PS_ERASE_DB=0 \
20+
PS_INSTALL_DB=0 \
21+
PS_DEV_MODE=0 \
22+
PS_HOST_MODE=0 \
23+
PS_DEMO_MODE=0 \
24+
PS_ENABLE_SSL=0 \
25+
PS_HANDLE_DYNAMIC_DOMAIN=0 \
26+
PS_FOLDER_ADMIN=admin \
27+
PS_FOLDER_INSTALL=install
28+
29+
RUN apt-get update \
30+
&& apt-get install -y libmcrypt-dev \
31+
libjpeg62-turbo-dev \
32+
libpng-dev \
33+
libwebp-dev \
34+
libfreetype6-dev \
35+
libxml2-dev \
36+
libicu-dev \
37+
libzip-dev \
38+
default-mysql-client \
39+
wget \
40+
unzip \
41+
libonig-dev \
42+
&& rm -rf /var/lib/apt/lists/*
43+
44+
RUN if [[ "$(cat /etc/os-release)" == *"bookworm"* ]]; then apt-get update \
45+
&& apt-get install -y libpcre3-dev \
46+
&& rm -rf /var/lib/apt/lists/*; fi
47+
48+
RUN docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ --with-webp=/usr/include
49+
RUN docker-php-ext-install iconv intl pdo_mysql mbstring soap gd zip bcmath
50+
51+
RUN docker-php-source extract \
52+
&& if [ -d "/usr/src/php/ext/mysql" ]; then docker-php-ext-install mysql; fi \
53+
&& if [ -d "/usr/src/php/ext/mcrypt" ]; then docker-php-ext-install mcrypt; fi \
54+
&& if [ -d "/usr/src/php/ext/opcache" ]; then docker-php-ext-install opcache; fi \
55+
&& docker-php-source delete
56+
57+
# Prepare install and CMD script
58+
COPY config_files/ps-extractor.sh config_files/docker_run.sh config_files/docker_nightly_run.sh config_files/docker_branch_run.sh /tmp/
59+
60+
# If handle dynamic domain
61+
COPY config_files/docker_updt_ps_domains.php /tmp/
62+
63+
# PHP env for dev / demo modes
64+
COPY config_files/defines_custom.inc.php /tmp/
65+
RUN chown www-data:www-data /tmp/defines_custom.inc.php
66+
67+
# Apache configuration
68+
RUN if [ -x "$(command -v apache2-foreground)" ]; then a2enmod rewrite; fi
69+
70+
# PHP configuration
71+
COPY config_files/php.ini /usr/local/etc/php/
72+
73+
# Run
74+
CMD ["/tmp/docker_run.sh"]
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* Copyright since 2007 PrestaShop SA and Contributors
4+
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
5+
*
6+
* NOTICE OF LICENSE
7+
*
8+
* This source file is subject to the Open Software License (OSL 3.0)
9+
* that is bundled with this package in the file LICENSE.md.
10+
* It is also available through the world-wide-web at this URL:
11+
* https://opensource.org/licenses/OSL-3.0
12+
* If you did not receive a copy of the license and are unable to
13+
* obtain it through the world-wide-web, please send an email
14+
* to [email protected] so we can send you a copy immediately.
15+
*
16+
* DISCLAIMER
17+
*
18+
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
19+
* versions in the future. If you wish to customize PrestaShop for your
20+
* needs please refer to https://devdocs.prestashop-project.org/ for more information.
21+
*
22+
* @author PrestaShop SA and Contributors <[email protected]>
23+
* @copyright Since 2007 PrestaShop SA and Contributors
24+
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
25+
*/
26+
if ((bool) getenv('PS_DEV_MODE')) {
27+
define('_PS_MODE_DEV_', (bool) getenv('PS_DEV_MODE'));
28+
}
29+
// FYI: Defining env var _PS_HOST_MODE_ as true also works natively
30+
if ((bool) getenv('PS_HOST_MODE')) {
31+
define('_PS_HOST_MODE_', (bool) getenv('PS_HOST_MODE'));
32+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
2+
3+
# Clone repository
4+
if [ ! -f /var/www/html/composer.json ]; then
5+
echo Clone PrestaShop $PS_BRANCH
6+
git clone -b $PS_BRANCH https://github.com/PrestaShop/PrestaShop.git /var/www/html
7+
chown -R www-data:www-data /var/www/html
8+
fi
9+
10+
# Install composer
11+
if [ ! -f /usr/local/bin/composer ]; then
12+
echo "\n* Install composer ...";
13+
mkdir -p /var/www/.composer
14+
chown -R www-data:www-data /var/www/.composer
15+
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
16+
if [ ! -f /usr/local/bin/composer ]; then
17+
echo Composer installation failed
18+
exit 1
19+
fi
20+
fi
21+
22+
# Install vendor dependencies (vendor are always installed)
23+
if [ ! -f /var/www/html/vendor/autoload.php ]; then
24+
echo "\n* Running composer ...";
25+
pushd /var/www/html
26+
# Execute composer as default user so that we can set the env variables to increase timeout, also disable default_socket_timeout for php
27+
COMPOSER_PROCESS_TIMEOUT=600 COMPOSER_IPRESOLVE=4 php -ddefault_socket_timeout=-1 /usr/local/bin/composer install --ansi --prefer-dist --no-interaction --no-progress
28+
# Update the owner of composer installed folders to be www-data
29+
chown -R www-data:www-data vendor modules themes
30+
popd
31+
fi
32+
33+
# Build assets unless make is disabled (which can b the case when we only need PHP dependencies in CI)
34+
# If auto install is enabled though we must build the assets
35+
if [ "${DISABLE_MAKE}" != "1" ] || [ "${PS_INSTALL_AUTO}" == "1"]; then
36+
mkdir -p /var/www/.npm
37+
chown -R www-data:www-data /var/www/.npm
38+
39+
echo "\n* Install node $NODE_VERSION...";
40+
export NVM_DIR=/usr/local/nvm
41+
mkdir -p $NVM_DIR \
42+
&& curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash \
43+
&& . $NVM_DIR/nvm.sh \
44+
&& nvm install $NODE_VERSION \
45+
&& nvm alias default $NODE_VERSION \
46+
&& nvm use default
47+
48+
export NODE_PATH=$NVM_DIR/versions/node/v$NODE_VERSION/bin
49+
export PATH=$PATH:$NODE_PATH
50+
51+
pushd /var/www/html
52+
echo "\n* Build assets ...";
53+
runuser -g www-data -u www-data -- /usr/bin/make assets
54+
55+
echo "\n* Wait for assets built...";
56+
runuser -g www-data -u www-data -- /usr/bin/make wait-assets
57+
popd
58+
else
59+
echo "\n* Build of assets was disabled...";
60+
fi
61+
62+
/tmp/docker_run.sh
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
3+
# Download nightly build
4+
if [ ! -d /tmp/data-ps ]; then
5+
gsutil cp `gsutil ls gs://prestashop-core-nightly/ | grep -E "$PS_VERSION.+\.zip$" | tail -1` /tmp/prestashop.zip
6+
7+
mkdir -p /tmp/data-ps
8+
unzip -q /tmp/prestashop.zip -d /tmp/data-ps/
9+
10+
bash /tmp/ps-extractor.sh /tmp/data-ps
11+
12+
# Remove downloaded zip
13+
rm /tmp/prestashop.zip
14+
fi
15+
16+
/tmp/docker_run.sh
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
#!/bin/sh
2+
3+
if [ "$DB_SERVER" = "<to be defined>" -a $PS_INSTALL_AUTO = 1 ]; then
4+
echo >&2 'error: You requested automatic PrestaShop installation but MySQL server address is not provided '
5+
echo >&2 ' You need to specify DB_SERVER in order to proceed'
6+
exit 1
7+
elif [ "$DB_SERVER" != "<to be defined>" -a $PS_INSTALL_AUTO = 1 ]; then
8+
RET=1
9+
while [ $RET -ne 0 ]; do
10+
echo "\n* Checking if $DB_SERVER is available..."
11+
mysql -h $DB_SERVER -P $DB_PORT -u $DB_USER -p$DB_PASSWD -e "status" > /dev/null 2>&1
12+
RET=$?
13+
14+
if [ $RET -ne 0 ]; then
15+
echo "\n* Waiting for confirmation of MySQL service startup";
16+
sleep 5
17+
fi
18+
done
19+
echo "\n* DB server $DB_SERVER is available, let's continue !"
20+
fi
21+
22+
# From now, stop at error
23+
set -e
24+
25+
if [ ! -f ./config/settings.inc.php ] && [ ! -f ./app/config/parameters.php ] && [ ! -f ./install.lock ]; then
26+
27+
echo "\n* Setting up install lock file..."
28+
touch ./install.lock
29+
30+
echo "\n* Reapplying PrestaShop files for enabled volumes ...";
31+
32+
if [ -d /tmp/data-ps/prestashop ]; then
33+
# init if empty
34+
echo "\n* Copying files from tmp directory ...";
35+
cp -n -R -T -p /tmp/data-ps/prestashop/ /var/www/html
36+
else
37+
echo "\n* No files to copy from tmp directory ...";
38+
fi
39+
40+
if [ -f /tmp/defines_custom.inc.php ]; then
41+
cp -n -p /tmp/defines_custom.inc.php /var/www/html/config/defines_custom.inc.php
42+
fi
43+
44+
if [ -d /tmp/pre-install-scripts/ ]; then
45+
echo "\n* Running pre-install script(s)..."
46+
47+
for i in `ls /tmp/pre-install-scripts/`;do
48+
/tmp/pre-install-scripts/$i
49+
done
50+
else
51+
echo "\n* No pre-install script found, let's continue..."
52+
fi
53+
54+
if [ $PS_FOLDER_INSTALL != "install" ] && [ -d /var/www/html/install ]; then
55+
echo "\n* Renaming install folder as $PS_FOLDER_INSTALL ...";
56+
mv /var/www/html/install /var/www/html/$PS_FOLDER_INSTALL/
57+
fi
58+
59+
if [ $PS_FOLDER_ADMIN != "admin" ] && [ -d /var/www/html/admin ]; then
60+
echo "\n* Renaming admin folder as $PS_FOLDER_ADMIN ...";
61+
mv /var/www/html/admin /var/www/html/$PS_FOLDER_ADMIN/
62+
fi
63+
64+
if [ $PS_HANDLE_DYNAMIC_DOMAIN = 1 ]; then
65+
cp /tmp/docker_updt_ps_domains.php /var/www/html
66+
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
67+
fi
68+
69+
if [ $PS_ERASE_DB = 1 ]; then
70+
echo "\n* Drop mysql database...";
71+
echo "\n* Dropping existing database $DB_NAME..."
72+
mysql -h $DB_SERVER -P $DB_PORT -u $DB_USER -p$DB_PASSWD -e "drop database if exists $DB_NAME;"
73+
fi
74+
75+
if [ $PS_INSTALL_DB = 1 ]; then
76+
echo "\n* Create mysql database...";
77+
echo "\n* Creating database $DB_NAME..."
78+
mysqladmin -h $DB_SERVER -P $DB_PORT -u $DB_USER create $DB_NAME -p$DB_PASSWD --force;
79+
fi
80+
81+
if [ $PS_INSTALL_AUTO = 1 ]; then
82+
echo "\n* Installing PrestaShop, this may take a while ...";
83+
84+
if [ "$PS_DOMAIN" = "<to be defined>" ]; then
85+
export PS_DOMAIN=$(hostname -i)
86+
fi
87+
88+
echo "\n* Launching the installer script..."
89+
runuser -g www-data -u www-data -- php -d memory_limit=-1 /var/www/html/$PS_FOLDER_INSTALL/index_cli.php \
90+
--domain="$PS_DOMAIN" --db_server=$DB_SERVER:$DB_PORT --db_name="$DB_NAME" --db_user=$DB_USER \
91+
--db_password=$DB_PASSWD --prefix="$DB_PREFIX" --firstname="John" --lastname="Doe" \
92+
--password="$ADMIN_PASSWD" --email="$ADMIN_MAIL" --language=$PS_LANGUAGE --country=$PS_COUNTRY \
93+
--all_languages=$PS_ALL_LANGUAGES --newsletter=0 --send_email=0 --ssl=$PS_ENABLE_SSL
94+
95+
if [ $? -ne 0 ]; then
96+
echo 'warning: PrestaShop installation failed.'
97+
else
98+
echo "\n* Removing install folder..."
99+
rm -r /var/www/html/$PS_FOLDER_INSTALL/
100+
fi
101+
fi
102+
103+
if [ -d /tmp/post-install-scripts/ ]; then
104+
echo "\n* Running post-install script(s)..."
105+
106+
for i in `ls /tmp/post-install-scripts/`;do
107+
/tmp/post-install-scripts/$i
108+
done
109+
else
110+
echo "\n* No post-install script found, let's continue..."
111+
fi
112+
113+
echo "\n* Setup completed, removing lock file..."
114+
rm ./install.lock
115+
116+
elif [ ! -f ./config/settings.inc.php ] && [ ! -f ./app/config/parameters.php ] && [ -f ./install.lock ]; then
117+
118+
echo "\n* Another setup is currently running..."
119+
sleep 10
120+
exit 42
121+
122+
elif [ -f ./config/settings.inc.php ] && [ ! -f ./app/config/parameters.php ] && [ -f ./install.lock ]; then
123+
124+
echo "\n* Shop seems setup but remaining install lock still present..."
125+
sleep 10
126+
exit 42
127+
128+
else
129+
echo "\n* PrestaShop Core already installed...";
130+
fi
131+
132+
if [ $PS_DEMO_MODE -ne 0 ]; then
133+
echo "\n* Enabling DEMO mode ...";
134+
sed -ie "s/define('_PS_MODE_DEMO_', false);/define('_PS_MODE_DEMO_',\ true);/g" /var/www/html/config/defines.inc.php
135+
fi
136+
137+
echo "\n* Almost ! Starting web server now\n";
138+
139+
if [ -d /tmp/init-scripts/ ]; then
140+
echo "\n* Running init script(s)..."
141+
for i in `ls /tmp/init-scripts/`;do
142+
/tmp/init-scripts/$i
143+
done
144+
else
145+
echo "\n* No init script found, let's continue..."
146+
fi
147+
148+
exec apache2-foreground
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
/**
3+
* Copyright since 2007 PrestaShop SA and Contributors
4+
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
5+
*
6+
* NOTICE OF LICENSE
7+
*
8+
* This source file is subject to the Open Software License (OSL 3.0)
9+
* that is bundled with this package in the file LICENSE.md.
10+
* It is also available through the world-wide-web at this URL:
11+
* https://opensource.org/licenses/OSL-3.0
12+
* If you did not receive a copy of the license and are unable to
13+
* obtain it through the world-wide-web, please send an email
14+
* to [email protected] so we can send you a copy immediately.
15+
*
16+
* DISCLAIMER
17+
*
18+
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
19+
* versions in the future. If you wish to customize PrestaShop for your
20+
* needs please refer to https://devdocs.prestashop-project.org/ for more information.
21+
*
22+
* @author PrestaShop SA and Contributors <[email protected]>
23+
* @copyright Since 2007 PrestaShop SA and Contributors
24+
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
25+
*/
26+
27+
// Workaround for redirection on init
28+
$_POST['id_shop'] = 1;
29+
30+
require_once 'config/config.inc.php';
31+
32+
if (!defined('_PS_VERSION_'))
33+
exit;
34+
35+
// First, we get the URL used to reach this page.
36+
$domain = Tools::getHttpHost();
37+
$old_domain = Configuration::get('PS_SHOP_DOMAIN');
38+
39+
if (version_compare(_PS_VERSION_, '1.5', '>=') && $domain != $old_domain && !Shop::isFeatureActive())
40+
{
41+
$url = ShopUrl::getShopUrls(Configuration::get('PS_SHOP_DEFAULT'))->where('main', '=', 1)->getFirst();
42+
if ($url)
43+
{
44+
$url->domain = $domain;
45+
$url->domain_ssl = $domain;
46+
$url->save();
47+
48+
// Then, we update the configuration table
49+
Configuration::updateValue('PS_SHOP_DOMAIN', $domain);
50+
Configuration::updateValue('PS_SHOP_DOMAIN_SSL', $domain);
51+
52+
// Finally, update all the files that depend on the domain name
53+
Tools::generateHtaccess();
54+
Tools::generateRobotsFile();
55+
Tools::clearSmartyCache();
56+
Media::clearCache();
57+
}
58+
}
59+
60+
//unlink(__FILE__);
61+
Tools::redirect("index.php");
62+
die();

0 commit comments

Comments
 (0)