diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 470ed49..ff47a13 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -61,7 +61,7 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 with: - platforms: ${{ env.TARGET_PLATFORMS }} + platforms: ${{ env.TARGET_PLATFORM }} use: true - name: Login to Docker Hub @@ -73,7 +73,7 @@ jobs: - name: Build and push run: ./build.sh env: - PLATFORM: ${{ inputs.target_platforms }} + TARGET_PLATFORM: ${{ inputs.target_platforms }} PS_VERSION: ${{ inputs.ps_version }} PHP_VERSION: ${{ inputs.php_version }} OS_FLAVOUR: ${{ inputs.os_flavour }} diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 748296a..5474015 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -3,6 +3,9 @@ on: pull_request: types: [opened, reopened, synchronize] +env: + TARGET_PLATFORM: "linux/amd64" + jobs: lint_shell: name: "Lint: shell" @@ -38,6 +41,7 @@ jobs: env: OS_FLAVOUR: ${{ matrix.os_flavour }} PS_VERSION: ${{ matrix.ps_version }} + TARGET_PLATFORM: ${{ env.TARGET_PLATFORM }} - name: Test the image with a dry run run: docker run --env PS_DOMAIN='localhost:80' --env DRY_RUN='true' $DOCKER_IMAGE diff --git a/.hadolint.yaml b/.hadolint.yaml index 2c44306..0a7a438 100644 --- a/.hadolint.yaml +++ b/.hadolint.yaml @@ -6,3 +6,4 @@ ignored: - DL4006 - DL4001 - SC1091 + - SC2086 diff --git a/assets/patch.sh b/assets/patch.sh index 235ace8..aa338d8 100755 --- a/assets/patch.sh +++ b/assets/patch.sh @@ -2,12 +2,12 @@ set -eu PS_FOLDER=${PS_FOLDER:?missing PS_FOLDER} -PS_VERSION=$(awk 'NR==1{print $2}' "${PS_FOLDER}/VERSION") +PS_VERSION=$(awk 'NR==1{print $2}' "$PS_FOLDER/VERSION") patch_1_6 () { # Add robots file - echo "User-agent: *" > "${PS_FOLDER}/robots.txt" - echo "Disallow: /" >> "${PS_FOLDER}/robots.txt" + echo "User-agent: *" > "$PS_FOLDER/robots.txt" + echo "Disallow: /" >> "$PS_FOLDER/robots.txt" } if echo "$PS_VERSION" | grep "^1.6" > /dev/null; then diff --git a/build.sh b/build.sh index 78a401c..c0d390b 100755 --- a/build.sh +++ b/build.sh @@ -8,7 +8,8 @@ declare PS_VERSION; # -- PrestaShop version, defaults to latest declare PHP_VERSION; # -- PHP version, defaults to recommended version for PrestaShop declare OS_FLAVOUR; # -- either "alpine" (default) or "debian" declare SERVER_FLAVOUR; # -- not implemented, either "nginx" (default) or "apache" -declare PLATFORM; # -- a comma separated list of target platforms (defaults to "linux/amd64") +declare TARGET_PLATFORM; # -- a comma separated list of target platforms (defaults to "linux/amd64") +declare PLATFORM; # -- alias for $TARGET_PLATFORM declare TARGET_IMAGE; # -- docker image name, defaults to "prestashop/prestashop-flashlight" declare PUSH; # -- set it to "true" if you want to push the resulting image @@ -19,6 +20,8 @@ DEFAULT_SERVER="nginx"; DEFAULT_DOCKER_IMAGE=prestashop/prestashop-flashlight DEFAULT_PLATFORM=linux/amd64 GIT_SHA=$(git rev-parse HEAD) +TARGET_PLATFORM="${TARGET_PLATFORM:-$DEFAULT_PLATFORM}" +[ -n "$PLATFORM" ] && TARGET_PLATFORM=$PLATFORM; error() { echo -e "\e[1;31m${1:-Unknown error}\e[0m" @@ -26,7 +29,7 @@ error() { } get_latest_prestashop_version() { - curl --silent --location --request GET \ + curl --silent --show-error --fail --location --request GET \ 'https://api.github.com/repos/prestashop/prestashop/releases/latest' | jq -r '.tag_name' } @@ -43,6 +46,19 @@ get_recommended_php_version() { echo "$RECOMMENDED_VERSION"; } +get_recommended_nodejs_version() { + local PS_VERSION=$1; + local RECOMMENDED_VERSION=; + REGEXP_LIST=$(jq -r 'keys_unsorted | .[]' /dev/null || true docker buildx build \ --file "./docker/${OS_FLAVOUR}.Dockerfile" \ - --platform "${PLATFORM:-$DEFAULT_PLATFORM}" \ + --platform "$TARGET_PLATFORM" \ --cache-from type=registry,ref="$CACHE_IMAGE" \ --cache-to type=inline \ --build-arg PHP_FLAVOUR="$PHP_FLAVOUR" \ --build-arg PS_VERSION="$PS_VERSION" \ --build-arg PHP_VERSION="$PHP_VERSION" \ --build-arg GIT_SHA="$GIT_SHA" \ + --build-arg NODE_VERSION="$NODE_VERSION" \ + --build-arg TARGET_PLATFORM="$TARGET_PLATFORM" \ --label org.opencontainers.image.title="PrestaShop Flashlight" \ --label org.opencontainers.image.description="PrestaShop Flashlight testing utility" \ --label org.opencontainers.image.source=https://github.com/PrestaShop/prestashop-flashlight \ diff --git a/docker-compose.yml b/docker-compose.yml index 0f1e734..1fe0923 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -39,7 +39,7 @@ services: env_file: - .env healthcheck: - test: ["CMD", "curl", "-Ss", "http://localhost/robots.txt"] + test: ["CMD", "curl", "-Isf", "http://localhost/robots.txt"] interval: 30s timeout: 10s retries: 5 diff --git a/docker/alpine.Dockerfile b/docker/alpine.Dockerfile index 68ef681..8d0f147 100644 --- a/docker/alpine.Dockerfile +++ b/docker/alpine.Dockerfile @@ -1,13 +1,18 @@ -# ------------------------------------- -# PrestaShop Flashlight: Alpine image -# ------------------------------------- ARG PS_VERSION ARG PHP_VERSION ARG PHP_FLAVOUR ARG GIT_SHA +ARG NODE_VERSION +ARG TARGET_PLATFORM + +# ------------------------------------- +# PrestaShop Flashlight: Alpine image +# ------------------------------------- FROM php:${PHP_FLAVOUR} AS base-prestashop ARG PS_VERSION ARG PHP_VERSION +ARG NODE_VERSION +ARG TARGET_PLATFORM ENV PS_FOLDER=/var/www/html # Install base tools @@ -25,15 +30,6 @@ RUN apk --no-cache add -U composer zlib-dev libjpeg-turbo-dev libpng-dev libzip- docker-php-ext-configure gd --with-jpeg && docker-php-ext-install gd pdo_mysql zip intl; \ fi; -# TODO check opcache configuration -# RUN docker-php-ext-enable opcache -# RUN echo '\ -# opcache.interned_strings_buffer=16\n\ -# opcache.load_comments=Off\n\ -# opcache.max_accelerated_files=16000\n\ -# opcache.save_comments=Off\n\ -# ' >> /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini - # Configure php-fpm and nginx RUN rm -rf /var/log/php* /etc/php*/php-fpm.conf /etc/php*/php-fpm.d \ && mkdir -p /var/log/php /var/run/php /var/run/nginx \ @@ -58,6 +54,19 @@ RUN PHP_CS_FIXER=$(jq -r '."'"${PHP_VERSION}"'".php_cs_fixer' < /tmp/php-flavour && wget -q -O /usr/bin/php-cs-fixer "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/releases/download/${PHP_CS_FIXER}/php-cs-fixer.phar" \ && chmod a+x /usr/bin/php-cs-fixer +# Install Node.js and pnpm (yarn and npm are included) +RUN apk --no-cache add -U gcompat && \ + if [ "linux/arm64" = "$TARGET_PLATFORM" ]; \ + then export DISTRO="linux-arm64"; \ + else export DISTRO="linux-x64"; \ + fi \ + && curl --silent --show-error --fail --location --output /tmp/node.tar.xz "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-${DISTRO}.tar.xz" \ + && mkdir /tmp/nodejs && tar -xJf /tmp/node.tar.xz -C /tmp/nodejs \ + && mv "/tmp/nodejs/node-v${NODE_VERSION}-${DISTRO}" /usr/local/lib/nodejs && rmdir /tmp/nodejs \ + && rm -f /tmp/node.tar.xz \ + && PATH="$PATH:/usr/local/lib/nodejs/bin" npm install -g pnpm@latest --force +ENV PATH "$PATH:/usr/local/lib/nodejs/bin" + # -------------------------------- # Flashlight install and dump SQL # -------------------------------- diff --git a/docker/debian.Dockerfile b/docker/debian.Dockerfile index 55ab324..19a0ec2 100644 --- a/docker/debian.Dockerfile +++ b/docker/debian.Dockerfile @@ -1,12 +1,19 @@ -# ------------------------------------- -# PrestaShop Flashlight: Debian image -# ------------------------------------- ARG PS_VERSION ARG PHP_VERSION ARG PHP_FLAVOUR +ARG GIT_SHA +ARG NODE_VERSION +ARG TARGET_PLATFORM + +# ------------------------------------- +# PrestaShop Flashlight: Debian image +# ------------------------------------- FROM php:${PHP_FLAVOUR} AS base-prestashop ARG PS_VERSION ARG PHP_VERSION +ARG GIT_SHA +ARG NODE_VERSION +ARG TARGET_PLATFORM ENV PS_FOLDER=/var/www/html # Install base tools @@ -21,8 +28,7 @@ RUN apt-get update \ # see: https://olvlvl.com/2019-06-install-php-ext-source # see: https://stackoverflow.com/a/73834081 # see: https://packages.sury.org/php/dists/ -RUN curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg \ - && . /etc/os-release \ +RUN . /etc/os-release \ && echo "deb [trusted=yes] https://packages.sury.org/php/ ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/php.list \ && rm /etc/apt/preferences.d/no-debian-php; RUN apt-get update \ @@ -64,6 +70,18 @@ RUN PHP_CS_FIXER=$(jq -r '."'"${PHP_VERSION}"'".php_cs_fixer' < /tmp/php-flavour && wget -q -O /usr/bin/php-cs-fixer "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/releases/download/${PHP_CS_FIXER}/php-cs-fixer.phar" \ && chmod a+x /usr/bin/php-cs-fixer +# Install Node.js and pnpm (yarn and npm are included) +RUN if [ "linux/arm64" = "$TARGET_PLATFORM" ]; \ + then export DISTRO="linux-arm64"; \ + else export DISTRO="linux-x64"; \ + fi \ + && curl --silent --show-error --fail --location --output /tmp/node.tar.xz "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-${DISTRO}.tar.xz" \ + && mkdir /tmp/nodejs && tar -xJf /tmp/node.tar.xz -C /tmp/nodejs \ + && mv "/tmp/nodejs/node-v${NODE_VERSION}-${DISTRO}" /usr/local/lib/nodejs && rmdir /tmp/nodejs \ + && rm -f /tmp/node.tar.xz \ + && PATH="$PATH:/usr/local/lib/nodejs/bin" npm install -g pnpm@latest --force +ENV PATH "$PATH:/usr/local/lib/nodejs/bin" + # -------------------------------- # Flashlight install and dump SQL # -------------------------------- diff --git a/examples/auto-install-modules/README.md b/examples/auto-install-modules/README.md index 863c281..3441d1c 100644 --- a/examples/auto-install-modules/README.md +++ b/examples/auto-install-modules/README.md @@ -8,7 +8,7 @@ Add a module like this: ```sh mkdir -p ./modules -curl -s -L -o modules/psxmarketingwithgoogle-v1.61.1.zip "https://github.com/PrestaShopCorp/psxmarketingwithgoogle/releases/download/v1.61.1/psxmarketingwithgoogle-v1.61.1.zip" +curl --silent --show-error --fail --location --output modules/psxmarketingwithgoogle-v1.61.1.zip "https://github.com/PrestaShopCorp/psxmarketingwithgoogle/releases/download/v1.61.1/psxmarketingwithgoogle-v1.61.1.zip" ``` The expected output of this example is: diff --git a/prestashop-versions.json b/prestashop-versions.json index b432ebd..41019c0 100644 --- a/prestashop-versions.json +++ b/prestashop-versions.json @@ -3,53 +3,80 @@ "php": { "recommended": "7.1", "compatible": ["5.2", "5.3", "5.4", "5.5", "5.6", "7.0", "7.1"] + }, + "nodejs": { + "recommended": "10.24.1" } }, "^1.7.[0-3]": { "php": { "recommended": "7.1", "compatible": ["5.4", "5.5", "5.6", "7.0", "7.1"] + }, + "nodejs": { + "recommended": "10.24.1" } }, "^1.7.7.4": { "php": { "recommended": "7.1", "compatible": ["5.6", "7.0", "7.1"] + }, + "nodejs": { + "recommended": "10.24.1" } }, "^1.7.[5-6]": { "php": { "recommended": "7.2", "compatible": ["5.6", "7.0", "7.1", "7.2"] + }, + "nodejs": { + "recommended": "10.24.1" } }, "^1.7.7": { "php": { "recommended": "7.3", "compatible": ["7.1", "7.2", "7.3"] + }, + "nodejs": { + "recommended": "10.24.1" } }, "^1.7.8": { "php": { "recommended": "7.4", "compatible": ["7.1", "7.2", "7.3", "7.4"] + }, + "nodejs": { + "recommended": "14.19.0" } }, "^8.0": { "php": { "recommended": "8.1", "compatible": ["7.2", "7.3", "7.4", "8.0", "8.1"] + }, + "nodejs": { + "recommended": "16.16.0" } }, "^8.1": { "php": { "recommended": "8.1", "compatible": ["7.2", "7.3", "7.4", "8.0", "8.1"] + }, + "nodejs": { + "recommended": "16.16.0" } }, "nightly": { "php": { "recommended": "8.1" + }, + "nodejs": { + "recommended": "16.16.0" } } }