Skip to content

Commit 5e17660

Browse files
committed
Add PHP 8.4
1 parent 7ebdd8b commit 5e17660

24 files changed

+4790
-6
lines changed

HOW-TO-USE.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,22 +125,22 @@ Then you'll have to build the base image for the PHP version and server you are
125125
especially if your architecture is based on linux/arm64 (processor M1, M2, ...).
126126
127127
```shell
128-
docker build base/images/8.3-apache -t prestashop/base:8.3-apache
129-
# You should see an image with Repository: prestashop Tag: 8.3-apache
128+
docker build base/images/8.4-apache -t prestashop/base:8.4-apache
129+
# You should see an image with Repository: prestashop Tag: 8.4-apache
130130
docker images
131131
```
132132
133133
Then you can build the image of the PrestaShop version you want to use:
134134
135135
```
136136
# Now build the PrestaShop version you want based on this local base image
137-
$ docker build images/9.0.x/8.3-apache -t prestashop/prestashop:9.0.x-8.3-apache
137+
$ docker build images/9.0.x/8.4-apache -t prestashop/prestashop:9.0.x-8.4-apache
138138
```
139139
140140
Finally, you can launch your PrestaShop container using docker compose
141141
142142
```
143-
$ PS_VERSION=9.0.x PHP_VERSION=8.3 docker compose -f images/docker-compose.yml up
143+
$ PS_VERSION=9.0.x PHP_VERSION=8.4 docker compose -f images/docker-compose.yml up
144144
```
145145
146146
Or you can use the `build-local-docker.sh` script that performs these actions based on the options
@@ -153,7 +153,7 @@ Or you can use the `build-local-docker.sh` script that performs these actions ba
153153
# -p PHP_VERSION (7.1, 8.2, ...)
154154
# -l Launch shop thanks to a docker compose (default false)
155155
#
156-
# Default values are nightly 8.3 apache
156+
# Default values are nightly 8.4 apache
157157
158158
$ ./build-local-docker.sh -v 9.0.x -p 8.1 -s fpm
159159
```

base/images/8.4-apache/Dockerfile

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
FROM php:8.4-apache
2+
LABEL maintainer="PrestaShop Core Team <coreteam@prestashop.com>"
3+
4+
ENV PS_DOMAIN="<to be defined>" \
5+
DB_SERVER="<to be defined>" \
6+
DB_PORT=3306 \
7+
DB_NAME=prestashop \
8+
DB_USER=root \
9+
DB_PASSWD=admin \
10+
DB_PREFIX=ps_ \
11+
ADMIN_MAIL=demo@prestashop.com \
12+
ADMIN_PASSWD=prestashop_demo \
13+
PS_LANGUAGE=en \
14+
PS_COUNTRY=GB \
15+
PS_ALL_LANGUAGES=0 \
16+
PS_INSTALL_AUTO=0 \
17+
PS_ERASE_DB=0 \
18+
PS_INSTALL_DB=0 \
19+
PS_DEV_MODE=0 \
20+
PS_HOST_MODE=0 \
21+
PS_DEMO_MODE=0 \
22+
PS_ENABLE_SSL=0 \
23+
PS_HANDLE_DYNAMIC_DOMAIN=0 \
24+
PS_FOLDER_ADMIN=admin \
25+
PS_FOLDER_INSTALL=install
26+
27+
RUN apt-get update \
28+
&& apt-get install -y libmcrypt-dev \
29+
libjpeg62-turbo-dev \
30+
libpcre3-dev \
31+
libpng-dev \
32+
libwebp-dev \
33+
libfreetype6-dev \
34+
libxml2-dev \
35+
libicu-dev \
36+
libzip-dev \
37+
default-mysql-client \
38+
wget \
39+
unzip \
40+
libonig-dev
41+
42+
RUN rm -rf /var/lib/apt/lists/*
43+
RUN docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ --with-webp=/usr/include
44+
RUN docker-php-ext-install iconv intl pdo_mysql mbstring soap gd zip bcmath
45+
46+
RUN docker-php-source extract \
47+
&& if [ -d "/usr/src/php/ext/mysql" ]; then docker-php-ext-install mysql; fi \
48+
&& if [ -d "/usr/src/php/ext/mcrypt" ]; then docker-php-ext-install mcrypt; fi \
49+
&& if [ -d "/usr/src/php/ext/opcache" ]; then docker-php-ext-install opcache; fi \
50+
&& docker-php-source delete
51+
52+
# Prepare install and CMD script
53+
COPY config_files/ps-extractor.sh config_files/docker_run.sh config_files/docker_nightly_run.sh config_files/docker_branch_run.sh /tmp/
54+
55+
# If handle dynamic domain
56+
COPY config_files/docker_updt_ps_domains.php /tmp/
57+
58+
# PHP env for dev / demo modes
59+
COPY config_files/defines_custom.inc.php /tmp/
60+
RUN chown www-data:www-data /tmp/defines_custom.inc.php
61+
62+
# Apache configuration
63+
RUN if [ -x "$(command -v apache2-foreground)" ]; then a2enmod rewrite; fi
64+
65+
# PHP configuration
66+
COPY config_files/php.ini /usr/local/etc/php/
67+
68+
# Run
69+
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 license@prestashop.com 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 <contact@prestashop.com>
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 'develop.+\.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 ./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 ./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 ./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

0 commit comments

Comments
 (0)