Skip to content

Commit 269a440

Browse files
authored
Merge pull request #120 from magento-commerce/MCLOUD-11525
Added support for PHP8.3
2 parents e1ea193 + 54854f1 commit 269a440

26 files changed

+665
-4
lines changed

images/php/8.3-cli/Dockerfile

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
# This file is automatically generated. Do not edit directly. #
2+
FROM golang:1.15 AS builder
3+
4+
RUN if [ $(uname -m) = "x86_64" ]; then mailhog_arch="amd64"; else mailhog_arch="arm64"; fi \
5+
&& wget -O mhsendmail.tar.gz https://github.com/mailhog/mhsendmail/archive/refs/tags/v0.2.0.tar.gz \
6+
&& tar -xf mhsendmail.tar.gz \
7+
&& mkdir -p ./src/github.com/mailhog/ \
8+
&& mv ./mhsendmail-0.2.0 ./src/github.com/mailhog/mhsendmail \
9+
&& cd ./src/github.com/mailhog/mhsendmail/ \
10+
&& go get . \
11+
&& GOOS=linux GOARCH=${mailhog_arch} go build -o mhsendmail .
12+
13+
FROM php:8.3-cli
14+
15+
ARG COMPOSER_VERSION=2.2.18
16+
ARG MAGENTO_ROOT=/app
17+
ARG COMPOSER_ALLOW_SUPERUSER=1
18+
ARG COMPOSER_HOME=/composer
19+
ARG CRONTAB=""
20+
21+
ENV COMPOSER_MEMORY_LIMIT -1
22+
ENV COMPOSER_ALLOW_SUPERUSER ${COMPOSER_ALLOW_SUPERUSER}
23+
ENV COMPOSER_HOME ${COMPOSER_HOME}
24+
ENV COMPOSER_CLEAR_CACHE false
25+
ENV PHP_MEMORY_LIMIT -1
26+
ENV PHP_VALIDATE_TIMESTAMPS 1
27+
ENV DEBUG false
28+
ENV MAGENTO_RUN_MODE production
29+
ENV SENDMAIL_PATH /dev/null
30+
ENV PHPRC ${MAGENTO_ROOT}/php.ini
31+
32+
ENV PHP_EXTENSIONS bcmath bz2 calendar exif gd gettext intl mysqli opcache pdo_mysql redis soap sockets sodium sysvmsg sysvsem sysvshm xsl zip pcntl
33+
34+
# Configure Node.js version
35+
RUN curl -sL https://deb.nodesource.com/setup_lts.x | bash
36+
37+
# Install dependencies
38+
RUN apt-get update \
39+
&& apt-get upgrade -y \
40+
&& apt-get install -y --no-install-recommends \
41+
apt-utils \
42+
cron \
43+
git \
44+
mariadb-client \
45+
nano \
46+
nodejs \
47+
python3 \
48+
python3-pip \
49+
redis-tools \
50+
sendmail-bin \
51+
sendmail \
52+
sudo \
53+
unzip \
54+
vim \
55+
openssh-client \
56+
gnupg2 \
57+
ca-certificates \
58+
lsb-release \
59+
software-properties-common \
60+
libbz2-dev \
61+
libjpeg62-turbo-dev \
62+
libpng-dev \
63+
libfreetype6-dev \
64+
libgmp-dev \
65+
libgpgme11-dev \
66+
libicu-dev \
67+
libldap2-dev \
68+
libpcre3-dev \
69+
libpspell-dev \
70+
libtidy-dev \
71+
libxslt1-dev \
72+
libyaml-dev \
73+
libzip-dev \
74+
zip \
75+
python3-yaml \
76+
&& rm -rf /var/lib/apt/lists/*
77+
78+
# Install Python packages
79+
80+
81+
# Install Grunt
82+
RUN npm install -g grunt-cli
83+
84+
# Install MailHog
85+
COPY --from=builder /go/src/github.com/mailhog/mhsendmail/mhsendmail /usr/local/bin/
86+
RUN sudo chmod +x /usr/local/bin/mhsendmail
87+
88+
# Configure the gd library
89+
RUN docker-php-ext-configure \
90+
gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/
91+
RUN docker-php-ext-configure \
92+
opcache --enable-opcache
93+
94+
# Install required PHP extensions
95+
RUN docker-php-ext-install -j$(nproc) \
96+
bcmath \
97+
bz2 \
98+
calendar \
99+
exif \
100+
gd \
101+
gettext \
102+
gmp \
103+
intl \
104+
mysqli \
105+
opcache \
106+
pdo_mysql \
107+
pspell \
108+
shmop \
109+
soap \
110+
sockets \
111+
sysvmsg \
112+
sysvsem \
113+
sysvshm \
114+
tidy \
115+
xsl \
116+
zip \
117+
pcntl
118+
119+
RUN pecl install -o -f \
120+
gnupg \
121+
mailparse \
122+
msgpack \
123+
oauth \
124+
pcov \
125+
raphf \
126+
redis \
127+
xdebug-3.3.0 \
128+
xmlrpc-1.0.0RC3 \
129+
yaml
130+
131+
RUN curl -L https://packages.blackfire.io/gpg.key | gpg --dearmor > blackfire.io-archive-keyring.gpg \
132+
&& install -o root -g root -m 644 blackfire.io-archive-keyring.gpg /etc/apt/trusted.gpg.d/ \
133+
&& echo "deb http://packages.blackfire.io/debian any main" | tee /etc/apt/sources.list.d/blackfire.list \
134+
&& apt-get update \
135+
&& apt-get install blackfire-php \
136+
&& rm -rf /var/lib/apt/lists/*
137+
RUN if [ $(uname -m) = "x86_64" ]; then ldap_arch="x86_64-linux-gnu"; else ldap_arch="aarch64-linux-gnu"; fi \
138+
&& docker-php-ext-configure ldap --with-libdir=lib/${ldap_arch}
139+
RUN rm -f /usr/local/etc/php/conf.d/*sodium.ini \
140+
&& rm -f /usr/local/lib/php/extensions/*/*sodium.so \
141+
&& apt-get remove libsodium* -y \
142+
&& mkdir -p /tmp/libsodium \
143+
&& curl -sL https://github.com/jedisct1/libsodium/archive/1.0.18-RELEASE.tar.gz | tar xzf - -C /tmp/libsodium \
144+
&& cd /tmp/libsodium/libsodium-1.0.18-RELEASE/ \
145+
&& ./configure \
146+
&& make && make check \
147+
&& make install \
148+
&& cd / \
149+
&& rm -rf /tmp/libsodium \
150+
&& pecl install -o -f libsodium
151+
152+
ADD etc/php-cli.ini /usr/local/etc/php/conf.d/zz-magento.ini
153+
ADD etc/php-xdebug.ini /usr/local/etc/php/conf.d/zz-xdebug-settings.ini
154+
ADD etc/php-pcov.ini /usr/local/etc/php/conf.d/zz-pcov-settings.ini
155+
ADD etc/mail.ini /usr/local/etc/php/conf.d/zz-mail.ini
156+
ADD etc/php-gnupg.ini /usr/local/etc/php/conf.d/gnupg.ini
157+
158+
# Get composer installed to /usr/local/bin/composer
159+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --version=${COMPOSER_VERSION} --filename=composer
160+
161+
ADD bin/* /usr/local/bin/
162+
163+
RUN groupadd -g 1000 www && useradd -g 1000 -u 1000 -d ${MAGENTO_ROOT} -s /bin/bash www
164+
165+
ADD docker-entrypoint.sh /docker-entrypoint.sh
166+
167+
RUN ["chmod", "+x", \
168+
"/docker-entrypoint.sh", \
169+
"/usr/local/bin/magento-installer", \
170+
"/usr/local/bin/magento-command", \
171+
"/usr/local/bin/mftf-command", \
172+
"/usr/local/bin/ece-command", \
173+
"/usr/local/bin/cloud-build", \
174+
"/usr/local/bin/cloud-deploy", \
175+
"/usr/local/bin/cloud-post-deploy", \
176+
"/usr/local/bin/run-cron", \
177+
"/usr/local/bin/run-hooks" \
178+
]
179+
180+
RUN mkdir -p ${MAGENTO_ROOT}
181+
182+
VOLUME ${MAGENTO_ROOT}
183+
184+
RUN chown -R www:www /usr/local /var/www /var/log /usr/local/etc/php/conf.d /etc/cron.d ${MAGENTO_ROOT} ${COMPOSER_HOME}
185+
RUN if [ ! -z "${CRONTAB}" ]; then echo "${CRONTAB}" > /etc/cron.d/magento && touch /var/log/cron.log ; fi
186+
187+
ENTRYPOINT ["/docker-entrypoint.sh"]
188+
189+
WORKDIR ${MAGENTO_ROOT}
190+
191+
USER root
192+
193+
CMD ["bash"]

images/php/8.3-cli/bin/cloud-build

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
[ "$DEBUG" = "true" ] && set -x
6+
7+
RUN_HOOKS="run-hooks"
8+
9+
if [ "$MAGENTO_RUN_MODE" == "production" ]; then
10+
echo "Cleaning directories:"
11+
12+
if [ "$INSTALLATION_TYPE" == "composer" ]; then
13+
echo "Cleaning setup directory."
14+
rm -rf $MAGENTO_ROOT/setup/*
15+
fi
16+
17+
echo "Cleaning vendor directory."
18+
rm -rf $MAGENTO_ROOT/vendor/*
19+
20+
echo "Cleaning generated directory."
21+
rm -rf $MAGENTO_ROOT/generated/*
22+
23+
echo "Removing app/etc/env.php file"
24+
rm -f $MAGENTO_ROOT/app/etc/env.php
25+
fi
26+
27+
echo "Installing dependencies."
28+
29+
composer --working-dir=$MAGENTO_ROOT install --no-suggest --no-ansi --no-interaction --no-progress --prefer-dist
30+
31+
echo "Running \"build\" hook."
32+
33+
$RUN_HOOKS build
34+
35+
if [ "$MAGENTO_RUN_MODE" == "production" ]; then
36+
echo "Setting file permissions."
37+
38+
chown -R www:www $MAGENTO_ROOT
39+
40+
find $MAGENTO_ROOT/pub -type f -exec chmod 664 {} \;
41+
find $MAGENTO_ROOT/pub -type d -exec chmod 775 {} \;
42+
fi
43+
44+
echo "Building complete."

images/php/8.3-cli/bin/cloud-deploy

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
[ "$DEBUG" = "true" ] && set -x
6+
7+
echo "Running \"deploy\" hook."
8+
9+
run-hooks deploy
10+
11+
# check that Varnish exists
12+
if ( varnish=$(curl -I varnish 2>&1 | grep -i "magento2") ); then
13+
minor_magento_version=$(magento-command --version | sed "s/Magento CLI version \([0-9]*\.[0-9]*\).*/\1/")
14+
if [[ "$minor_magento_version" != "2.1" ]]; then
15+
output=$(magento-command config:set system/full_page_cache/caching_application 2)
16+
# as config:set does not return error code, we check output text to continue set varnish settings
17+
if [[ $output == *"Value was saved"* ]]; then
18+
echo "Setting Varnish for Magento FPC."
19+
magento-command setup:config:set --http-cache-hosts=varnish -n
20+
else
21+
echo $output
22+
fi
23+
fi
24+
fi
25+
26+
# set developer mode if it is configured in $MAGENTO_RUN_MODE
27+
if [ "$MAGENTO_RUN_MODE" == "developer" ]; then
28+
output=$(magento-command deploy:mode:set developer)
29+
if [[ $output == *"Enabled developer mode."* ]]; then
30+
echo "Enabled developer mode."
31+
else
32+
echo $output
33+
fi
34+
fi
35+
36+
37+
echo "Deployment finished."
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
[ "$DEBUG" = "true" ] && set -x
6+
7+
echo "Running \"post-deploy\" hook."
8+
9+
run-hooks post_deploy
10+
11+
echo "Post deployment finished."

images/php/8.3-cli/bin/ece-command

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
[ "$DEBUG" = "true" ] && set -x
4+
5+
ECE_COMMAND="$MAGENTO_ROOT/vendor/bin/ece-tools"
6+
7+
exec $ECE_COMMAND "$@"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
[ "$DEBUG" = "true" ] && set -x
4+
5+
MAGENTO_COMMAND="php $MAGENTO_ROOT/bin/magento"
6+
7+
exec $MAGENTO_COMMAND "$@"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
[ "$DEBUG" = "true" ] && set -x
6+
7+
BUILD_COMMAND="cloud-build"
8+
DEPLOY_COMMAND="cloud-deploy"
9+
10+
$BUILD_COMMAND
11+
$DEPLOY_COMMAND

images/php/8.3-cli/bin/mftf-command

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
[ "$DEBUG" = "true" ] && set -x
4+
5+
MFTF_COMMAND="$MAGENTO_ROOT/vendor/bin/mftf"
6+
7+
exec $MFTF_COMMAND "$@"

images/php/8.3-cli/bin/run-cron

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
cron && tail -f -n0 /var/log/cron.log

images/php/8.3-cli/bin/run-hooks

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env python3
2+
3+
import os
4+
import sys
5+
import subprocess
6+
import json
7+
import base64
8+
9+
# Disable output buffering.
10+
os.environ['PYTHONUNBUFFERED'] = "1"
11+
12+
# The list of available hooks.
13+
available_hooks = ["build", "deploy", "post_deploy"]
14+
15+
16+
# Prints a message and returns an exit code.
17+
def error_exit(msg, code=1):
18+
print(msg)
19+
sys.exit(code)
20+
21+
22+
# Gets Magento root path.
23+
def get_magento_root():
24+
try:
25+
return str(os.environ['MAGENTO_ROOT'])
26+
except KeyError:
27+
error_exit('Environment variable MAGENTO_ROOT is not available')
28+
29+
30+
# Gets set hooks by hook name.
31+
def get_hooks(hook_name):
32+
try:
33+
application = str(os.environ['MAGENTO_CLOUD_APPLICATION'])
34+
content = json.loads(base64.b64decode(application).decode("utf-8"))
35+
36+
return content['hooks'][hook_name]
37+
except Exception as exc:
38+
error_exit("Cannot decode string: " + str(exc))
39+
40+
41+
# Main function.
42+
def main():
43+
if len(sys.argv) != 2:
44+
error_exit("Usage: run-hooks <hook-name>")
45+
46+
hook_name = str(sys.argv[1])
47+
if hook_name not in available_hooks:
48+
error_exit("The hook \"" + hook_name + "\" is not available. The list of available hooks: " + ", ".join(available_hooks))
49+
50+
try:
51+
subprocess.check_call(
52+
get_hooks(hook_name),
53+
shell=True,
54+
cwd=get_magento_root()
55+
)
56+
except subprocess.CalledProcessError as exc:
57+
error_exit("returned non-zero exit status " + str(exc.returncode))
58+
59+
60+
if __name__ == '__main__':
61+
main()

0 commit comments

Comments
 (0)