Skip to content

Commit

Permalink
fix: adjust user used in cache watcher installation in PHP images to …
Browse files Browse the repository at this point in the history
…avoid ownership errors [#1]
  • Loading branch information
d3p1 committed Dec 11, 2024
1 parent 8826636 commit 94626ce
Show file tree
Hide file tree
Showing 8 changed files with 256 additions and 224 deletions.
4 changes: 4 additions & 0 deletions src/images/php/7.3-cli/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ FROM magento/magento-cloud-docker-php:7.3-cli-1.3.6
##
# @note Install Magento cache watcher globally to be able to use it
# as a development tool
# @note Switch temporarily to `www` user to avoid change
# ownership of Composer files to `root`
# @link https://github.com/mage2tv/magento-cache-clean
##
USER www
RUN composer global require mage2tv/magento-cache-clean
USER root
116 changes: 60 additions & 56 deletions src/images/php/7.3-fpm-dev/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,64 +24,68 @@
# @note Add Xdebug for debugging purpose
##
FROM d3p1/magento-php:7.3-fpm
##
# @note Add Composer
# @note Add Composer binary folder to `$PATH` so it is possible to execute
# global utilities without having to locate them by path
# @link https://github.com/magento/magento-cloud-docker/blob/9998e5615a37cc584ac26b236104ae040aa6e0c5/images/php/cli/Dockerfile#L21
# @link https://stackoverflow.com/questions/27093612/in-a-dockerfile-how-to-update-path-environment-variable
##
ENV COMPOSER_MEMORY_LIMIT=-1
ENV COMPOSER_ALLOW_SUPERUSER=1
ENV COMPOSER_HOME="/composer"
ENV PATH="${PATH}:${COMPOSER_HOME}/vendor/bin"
COPY --from=d3p1/magento-php:7.3-cli \
/usr/local/bin/composer \
/usr/local/bin/composer
RUN mkdir ${COMPOSER_HOME}
RUN chown -R www:www ${COMPOSER_HOME}
##
# @note Add Composer
# @note Add Composer binary folder to `$PATH` so it is possible to execute
# global utilities without having to locate them by path
# @link https://github.com/magento/magento-cloud-docker/blob/9998e5615a37cc584ac26b236104ae040aa6e0c5/images/php/cli/Dockerfile#L21
# @link https://stackoverflow.com/questions/27093612/in-a-dockerfile-how-to-update-path-environment-variable
##
ENV COMPOSER_MEMORY_LIMIT=-1
ENV COMPOSER_ALLOW_SUPERUSER=1
ENV COMPOSER_HOME="/composer"
ENV PATH="${PATH}:${COMPOSER_HOME}/vendor/bin"
COPY --from=d3p1/magento-php:7.3-cli \
/usr/local/bin/composer \
/usr/local/bin/composer
RUN mkdir ${COMPOSER_HOME}
RUN chown -R www:www ${COMPOSER_HOME}

##
# @note Install common/required development tools
##
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y --no-install-recommends \
git \
mariadb-client \
nodejs \
python3 \
python3-pip \
redis-tools && \
rm -rf /var/lib/apt/lists/*
##
# @note Install common/required development tools
##
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y --no-install-recommends \
git \
mariadb-client \
nodejs \
python3 \
python3-pip \
redis-tools && \
rm -rf /var/lib/apt/lists/*

##
# @note Install Magento cache watcher globally to be able to use it
# as a development tool
# @link https://github.com/mage2tv/magento-cache-clean
##
RUN composer global require mage2tv/magento-cache-clean
##
# @note Install Magento cache watcher globally to be able to use it
# as a development tool
# @note Switch temporarily to `www` user to avoid change
# ownership of Composer files to `root`
# @link https://github.com/mage2tv/magento-cache-clean
##
USER www
RUN composer global require mage2tv/magento-cache-clean
USER root

##
# @note Remove Xdebug configuration customization done in base image,
# so Xdebug can connect to an IDE that lives in the container.
# This is useful because the main porpouse of this image is
# to be able to use it to run a Dev Container
# @link https://github.com/magento/magento-cloud-docker/blob/36d595ca424dd73d104459f89a8c0d42617f601d/images/php/7.4-fpm/Dockerfile#L160
##
COPY etc/php-xdebug.ini /usr/local/etc/php/conf.d/zz-xdebug-settings.ini
##
# @note Remove Xdebug configuration customization done in base image,
# so Xdebug can connect to an IDE that lives in the container.
# This is useful because the main porpouse of this image is
# to be able to use it to run a Dev Container
# @link https://github.com/magento/magento-cloud-docker/blob/36d595ca424dd73d104459f89a8c0d42617f601d/images/php/7.4-fpm/Dockerfile#L160
##
COPY etc/php-xdebug.ini /usr/local/etc/php/conf.d/zz-xdebug-settings.ini

##
# @note Add Xdebug as current enabled extensions
# @link https://github.com/magento/magento-cloud-docker/blob/9998e5615a37cc584ac26b236104ae040aa6e0c5/images/php/fpm/docker-entrypoint.sh#L13
##
ENV PHP_EXTENSIONS="bcmath bz2 calendar exif gd gettext intl mysqli pdo_mysql redis soap sockets sodium sysvmsg sysvsem sysvshm xsl zip pcntl xdebug"
##
# @note Add Xdebug as current enabled extensions
# @link https://github.com/magento/magento-cloud-docker/blob/9998e5615a37cc584ac26b236104ae040aa6e0c5/images/php/fpm/docker-entrypoint.sh#L13
##
ENV PHP_EXTENSIONS="bcmath bz2 calendar exif gd gettext intl mysqli pdo_mysql redis soap sockets sodium sysvmsg sysvsem sysvshm xsl zip pcntl xdebug"

##
# @note Add custom entrypoint to include startup logic
# @link https://github.com/magento/magento-cloud-docker/blob/9998e5615a37cc584ac26b236104ae040aa6e0c5/images/php/fpm/Dockerfile#L72
##
COPY main.docker-entrypoint.sh /
RUN chmod +x /main.docker-entrypoint.sh
ENTRYPOINT ["/main.docker-entrypoint.sh"]
CMD ["php-fpm", "-R"]
##
# @note Add custom entrypoint to include startup logic
# @link https://github.com/magento/magento-cloud-docker/blob/9998e5615a37cc584ac26b236104ae040aa6e0c5/images/php/fpm/Dockerfile#L72
##
COPY main.docker-entrypoint.sh /
RUN chmod +x /main.docker-entrypoint.sh
ENTRYPOINT ["/main.docker-entrypoint.sh"]
CMD ["php-fpm", "-R"]
4 changes: 4 additions & 0 deletions src/images/php/7.4-cli/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ FROM magento/magento-cloud-docker-php:7.4-cli-1.4.0
##
# @note Install Magento cache watcher globally to be able to use it
# as a development tool
# @note Switch temporarily to `www` user to avoid change
# ownership of Composer files to `root`
# @link https://github.com/mage2tv/magento-cache-clean
##
USER www
RUN composer global require mage2tv/magento-cache-clean
USER root
116 changes: 60 additions & 56 deletions src/images/php/7.4-fpm-dev/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,64 +24,68 @@
# @note Add Xdebug for debugging purpose
##
FROM d3p1/magento-php:7.4-fpm
##
# @note Add Composer
# @note Add Composer binary folder to `$PATH` so it is possible to execute
# global utilities without having to locate them by path
# @link https://github.com/magento/magento-cloud-docker/blob/9998e5615a37cc584ac26b236104ae040aa6e0c5/images/php/cli/Dockerfile#L21
# @link https://stackoverflow.com/questions/27093612/in-a-dockerfile-how-to-update-path-environment-variable
##
ENV COMPOSER_MEMORY_LIMIT=-1
ENV COMPOSER_ALLOW_SUPERUSER=1
ENV COMPOSER_HOME="/composer"
ENV PATH="${PATH}:${COMPOSER_HOME}/vendor/bin"
COPY --from=d3p1/magento-php:7.4-cli \
/usr/local/bin/composer \
/usr/local/bin/composer
RUN mkdir ${COMPOSER_HOME}
RUN chown -R www:www ${COMPOSER_HOME}
##
# @note Add Composer
# @note Add Composer binary folder to `$PATH` so it is possible to execute
# global utilities without having to locate them by path
# @link https://github.com/magento/magento-cloud-docker/blob/9998e5615a37cc584ac26b236104ae040aa6e0c5/images/php/cli/Dockerfile#L21
# @link https://stackoverflow.com/questions/27093612/in-a-dockerfile-how-to-update-path-environment-variable
##
ENV COMPOSER_MEMORY_LIMIT=-1
ENV COMPOSER_ALLOW_SUPERUSER=1
ENV COMPOSER_HOME="/composer"
ENV PATH="${PATH}:${COMPOSER_HOME}/vendor/bin"
COPY --from=d3p1/magento-php:7.4-cli \
/usr/local/bin/composer \
/usr/local/bin/composer
RUN mkdir ${COMPOSER_HOME}
RUN chown -R www:www ${COMPOSER_HOME}

##
# @note Install common/required development tools
##
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y --no-install-recommends \
git \
mariadb-client \
nodejs \
python3 \
python3-pip \
redis-tools && \
rm -rf /var/lib/apt/lists/*
##
# @note Install common/required development tools
##
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y --no-install-recommends \
git \
mariadb-client \
nodejs \
python3 \
python3-pip \
redis-tools && \
rm -rf /var/lib/apt/lists/*

##
# @note Install Magento cache watcher globally to be able to use it
# as a development tool
# @link https://github.com/mage2tv/magento-cache-clean
##
RUN composer global require mage2tv/magento-cache-clean
##
# @note Install Magento cache watcher globally to be able to use it
# as a development tool
# @note Switch temporarily to `www` user to avoid change
# ownership of Composer files to `root`
# @link https://github.com/mage2tv/magento-cache-clean
##
USER www
RUN composer global require mage2tv/magento-cache-clean
USER root

##
# @note Remove Xdebug configuration customization done in base image,
# so Xdebug can connect to an IDE that lives in the container.
# This is useful because the main porpouse of this image is
# to be able to use it to run a Dev Container
# @link https://github.com/magento/magento-cloud-docker/blob/36d595ca424dd73d104459f89a8c0d42617f601d/images/php/7.4-fpm/Dockerfile#L160
##
COPY etc/php-xdebug.ini /usr/local/etc/php/conf.d/zz-xdebug-settings.ini
##
# @note Remove Xdebug configuration customization done in base image,
# so Xdebug can connect to an IDE that lives in the container.
# This is useful because the main porpouse of this image is
# to be able to use it to run a Dev Container
# @link https://github.com/magento/magento-cloud-docker/blob/36d595ca424dd73d104459f89a8c0d42617f601d/images/php/7.4-fpm/Dockerfile#L160
##
COPY etc/php-xdebug.ini /usr/local/etc/php/conf.d/zz-xdebug-settings.ini

##
# @note Add Xdebug as current enabled extensions
# @link https://github.com/magento/magento-cloud-docker/blob/9998e5615a37cc584ac26b236104ae040aa6e0c5/images/php/fpm/docker-entrypoint.sh#L13
##
ENV PHP_EXTENSIONS="bcmath bz2 calendar exif gd gettext intl mysqli pdo_mysql redis soap sockets sodium sysvmsg sysvsem sysvshm xsl zip pcntl xdebug"
##
# @note Add Xdebug as current enabled extensions
# @link https://github.com/magento/magento-cloud-docker/blob/9998e5615a37cc584ac26b236104ae040aa6e0c5/images/php/fpm/docker-entrypoint.sh#L13
##
ENV PHP_EXTENSIONS="bcmath bz2 calendar exif gd gettext intl mysqli pdo_mysql redis soap sockets sodium sysvmsg sysvsem sysvshm xsl zip pcntl xdebug"

##
# @note Add custom entrypoint to include startup logic
# @link https://github.com/magento/magento-cloud-docker/blob/9998e5615a37cc584ac26b236104ae040aa6e0c5/images/php/fpm/Dockerfile#L72
##
COPY main.docker-entrypoint.sh /
RUN chmod +x /main.docker-entrypoint.sh
ENTRYPOINT ["/main.docker-entrypoint.sh"]
CMD ["php-fpm", "-R"]
##
# @note Add custom entrypoint to include startup logic
# @link https://github.com/magento/magento-cloud-docker/blob/9998e5615a37cc584ac26b236104ae040aa6e0c5/images/php/fpm/Dockerfile#L72
##
COPY main.docker-entrypoint.sh /
RUN chmod +x /main.docker-entrypoint.sh
ENTRYPOINT ["/main.docker-entrypoint.sh"]
CMD ["php-fpm", "-R"]
4 changes: 4 additions & 0 deletions src/images/php/8.1-cli/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ FROM magento/magento-cloud-docker-php:8.1-cli-1.3.7
##
# @note Install Magento cache watcher globally to be able to use it
# as a development tool
# @note Switch temporarily to `www` user to avoid change
# ownership of Composer files to `root`
# @link https://github.com/mage2tv/magento-cache-clean
##
USER www
RUN composer global require mage2tv/magento-cache-clean
USER root
Loading

0 comments on commit 94626ce

Please sign in to comment.