Skip to content

Commit

Permalink
fix(build): old base image (PrestaShop#148)
Browse files Browse the repository at this point in the history
Co-authored-by: Alexandre Lematre <[email protected]>
  • Loading branch information
jokesterfr and Alexandre-Lematre authored Feb 11, 2025
1 parent f1e5ff9 commit 9ea9477
Show file tree
Hide file tree
Showing 11 changed files with 172 additions and 118 deletions.
72 changes: 41 additions & 31 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,40 +80,31 @@ jobs:
env:
PS_VERSION: ${{ matrix.ps_version }}
REBUILD_BASE: "true"
TARGET_IMAGE: "flashlight:${{ matrix.ps_version }}"

- name: Test the image with a dry run
run: docker run --env PS_DOMAIN='localhost:80' --env DRY_RUN='true' $DOCKER_IMAGE
env:
DOCKER_IMAGE: prestashop/prestashop-flashlight:${{ matrix.ps_version }}
run: docker run --env PS_DOMAIN='localhost:80' --env DRY_RUN='true' flashlight:${{ matrix.ps_version }}

- name: Test the image tooling(composer)
run: docker run --env PS_DOMAIN='localhost:80' --entrypoint composer $DOCKER_IMAGE --version
env:
DOCKER_IMAGE: prestashop/prestashop-flashlight:${{ matrix.ps_version }}
run: docker run --env PS_DOMAIN='localhost:80' --entrypoint composer flashlight:${{ matrix.ps_version }} --version

- name: Test the image tooling(phpunit)
run: docker run --env PS_DOMAIN='localhost:80' --entrypoint phpunit $DOCKER_IMAGE --version
env:
DOCKER_IMAGE: prestashop/prestashop-flashlight:${{ matrix.ps_version }}
run: docker run --env PS_DOMAIN='localhost:80' --entrypoint phpunit flashlight:${{ matrix.ps_version }} --version

- name: Test the image tooling(phpstan)
run: docker run --env PS_DOMAIN='localhost:80' --entrypoint phpstan $DOCKER_IMAGE --version
env:
DOCKER_IMAGE: prestashop/prestashop-flashlight:${{ matrix.ps_version }}
run: docker run --env PS_DOMAIN='localhost:80' --entrypoint phpstan flashlight:${{ matrix.ps_version }} --version

- name: Test the image tooling(xdebug)
run: docker run --env PS_DOMAIN='localhost:80' --entrypoint bash $DOCKER_IMAGE -c 'php -m -c | grep xdebug'
env:
DOCKER_IMAGE: prestashop/prestashop-flashlight:${{ matrix.ps_version }}
run: docker run --env PS_DOMAIN='localhost:80' --entrypoint bash flashlight:${{ matrix.ps_version }} -c 'php -m -c | grep xdebug'

docker_build_old_php:
name: "Docker build: PrestaShop with PHP 5.6"
docker_build_base_alpine:
name: "Docker build: PrestaShop with PHP ${{ matrix.php_version }} alpine"
runs-on: ubuntu-latest
timeout-minutes: 45
strategy:
fail-fast: true
matrix:
os_version: ["alpine", "debian"]
php_version: ["5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3"]
needs: [docker_dry_build]
steps:
- name: Checkout repository
Expand All @@ -122,15 +113,37 @@ jobs:
- name: Call the docker build chain
run: ./build.sh
env:
PS_VERSION: 1.6.1.24
PHP_VERSION: 5.6
OS_VERSION: ${{ matrix.os_version }}
REBUILD_BASE: "true"
PHP_VERSION: ${{ matrix.php_version }}
OS_FLAVOUR: alpine
TARGET_IMAGE: "flashlight:test"
BASE_ONLY: "true"

- name: Test the image with a dry run
run: docker run --env PS_DOMAIN='localhost:80' --env DRY_RUN='true' $DOCKER_IMAGE
run: docker run --env PS_DOMAIN='localhost:80' --env DRY_RUN='true' --user www-data flashlight:test

docker_build_base_debian:
name: "Docker build: PrestaShop with PHP ${{ matrix.php_version }} debian"
runs-on: ubuntu-latest
timeout-minutes: 45
strategy:
fail-fast: true
matrix:
php_version: ["8.0", "8.1", "8.2", "8.3"]
needs: [docker_dry_build]
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Call the docker build chain
run: ./build.sh
env:
DOCKER_IMAGE: prestashop/prestashop-flashlight:1.6.1.24-${{ matrix.os_version }}
PHP_VERSION: ${{ matrix.php_version }}
OS_FLAVOUR: debian
TARGET_IMAGE: "flashlight:test"
BASE_ONLY: "true"

- name: Test the image with a dry run
run: docker run --env PS_DOMAIN='localhost:80' --env DRY_RUN='true' --user www-data flashlight:test

docker_build_debian:
name: "Docker build: PS ${{ matrix.ps_version }} for debian"
Expand All @@ -140,7 +153,7 @@ jobs:
strategy:
fail-fast: true
matrix:
ps_version: ["1.6.1.24", "1.7.6.9", "1.7.7.8", "1.7.8.11", "8.1.7"]
ps_version: ["8.1.7"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -150,17 +163,14 @@ jobs:
env:
OS_FLAVOUR: "debian"
PS_VERSION: ${{ matrix.ps_version }}
TARGET_IMAGE: "flashlight:${{ matrix.ps_version }}-debian"
REBUILD_BASE: "true"

- name: Test the image with a dry run
run: docker run --env PS_DOMAIN='localhost:80' --env DRY_RUN='true' $DOCKER_IMAGE
env:
DOCKER_IMAGE: prestashop/prestashop-flashlight:${{ matrix.ps_version }}-debian
run: docker run --env PS_DOMAIN='localhost:80' --env DRY_RUN='true' flashlight:${{ matrix.ps_version }}-debian

- name: The image has a PrestaShop console CLI
run: docker run --env PS_DOMAIN='localhost:80' --entrypoint /bin/ls $DOCKER_IMAGE bin/console
env:
DOCKER_IMAGE: prestashop/prestashop-flashlight:${{ matrix.ps_version }}-debian
run: docker run --env PS_DOMAIN='localhost:80' --entrypoint /bin/ls flashlight:${{ matrix.ps_version }}-debian bin/console

docker_build_nightly:
name: "Docker build: PS nightly"
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ You can check this implementation anytime in [prestashop-version.json](./prestas
| 8.0~8.1 | PHP 7.2 - 8.1 |
| nightly | PHP 8.1 - 8.3 |

PrestaShop Flashlight **does not support** PHP versions prior to PHP 5.6, here is why:
PrestaShop Flashlight **does not support** PHP versions prior to PHP 5.6 with Alpine Linux, 8.0 with Debian, here is why:

- Official PHP docker images are very old for PHP 5.2, 5.3, 5.4... til the point docker images do not comply with current docker engines.
- Old debian / alpine OS releases do not support arm64 builds and packages
- Rebuilding legacy PHP environments compatible with moddern docker images is costly, with a low value for Flashlight
- Migrating from PHP 5.2 to 5.6 might not be a hard task for an agency/merchant.
- Sury repositories dropped support for Debian Jessie, Stretch & Buster

## Environment variables

Expand Down
30 changes: 26 additions & 4 deletions assets/alpine-base-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
set -eu

# Install base tools, PHP requirements and dev-tools
PHP_COMMON=$(apk search -a 'php-common' | awk 'NR==1{print $1}')
PHP_ICONV=$(apk search -a 'php-iconv' | awk 'NR==1{print $1}')
PHP_GD=$(apk search -a 'php-gd' | awk 'NR==1{print $1}')
packages="bash less vim geoip git tzdata zip curl jq autoconf findutils \
ca-certificates \
php-common php-iconv php-gd mariadb-client sudo libjpeg libxml2 \
mariadb-client sudo libjpeg libxml2 \
build-base linux-headers freetype-dev zlib-dev libjpeg-turbo-dev \
libpng-dev oniguruma-dev libzip-dev icu-dev libmcrypt-dev libxml2-dev \
openssh-client libcap shadow"
openssh-client libcap shadow $PHP_COMMON $PHP_ICONV $PHP_GD"

if [ "$SERVER_FLAVOUR" = "nginx" ]; then
packages="$packages nginx nginx-mod-http-headers-more nginx-mod-http-geoip nginx-mod-stream nginx-mod-stream-geoip"
Expand Down Expand Up @@ -99,7 +102,13 @@ fi
# Install phpstan
PHPSTAN_VERSION=$(jq -r '."'"${PHP_SHORT_VERSION}"'".phpstan' < /tmp/php-flavours.json)
if [ "$PHPSTAN_VERSION" != "null" ]; then
wget -q -O /usr/bin/phpstan "https://github.com/phpstan/phpstan/raw/${PHPSTAN_VERSION}/phpstan.phar"

PHP_STAN_DL_URL="https://github.com/phpstan/phpstan/releases/download/${PHPSTAN_VERSION}/phpstan.phar"
if [ "$PHPSTAN_VERSION" = "HEAD" ]; then
PHP_STAN_DL_URL="https://github.com/phpstan/phpstan/raw/HEAD/phpstan.phar"
fi

wget -q -O /usr/bin/phpstan "$PHP_STAN_DL_URL"
chmod a+x /usr/bin/phpstan
fi

Expand All @@ -119,7 +128,20 @@ fi

# Install Node.js (shipping yarn and npm) and pnpm
if [ "0.0.0" != "$NODE_VERSION" ]; then
apk --no-cache add -U sqlite sqlite-dev python3 nodejs npm yarn
APK_NODE_JS="nodejs npm"
if [ "$PHP_VERSION" = "7.0" ] || [ "$PHP_VERSION" = "7.1" ] || [ "$PHP_VERSION" = "7.2" ]; then
APK_NODE_JS="nodejs-npm"
fi
# shellcheck disable=SC2086
set -- $APK_NODE_JS yarn python3 sqlite-dev
apk --no-cache add -U "$@"

# see https://stackoverflow.com/a/52196681
NODE_MAJOR_VERSION=$(node -v | cut -d '.' -f1 | tr -d 'v')
if [ "$NODE_MAJOR_VERSION" -lt 14 ]; then
npm config set unsafe-perm true
fi

npm install -g pnpm@latest
fi

Expand Down
27 changes: 18 additions & 9 deletions assets/debian-base-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,19 @@ rm -rf /usr/share/doc \
/usr/share/locale

# Get debian version and codename
VERSION_CODENAME=""
# shellcheck disable=SC1091
. /etc/os-release
if [ "$VERSION_ID" = 9 ]; then
if [ "$VERSION_ID" = 8 ]; then
export VERSION_CODENAME="jessie";
elif [ "$VERSION_ID" = 9 ]; then
export VERSION_CODENAME="stretch";
fi

# https://unix.stackexchange.com/a/743874
if [ "$VERSION_CODENAME" = "stretch" ]; then
if [ "$VERSION_CODENAME" = "jessie" ]; then
echo "deb [check-valid-until=no] http://archive.debian.org/debian/ jessie main contrib non-free" > /etc/apt/sources.list
elif [ "$VERSION_CODENAME" = "stretch" ]; then
sed -i s/deb.debian.org/archive.debian.org/g /etc/apt/sources.list
sed -i s/security.debian.org/archive.debian.org/g /etc/apt/sources.list
sed -i s/stretch-updates/stretch/g /etc/apt/sources.list
Expand All @@ -32,22 +37,26 @@ curl -s -L -H "Content-Type: application/octet-stream" \
--data-binary "@/etc/apt/trusted.gpg.d/php.gpg" \
"https://packages.sury.org/php/apt.gpg"
apt-get update
apt-get install --no-install-recommends -qqy apt-transport-https ca-certificates
apt-get install --no-install-recommends --force-yes -qqy apt-transport-https ca-certificates
LIB_GNUTLS=$(apt-cache search '^libgnutls' | awk 'NR==1{print $1}')
packages=(bash less vim git sudo mariadb-client \
tzdata zip unzip curl wget make jq netcat-traditional build-essential \
lsb-release libgnutls30 gnupg libiconv-hook1 libonig-dev libnginx-mod-http-headers-more-filter libnginx-mod-http-geoip \
libnginx-mod-http-geoip libnginx-mod-stream openssh-client libcap2-bin)
lsb-release "$LIB_GNUTLS" gnupg libiconv-hook1 libonig-dev openssh-client libcap2-bin)
if [ "$SERVER_FLAVOUR" = "nginx" ]; then
packages+=(nginx)
packages+=(nginx-full)
else
packages+=(apache2)
fi

apt-get install --no-install-recommends -o Dpkg::Options::="--force-confold" -qqy "${packages[@]}"
apt-get install --no-install-recommends -o Dpkg::Options::="--force-confold" --force-yes -qqy "${packages[@]}"


if [ "$VERSION_CODENAME" != "stretch" ] && [ "$VERSION_CODENAME" != "buster" ]; then
if [ "$VERSION_CODENAME" = "bookworm" ] || [ "$VERSION_CODENAME" = "bullseye" ]; then
echo "deb [trusted=yes] https://packages.sury.org/php/ $VERSION_CODENAME main" > /etc/apt/sources.list.d/php.list
else
echo "[WARNING] The sury repository does not support debian jessie, stretch or buster any more."
echo "This build is likely to fail, please use an alpine build if you can."
echo "see: https://packages.sury.org/php/dists/"
exit 6
fi
rm /etc/apt/preferences.d/no-debian-php
apt-get update
Expand Down
3 changes: 2 additions & 1 deletion assets/hydrate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ PS_OPT_DIR=/var/opt/prestashop
mkdir -p "$PS_OPT_DIR"
if echo "$PS_VERSION" | grep "^1.6" > /dev/null; then
cp "$PS_FOLDER/config/settings.inc.php" "$PS_OPT_DIR/settings.inc.php"
elif [ -f "$PS_FOLDER/app/config/parameters.yml.dist" ]; then
cp "$PS_FOLDER/app/config/parameters.yml.dist" "$PS_OPT_DIR/parameters.yml"
else
mkdir -p "$PS_OPT_DIR"
cp "$PS_FOLDER/app/config/parameters.php" "$PS_OPT_DIR/parameters.php"
fi

Expand Down
Loading

0 comments on commit 9ea9477

Please sign in to comment.