diff --git a/assets/000-default.conf b/assets/000-default.conf new file mode 100644 index 0000000..a2ed2f5 --- /dev/null +++ b/assets/000-default.conf @@ -0,0 +1,22 @@ + + DocumentRoot /var/www/html + + + SetHandler "proxy:unix:/var/run/php/php-fpm.sock|fcgi://localhost/" + + + + + + + Options Indexes FollowSymLinks + AllowOverride All + Require all granted + + + ErrorLog /var/log/apache2/error.log + CustomLog /var/log/apache2/access.log combined + + + +ServerName localhost \ No newline at end of file diff --git a/assets/alpine-base-install.sh b/assets/alpine-base-install.sh index bd021ca..a7636da 100755 --- a/assets/alpine-base-install.sh +++ b/assets/alpine-base-install.sh @@ -2,30 +2,80 @@ set -eu # Install base tools, PHP requirements and dev-tools -apk --no-cache add -U \ - bash less vim geoip git tzdata zip curl jq autoconf findutils \ - nginx nginx-mod-http-headers-more nginx-mod-http-geoip \ - nginx-mod-stream nginx-mod-stream-geoip ca-certificates \ +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 \ 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" + +if [ "$SERVER_FLAVOUR" = "nginx" ]; then + packages="$packages nginx nginx-mod-http-headers-more nginx-mod-http-geoip nginx-mod-stream nginx-mod-stream-geoip" +else + packages="$packages apache2 apache2-proxy" +fi + +# shellcheck disable=SC2086 +set -- $packages +apk --no-cache add -U "$@" # Help mapping to Linux users' host usermod -u 1000 www-data groupmod -g 1000 www-data -# Configure php-fpm and nginx +# Configure php-fpm /tmp/php-configuration.sh 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 /var/log/nginx /var/tmp/nginx -touch /var/log/nginx/access.log /var/log/nginx/error.log -chown -R www-data:www-data /var/log/php /var/run/php "$PHP_INI_DIR" \ - /var/run/nginx /var/log/nginx /var/lib/nginx /var/tmp/nginx /var/opt/prestashop -setcap cap_net_bind_service=+ep /usr/sbin/nginx +mkdir -p /var/log/php /var/run/php +chown -R www-data:www-data /var/log/php /var/run/php "$PHP_INI_DIR" /var/opt/prestashop -# Compute the short version (8.1.27 becomes 8.1) -PHP_SHORT_VERSION=$(echo "$PHP_VERSION" | cut -d '.' -f1-2) +# Configure server +if [ "$SERVER_FLAVOUR" = "nginx" ]; then + rm -rf /etc/apache2 +else + a2enmod() { + while test $# -gt 0; do + MODULE="$1" + echo "Enabling module $MODULE" + sed -i "/^#LoadModule ${MODULE}_module/s/^#//g" /etc/apache2/httpd.conf + shift + done + } + + a2dismod() { + while test $# -gt 0; do + MODULE="$1" + echo "Disabling module $MODULE" + sed -i "/^LoadModule ${MODULE}_module/s/^LoadModule/#LoadModule/g" /etc/apache2/httpd.conf + shift + done + } + + a2enmod proxy \ + && a2enmod proxy_fcgi \ + && a2enmod rewrite \ + && a2enmod mpm_event \ + && a2dismod mpm_prefork + + echo "include /etc/apache2/sites-available/000-default.conf" >> /etc/apache2/httpd.conf + rm -rf /etc/nginx +fi + +if [ "$SERVER_FLAVOUR" = "nginx" ]; then + mkdir -p /var/run/nginx /var/log/nginx /var/tmp/nginx + touch /var/log/nginx/access.log /var/log/nginx/error.log + chown -R www-data:www-data /var/run/nginx /var/log/nginx /var/tmp/nginx + chown -R www-data:www-data /var/lib/nginx + setcap cap_net_bind_service=+ep /usr/sbin/nginx +else + mkdir -p /var/run/apache2 /var/log/apache2 /var/tmp/apache2 + touch /var/log/apache2/access.log /var/log/apache2/error.log + chown -R www-data:www-data /var/run/apache2 /var/log/apache2 /var/tmp/apache2 + chown -R www-data:www-data /usr/lib/apache2 + setcap cap_net_bind_service=+ep /usr/sbin/httpd +fi + +rm -f "$PS_FOLDER"/index* # Install composer curl -s https://getcomposer.org/installer | php @@ -36,6 +86,9 @@ chown -R www-data:www-data "$COMPOSER_HOME" # Install PrestaShop tools required by prestashop coding-standards composer require nikic/php-parser --working-dir=/var/opt || true +# Compute the short version (8.1.27 becomes 8.1) +PHP_SHORT_VERSION=$(echo "$PHP_VERSION" | cut -d '.' -f1-2) + # Install phpunit PHPUNIT_VERSION=$(jq -r '."'"${PHP_SHORT_VERSION}"'".phpunit' < /tmp/php-flavours.json) if [ "$PHPUNIT_VERSION" != "null" ]; then diff --git a/assets/debian-base-install.sh b/assets/debian-base-install.sh index e39e0f5..fbc7870 100755 --- a/assets/debian-base-install.sh +++ b/assets/debian-base-install.sh @@ -33,10 +33,19 @@ curl -s -L -H "Content-Type: application/octet-stream" \ "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 -o Dpkg::Options::="--force-confold" -qqy bash less vim git sudo mariadb-client \ +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 nginx libnginx-mod-http-headers-more-filter libnginx-mod-http-geoip \ - libnginx-mod-http-geoip libnginx-mod-stream openssh-client libcap2-bin; + 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) +if [ "$SERVER_FLAVOUR" = "nginx" ]; then + packages+=(nginx) +else + packages+=(apache2) +fi + +apt-get install --no-install-recommends -o Dpkg::Options::="--force-confold" -qqy "${packages[@]}" + + if [ "$VERSION_CODENAME" != "stretch" ] && [ "$VERSION_CODENAME" != "buster" ]; then echo "deb [trusted=yes] https://packages.sury.org/php/ $VERSION_CODENAME main" > /etc/apt/sources.list.d/php.list fi @@ -59,17 +68,34 @@ apt-get install --no-install-recommends -qqy \ usermod -u 1000 www-data groupmod -g 1000 www-data -# Configure php-fpm and nginx +# Configure php-fpm /tmp/php-configuration.sh 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 /var/log/nginx /var/tmp/nginx -touch /var/log/nginx/access.log /var/log/nginx/error.log -chown -R www-data:www-data /var/log/php /var/run/php "$PHP_INI_DIR" \ - /var/run/nginx /var/log/nginx /var/lib/nginx /var/tmp/nginx /var/opt/prestashop -setcap cap_net_bind_service=+ep /usr/sbin/nginx +mkdir -p /var/log/php /var/run/php +chown -R www-data:www-data /var/log/php /var/run/php "$PHP_INI_DIR" /var/opt/prestashop + +# Configure server +if [ "$SERVER_FLAVOUR" = "nginx" ]; then + rm -rf /etc/apache2 +else + a2enmod proxy \ + && a2enmod proxy_fcgi \ + && a2enmod rewrite + rm -rf /etc/nginx +fi +if [ "$SERVER_FLAVOUR" = "nginx" ]; then + mkdir -p /var/run/nginx /var/log/nginx /var/tmp/nginx + touch /var/log/nginx/access.log /var/log/nginx/error.log + chown -R www-data:www-data /var/run/nginx /var/log/nginx /var/tmp/nginx /var/lib/nginx + setcap cap_net_bind_service=+ep /usr/sbin/nginx +else + mkdir -p /var/run/apache2 /var/log/apache2 /var/tmp/apache2 + touch /var/log/apache2/access.log /var/log/apache2/error.log + chown -R www-data:www-data /var/run/apache2 /var/log/apache2 /var/tmp/apache2 /var/lib/apache2 + setcap cap_net_bind_service=+ep /usr/sbin/apache2 +fi -# Compute the short version (8.1.27 becomes 8.1) -PHP_SHORT_VERSION=$(echo "$PHP_VERSION" | cut -d '.' -f1-2) +rm -f "$PS_FOLDER"/index* # Install composer curl -s https://getcomposer.org/installer | php @@ -80,6 +106,9 @@ chown -R www-data:www-data "$COMPOSER_HOME" # Install PrestaShop tools required by prestashop coding-standards composer require nikic/php-parser --working-dir=/var/opt +# Compute the short version (8.1.27 becomes 8.1) +PHP_SHORT_VERSION=$(echo "$PHP_VERSION" | cut -d '.' -f1-2) + # Install phpunit PHPUNIT_VERSION=$(jq -r '."'"${PHP_SHORT_VERSION}"'".phpunit' < /tmp/php-flavours.json) if [ "$PHPUNIT_VERSION" != "null" ]; then diff --git a/assets/run.sh b/assets/run.sh index 9397f48..7cbccac 100755 --- a/assets/run.sh +++ b/assets/run.sh @@ -26,6 +26,7 @@ export PS_PROTOCOL="${PS_PROTOCOL:-http}" export SSL_REDIRECT="${SSL_REDIRECT:-false}" export XDEBUG_ENABLED="${XDEBUG_ENABLED:-false}" + INIT_LOCK=/tmp/flashlight-init.lock DUMP_LOCK=/tmp/flashlight-dump.lock MODULES_INSTALLED_LOCK=/tmp/flashlight-modules-installed.lock @@ -74,6 +75,11 @@ if [ ! -f $INIT_LOCK ] || [ "$INIT_ON_RESTART" = "true" ]; then rm -f "$TMP_FILE" export PS_DOMAIN="$PS_DOMAIN" + if [ "$SERVER_FLAVOUR" = "apache" ]; then + echo "* Applying PS_DOMAIN ($PS_DOMAIN) to root .htaccess..." + sed -i "s~localhost:80~$PS_DOMAIN~g" "$PS_FOLDER"/.htaccess + fi + # Note: use PS_TRUSTED_PROXIES for PrestaShop > 9 since bbdee4b6d07cf4c40787c95b8c948b04506208fd # Note: PS_SSL_ENABLED_EVERYWHERE was missing in ps_configuration in 1.7.2.5 [ "$SSL_REDIRECT" = "true" ] && PS_PROTOCOL="https"; @@ -239,17 +245,25 @@ if [ "$DRY_RUN" = "true" ]; then fi echo "* Starting php-fpm..." -# Is running as root, set the php-fpm user and group to www-data +# If running as root, set the php-fpm user and group to www-data [ "$(id -u)" -eq 0 ] && sed -i '/user\s=/s/^;//' /usr/local/etc/php-fpm.conf && sed -i '/group\s=/s/^;//' /usr/local/etc/php-fpm.conf php-fpm -D -echo "* Starting nginx..." -# Is running as root, set the nginx user and group to www-data -[ "$(id -u)" -eq 0 ] && sed -i '/#\suser\swww-data/s/^#//' /etc/nginx/nginx.conf -nginx -g "daemon off;" & -NGINX_PID=$! +echo "* Starting $SERVER_FLAVOUR..." +if [ "$SERVER_FLAVOUR" = "nginx" ]; then + # If running as root, set the nginx user and group to www-data + [ "$(id -u)" -eq 0 ] && sed -i '/#\suser\swww-data/s/^#//' /etc/nginx/nginx.conf + nginx -g "daemon off;" & +elif service --status-all 2> /dev/null | grep -Fq 'apache2'; then + apache2ctl -D FOREGROUND & +else + # If running as root, set the nginx user and group to www-data + [ "$(id -u)" -eq 0 ] && sed -i '/User apache/s/apache/www-data/' /etc/apache2/httpd.conf && sed -i '/Group apache/s/apache/www-data/' /etc/apache2/httpd.conf + /usr/sbin/httpd -D FOREGROUND -f /etc/apache2/httpd.conf & +fi +SERVER_PID=$! sleep 1; -echo "* Nginx started" +echo "* $SERVER_FLAVOUR started" # Post-run scripts if [ -d "$POST_SCRIPTS_DIR" ]; then @@ -279,5 +293,5 @@ else echo "* No post-script(s) found" fi -# set back nginx to front process -wait $NGINX_PID +# set back server to front process +wait "$SERVER_PID" diff --git a/build.sh b/build.sh index 21bc339..20eff3a 100755 --- a/build.sh +++ b/build.sh @@ -11,17 +11,18 @@ declare OS_FLAVOUR; # -- either "alpine" (default) or "debian" declare PHP_VERSION; # -- PHP version, defaults to recommended version for PrestaShop declare PS_VERSION; # -- PrestaShop version, defaults to latest declare PUSH; # -- set it to "true" if you want to push the resulting image -declare SERVER_FLAVOUR; # -- not implemented, either "nginx" (default) or "apache" +declare SERVER_FLAVOUR; # -- either "nginx" (default) or "apache" declare TARGET_IMAGE; # -- docker image name, defaults to "prestashop/prestashop-flashlight" declare TARGET_PLATFORM; # -- a comma separated list of target platforms (defaults to "linux/amd64") declare PLATFORM; # -- alias for $TARGET_PLATFORM declare ZIP_SOURCE; # -- the zip to unpack in flashlight -declare CUSTOM_LABELS; # -- only when PRIVATE : list of key=value pairs separated by a comma, for overriding official flashlight labels +declare CUSTOM_LABELS; # -- A comma separated list of key=value pairs, for overriding official flashlight labels" +declare CUSTOM_BASE_IMAGE; # -- A name for overriding the base docker image. Usefull if you need to build the base to a custom repo # Static configuration # -------------------- -DEFAULT_DOCKER_IMAGE=prestashop/prestashop-flashlight +DEFAULT_BASE_DOCKER_IMAGE=prestashop/prestashop-flashlight DEFAULT_OS="alpine"; DEFAULT_PLATFORM=$(docker system info --format '{{.OSType}}/{{.Architecture}}') DEFAULT_SERVER="nginx"; @@ -45,11 +46,12 @@ help() { echo " --ps-version PrestaShop version, defaults to latest" echo " --push Push the resulting image to the registry" echo " --rebuild-base Force the rebuild of the base image" - echo " --server-flavour Not implemented, either 'nginx' (default) or 'apache'" + echo " --server-flavour Either 'nginx' (default) or 'apache'" echo " --target-image Docker image name, defaults to 'prestashop/prestashop-flashlight'" echo " --custom-labels A comma separated list of key=value pairs, for overriding official flashlight labels" echo " --target-platform A comma separated list of target platforms (defaults to 'linux/amd64')" echo " --zip-source The zip containing the PrestaShop release to build a docker image upon (defaults to PrestaShop source code)" + echo " --custom-base-image A name for overriding the base docker image. Usefull if you need to build the base to a custom repo" echo "" echo "$(tput bold)Environment variables:$(tput sgr0)" echo " BASE_ONLY Only build the base image (OS_FLAVOUR) without shipping PrestaShop" @@ -59,11 +61,12 @@ help() { echo " PS_VERSION PrestaShop version, defaults to latest" echo " PUSH Set it to 'true' if you want to push the resulting image" echo " REBUILD_BASE Force the rebuild of the base image" - echo " SERVER_FLAVOUR Not implemented, either 'nginx' (default) or 'apache'" + echo " SERVER_FLAVOUR Either 'nginx' (default) or 'apache'" echo " TARGET_IMAGE Docker image name, defaults to 'prestashop/prestashop-flashlight'" echo " CUSTOM_LABELS A comma separated list of key=value pairs, for overriding official flashlight labels" echo " TARGET_PLATFORM A comma separated list of target platforms (defaults to 'linux/amd64')" echo " ZIP_SOURCE The zip containing the PrestaShop release to build a docker image upon (defaults to PrestaShop source code)" + echo " CUSTOM_BASE_IMAGE A name for overriding the base docker image. Usefull if you need to build the base to a custom repo" } # Parsing input arguments @@ -83,6 +86,7 @@ while [ "$#" -gt 0 ]; do --target-image) TARGET_IMAGE="$2"; shift; shift;; --custom-labels) CUSTOM_LABELS="$2"; shift; shift;; --zip-source) ZIP_SOURCE="$2"; shift; shift;; + --custom-base-image) CUSTOM_BASE_IMAGE="$2"; shift; shift;; *) error "Unknown option: $1" 2;; esac done @@ -94,6 +98,7 @@ BASE_ONLY=${BASE_ONLY:-false} REBUILD_BASE=${REBUILD_BASE:-$BASE_ONLY} DRY_RUN=${DRY_RUN:-false} TARGET_PLATFORM="${TARGET_PLATFORM:-${PLATFORM:-$DEFAULT_PLATFORM}}" +BASE_DOCKER_IMAGE="${CUSTOM_BASE_IMAGE:-${DEFAULT_BASE_DOCKER_IMAGE}}" declare -A TARGET_IMAGE_LABELS; @@ -193,23 +198,26 @@ get_target_images() { declare RES; if [ "$PS_VERSION" == "nightly" ]; then if [ "$OS_FLAVOUR" = "$DEFAULT_OS" ]; then - RES="-t ${DEFAULT_DOCKER_IMAGE}:nightly"; + RES="-t ${BASE_DOCKER_IMAGE}:nightly-${SERVER_FLAVOUR}"; else - RES="-t ${DEFAULT_DOCKER_IMAGE}:nightly-${OS_FLAVOUR}"; + RES="-t ${BASE_DOCKER_IMAGE}:nightly-${OS_FLAVOUR}-${SERVER_FLAVOUR}"; fi else - if [ "$PS_VERSION" = "$(get_latest_prestashop_version)" ] && [ "$OS_FLAVOUR" = "$DEFAULT_OS" ] && [ "$PHP_VERSION" = "$(get_recommended_php_version "$PS_VERSION")" ]; then - RES="-t ${DEFAULT_DOCKER_IMAGE}:latest"; + if [ "$PS_VERSION" = "$(get_latest_prestashop_version)" ] \ + && [ "$OS_FLAVOUR" = "$DEFAULT_OS" ] \ + && [ "$PHP_VERSION" = "$(get_recommended_php_version "$PS_VERSION")" ] \ + && [ "$SERVER_FLAVOUR" = "$DEFAULT_SERVER" ]; then + RES="-t ${BASE_DOCKER_IMAGE}:latest"; fi if [ "$OS_FLAVOUR" = "$DEFAULT_OS" ]; then - RES="${RES} -t ${DEFAULT_DOCKER_IMAGE}:${PS_VERSION}-${PHP_VERSION}"; + RES="${RES} -t ${BASE_DOCKER_IMAGE}:${PS_VERSION}-${PHP_VERSION}-${SERVER_FLAVOUR}"; if [ "$PHP_VERSION" = "$(get_recommended_php_version "$PS_VERSION")" ]; then - RES="${RES} -t ${DEFAULT_DOCKER_IMAGE}:${PS_VERSION}"; - RES="${RES} -t ${DEFAULT_DOCKER_IMAGE}:php-${PHP_VERSION}"; + RES="${RES} -t ${BASE_DOCKER_IMAGE}:${PS_VERSION}-${SERVER_FLAVOUR}"; + RES="${RES} -t ${BASE_DOCKER_IMAGE}:php-${PHP_VERSION}-${SERVER_FLAVOUR}"; fi fi - RES="${RES} -t ${DEFAULT_DOCKER_IMAGE}:${PS_VERSION}-${PHP_BASE_IMAGE}"; - RES="${RES} -t ${DEFAULT_DOCKER_IMAGE}:${PS_VERSION}-${OS_FLAVOUR}"; + RES="${RES} -t ${BASE_DOCKER_IMAGE}:${PS_VERSION}-${PHP_BASE_IMAGE}-${SERVER_FLAVOUR}"; + RES="${RES} -t ${BASE_DOCKER_IMAGE}:${PS_VERSION}-${OS_FLAVOUR}-${SERVER_FLAVOUR}"; fi echo "$RES"; } @@ -257,7 +265,7 @@ done # Build the docker image # ---------------------- -CACHE_IMAGE=prestashop/prestashop-flashlight:base-${PHP_BASE_IMAGE} +CACHE_IMAGE=$BASE_DOCKER_IMAGE:base-${PHP_BASE_IMAGE}-${SERVER_FLAVOUR} if [ "$DRY_RUN" == "true" ]; then docker() { echo docker "$@" @@ -267,7 +275,7 @@ fi docker pull "$CACHE_IMAGE" 2> /dev/null || REBUILD_BASE='true'; if [ "$REBUILD_BASE" == "true" ]; then - echo "building base for $PHP_BASE_IMAGE ($TARGET_PLATFORM)" + echo "building base for $PHP_BASE_IMAGE $SERVER_FLAVOUR ($TARGET_PLATFORM)" docker buildx build \ --progress=plain \ --file "./docker/$OS_FLAVOUR-base.Dockerfile" \ @@ -278,8 +286,9 @@ if [ "$REBUILD_BASE" == "true" ]; then --build-arg PHP_VERSION="$PHP_VERSION" \ --build-arg NODE_VERSION="$NODE_VERSION" \ --build-arg GIT_SHA="$GIT_SHA" \ + --build-arg SERVER_FLAVOUR="$SERVER_FLAVOUR" \ "${LABELS[@]}" \ - --tag "prestashop/prestashop-flashlight:base-$PHP_BASE_IMAGE" \ + --tag "$BASE_DOCKER_IMAGE:base-${PHP_BASE_IMAGE}-${SERVER_FLAVOUR}" \ "$([ "${PUSH}" == "true" ] && echo "--push" || echo "--load")" \ . fi @@ -296,6 +305,8 @@ if [ "$BASE_ONLY" == "false" ]; then --build-arg PHP_VERSION="$PHP_VERSION" \ --build-arg GIT_SHA="$GIT_SHA" \ --build-arg ZIP_SOURCE="$ZIP_SOURCE" \ + --build-arg SERVER_FLAVOUR="$SERVER_FLAVOUR" \ + --build-arg BASE_DOCKER_IMAGE="$BASE_DOCKER_IMAGE" \ "${LABELS[@]}" \ "${TARGET_IMAGES[@]}" \ "$([ "${PUSH}" == "true" ] && echo "--push" || echo "--load")" \ diff --git a/docker/alpine-base.Dockerfile b/docker/alpine-base.Dockerfile index 961814d..b6e53be 100644 --- a/docker/alpine-base.Dockerfile +++ b/docker/alpine-base.Dockerfile @@ -3,7 +3,7 @@ ARG PHP_VERSION ARG PHP_BASE_IMAGE=8.3-fpm-alpine ARG GIT_SHA ARG NODE_VERSION -ARG ZIP_SOURCE +ARG SERVER_FLAVOUR # ------------------------------------- # PrestaShop Flashlight: Alpine image @@ -13,6 +13,7 @@ ARG PS_VERSION ARG PHP_VERSION ARG GIT_SHA ARG NODE_VERSION +ARG SERVER_FLAVOUR ENV PS_FOLDER=/var/www/html ENV PHP_INI_DIR=/usr/local/etc/php ENV COMPOSER_HOME=/var/composer @@ -20,6 +21,7 @@ ENV PHP_ENV=development COPY ./assets/php-fpm.conf /usr/local/etc/php-fpm.conf COPY ./assets/nginx.conf /etc/nginx/nginx.conf +COPY ./assets/000-default.conf /etc/apache2/sites-available/000-default.conf COPY ./php-flavours.json /tmp COPY ./assets/php-configuration.sh /tmp/ COPY ./assets/alpine-base-install.sh /tmp/ diff --git a/docker/debian-base.Dockerfile b/docker/debian-base.Dockerfile index a5ec571..8032362 100644 --- a/docker/debian-base.Dockerfile +++ b/docker/debian-base.Dockerfile @@ -3,7 +3,7 @@ ARG PHP_VERSION ARG PHP_BASE_IMAGE=8.3-fpm-bookworm ARG GIT_SHA ARG NODE_VERSION -ARG ZIP_SOURCE +ARG SERVER_FLAVOUR # ------------------------------------- # PrestaShop Flashlight: Debian image @@ -13,12 +13,14 @@ ARG PS_VERSION ARG PHP_VERSION ARG GIT_SHA ARG NODE_VERSION +ARG SERVER_FLAVOUR ENV PS_FOLDER=/var/www/html ENV COMPOSER_HOME=/var/composer ENV PHP_ENV=development COPY ./assets/php-fpm.conf /usr/local/etc/php-fpm.conf COPY ./assets/nginx.conf /etc/nginx/nginx.conf +COPY ./assets/000-default.conf /etc/apache2/sites-available/000-default.conf COPY ./php-flavours.json /tmp COPY ./assets/php-configuration.sh /tmp/ COPY ./assets/debian-base-install.sh /tmp/ diff --git a/docker/flashlight.Dockerfile b/docker/flashlight.Dockerfile index df521da..e544ff9 100644 --- a/docker/flashlight.Dockerfile +++ b/docker/flashlight.Dockerfile @@ -1,8 +1,10 @@ # -------------------------------- # Flashlight install and dump SQL # -------------------------------- +ARG BASE_DOCKER_IMAGE ARG PHP_BASE_IMAGE -FROM prestashop/prestashop-flashlight:base-${PHP_BASE_IMAGE} AS build-and-dump +ARG SERVER_FLAVOUR +FROM ${BASE_DOCKER_IMAGE}:base-${PHP_BASE_IMAGE}-${SERVER_FLAVOUR} AS build-and-dump ARG PS_VERSION ARG PHP_VERSION ARG GIT_SHA @@ -13,7 +15,7 @@ ARG ZIP_SOURCE # hadolint ignore=DL3020 ADD ${ZIP_SOURCE} /tmp/prestashop.zip -# Extract the souces +# Extract the sources RUN mkdir -p "$PS_FOLDER" /tmp/unzip-ps \ && unzip -n -q /tmp/prestashop.zip -d /tmp/unzip-ps \ && ([ -f /tmp/unzip-ps/prestashop.zip ] \ @@ -39,11 +41,14 @@ RUN sh /hydrate.sh # ----------------------- # Flashlight final image # ----------------------- +ARG BASE_DOCKER_IMAGE ARG PHP_BASE_IMAGE -FROM prestashop/prestashop-flashlight:base-${PHP_BASE_IMAGE} AS prestashop-flashlight +ARG SERVER_FLAVOUR +FROM ${BASE_DOCKER_IMAGE}:base-${PHP_BASE_IMAGE}-${SERVER_FLAVOUR} AS prestashop-flashlight ARG PS_VERSION ARG PHP_VERSION ARG PHP_BASE_IMAGE +ARG SERVER_FLAVOUR ARG PS_FOLDER=/var/www/html WORKDIR $PS_FOLDER @@ -51,6 +56,7 @@ ENV PHP_BASE_IMAGE=$PHP_BASE_IMAGE ENV PHP_VERSION=$PHP_VERSION ENV PS_VERSION=$PS_VERSION ENV PS_FOLDER=$PS_FOLDER +ENV SERVER_FLAVOUR=$SERVER_FLAVOUR RUN mkdir -p "$COMPOSER_HOME" \ && chown -R www-data:www-data "$COMPOSER_HOME"