-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #403 from PrestaShop/fix-90x-docker
Fix 9.0.x docker
- Loading branch information
Showing
65 changed files
with
1,236 additions
and
59 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 |
---|---|---|
|
@@ -4,6 +4,6 @@ LABEL maintainer="PrestaShop Core Team <[email protected]>" | |
RUN apt update | ||
RUN apt -y install git | ||
|
||
RUN git clone -b $branch_version https://github.com/PrestaShop/PrestaShop.git /tmp/data-ps | ||
ENV PS_BRANCH=$branch_version | ||
|
||
CMD ["/tmp/docker_run.sh"] | ||
CMD ["/tmp/docker_branch_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 |
---|---|---|
|
@@ -111,3 +111,46 @@ $ nosetests --with-id 7 | |
``` | ||
This will also generate a `.nodeids` binary file, when you add new test methods you need to remove this file to re-generate the list of IDs. | ||
## Building and running PrestaShop docker locally | ||
First to make sure you will use the local docker containers and not the ones from Docker hub make sure you remove all existing PrestaShop images (including the base images) | ||
``` | ||
# This should be empty to be extra sure | ||
$ docker images | ||
``` | ||
Then you'll have to build the base image for the PHP version and server you are willing to use. If you are on MacOS this is crucial that you clean any image from cache and tun this locally, | ||
especially if your architecture is based on linux/arm64 (processor M1, M2, ...). | ||
```shell | ||
docker build base/images/8.3-apache -t prestashop/base:8.3-apache | ||
# You should see an image with Repository: prestashop Tag: 8.3-apache | ||
docker images | ||
``` | ||
Then you can build the image of the PrestaShop version you want to use: | ||
``` | ||
# Now build the PrestaShop version you want based on this local base image | ||
$ docker build images/9.0.x/8.3-apache -t prestashop/prestashop:9.0.x-8.3-apache | ||
``` | ||
Finally, you can launch your PrestaShop container using docker compose | ||
``` | ||
$ PS_VERSION=9.0.x PHP_VERSION=8.3 docker compose -f images/docker-compose.yml up | ||
``` | ||
Or you can use this script that performs these actions based on the arguments | ||
``` | ||
# Default values are nightly 8.3 apache | ||
./build-local-docker.sh 9.0.x 8.1 fpm | ||
``` | ||
Now you should be able to access a shop at this address: `http://localhost:8001/` | ||
The BO is accessible at `http://localhost:8001/admin-dev` with the following login: | ||
Email: `[email protected]` | ||
Password: `Correct Horse Battery Staple` |
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,27 @@ | ||
### Creating new base images | ||
|
||
To add new base versions update the `tags.txt` file to add a new version of PHP (usually one for apache and one for fpm) | ||
|
||
Then run the generation script: | ||
|
||
``` | ||
$ ./generate_tags.sh | ||
``` | ||
|
||
If you wan to force the regeneration of existing base images force it: | ||
|
||
```shell | ||
$ ./generate_tags.sh -f | ||
``` | ||
|
||
But be careful, for image with PHP <7.4 the installation of GD is different be careful not to remove this special line: | ||
|
||
``` | ||
# Not this line: | ||
RUN docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ --with-webp=/usr/include | ||
But those lines instead: | ||
# PHP < 7.4 have an old syntax to install GD. See https://github.com/docker-library/php/issues/912 | ||
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-webp-dir=/usr/include | ||
``` |
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,61 @@ | ||
#!/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 | ||
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 | ||
if [ "${DISABLE_MAKE}" != "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
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,61 @@ | ||
#!/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 | ||
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 | ||
if [ "${DISABLE_MAKE}" != "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
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,61 @@ | ||
#!/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 | ||
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 | ||
if [ "${DISABLE_MAKE}" != "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
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
Oops, something went wrong.