Skip to content

magento2 on kubernetes

I am trying to deploy magento on Kubernetes, I am using php-fpm as a base image with nginx, the magento files are available locally on Docker, but when I move it to Kubernetes i do notenter code here see anything in the PVC,

FROM php:8.2.12-fpm@sha256:2aa938b6d62f7415e9c84d867d9ceed18ef8ec3cf3944d389e088c93f9678a84 as base
ENV MAGENTO_PUBLIC_KEY “”
ENV MAGENTO_PRIVATE_KEY “”
ENV MAGENTO_VERSION 2.4.6-p3
ENV COMPOSER_HOME=/tmp/composer

RUN apt-get update && apt-get install -y –no-install-recommends gnupg
nginx
netcat-openbsd
libicu-dev
libfreetype6-dev
libjpeg-dev
libpng-dev
libsodium-dev
libxml2-dev
libxslt-dev
libzip-dev
rsync
supervisor
unzip
cron
default-mysql-client
git
gnupg
gzip
libbz2-dev
libfreetype6-dev
libicu-dev
libjpeg62-turbo-dev
libmagickwand-dev
libmcrypt-dev
libonig-dev
libpng-dev
libsodium-dev
libssh2-1-dev
libwebp-dev
libxslt1-dev
libzip-dev
lsof
mailutils
msmtp
nodejs
procps
vim
zip
&& rm -rf /var/lib/apt/lists/*

RUN pecl channel-update pecl.php.net && pecl install
imagick
redis
ssh2-1.3.1
xdebug
&& pecl clear-cache
&& rm -rf /tmp/pear

RUN docker-php-ext-configure
gd –with-freetype –with-jpeg –with-webp
&& docker-php-ext-install
bcmath
bz2
calendar
exif
gd
gettext
intl
mbstring
mysqli
opcache
pcntl
pdo_mysql
soap
sockets
sodium
sysvmsg
sysvsem
sysvshm
xsl
zip
&& docker-php-ext-enable
imagick
redis
ssh2
xdebug

RUN docker-php-ext-enable apcu

RUN echo “memory_limit=1G” >> /usr/local/etc/php/conf.d/zz-memory-limit-php.ini
RUN echo “apc.enable=1” >> /usr/local/etc/php/conf.d/zz-apcu.ini
RUN echo “apc.enable_cli=1” >> /usr/local/etc/php/conf.d/zz-apcu.ini
RUN echo “opcache.memory_consumption=512MB” >> /usr/local/etc/php/conf.d/zz-opcache.conf
RUN echo “opcache.max_accelerated_files=60000” >> /usr/local/etc/php/conf.d/zz-opcache.conf
RUN echo “opcache.consistency_checks=0” >> /usr/local/etc/php/conf.d/zz-opcache.conf
RUN echo “opcache.validate_timestamps=0” >> /usr/local/etc/php/conf.d/zz-opcache.conf
RUN echo “opcache.enable_cli=1” >> /usr/local/etc/php/conf.d/zz-opcache.conf

RUN mkdir -p /var/lib/nginx/{body,fastcgi} &&
chown -R www-data:www-data /var/lib/nginx

RUN touch /run/nginx.pid &&
chown www-data:www-data /run/nginx.pid

COPY etc/supervisord.conf /etc/supervisor/supervisord.conf
COPY etc/nginx /etc/nginx

RUN curl https://files.magerun.net/n98-magerun2.phar -o /usr/local/bin/magerun
&& chmod 755 /usr/local/bin/magerun

RUN mkdir -p /var/log/supervisor
&& chown www-data:www-data /var/log/supervisor

WORKDIR /var/www/html

ARG COMPOSER_AUTH

COPY –from=composer:2.6.5@sha256:fb3c5a283f2dc08e08841048498e8a82c3864648c84255b5ad7243b38d33a8db /usr/bin/composer /usr/bin/composer

RUN composer config -g http-basic.repo.magento.com $MAGENTO_PUBLIC_KEY $MAGENTO_PRIVATE_KEY;
composer create-project –repository-url=https://repo.magento.com/ magento/project-enterprise-edition:${MAGENTO_VERSION} .

COPY bin bin
COPY bin/entrypoint.sh /usr/local/bin/docker-php-entrypoint

RUN rm -rf /var/www/html/var/cache
RUN rm -rf /var/www/html/var/page_cache
RUN rm -rf /var/www/html/var/session