woocommerce-paypal-payments/docker/Dockerfile_wp
2021-10-08 10:21:33 +03:00

159 lines
4 KiB
Text

ARG PHP_BUILD_VERSION
ARG PHP_TEST_VERSION
ARG PHP_DEPS_VERSION
ARG WP_VERSION
# Composer on correct PHP version
FROM php:${PHP_DEPS_VERSION}-cli as composer
ARG BUILD_ROOT_PATH
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
RUN echo 'memory_limit = 128M' >> /usr/local/etc/php/conf.d/docker-php-memlimit.ini;
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
php composer-setup.php --install-dir=/usr/bin --filename=composer --version=1.10.22 && \
php -r "unlink('composer-setup.php');"
RUN apt-get update
RUN apt-get install -y \
ssh \
zip \
unzip \
curl \
git \
# These are for extensions
zlib1g-dev \
libicu-dev
RUN mkdir -p ~/.ssh
RUN ssh-keyscan -H github.com >> ~/.ssh/known_hosts
RUN docker-php-ext-install intl json && \
docker-php-ext-enable intl json
WORKDIR ${BUILD_ROOT_PATH}
# Composer on correct PHP version
FROM php:${PHP_BUILD_VERSION}-cli as build
ARG BUILD_ROOT_PATH
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
RUN echo 'memory_limit = 256M' >> /usr/local/etc/php/conf.d/docker-php-memlimit.ini;
RUN apt-get update
RUN apt-get install -y gnupg apt-transport-https ca-certificates
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update
RUN apt-get install -y \
ssh \
zip \
unzip \
curl \
git \
yarn \
ca-certificates \
# These are for extensions
zlib1g-dev \
libicu-dev \
g++ \
# For installing things from URL
wget
# https://github.com/nodesource/distributions/issues/1266
RUN update-ca-certificates
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
php composer-setup.php --install-dir=/usr/bin --filename=composer --version=1.10.22 && \
php -r "unlink('composer-setup.php');"
RUN mkdir -p ~/.ssh
RUN ssh-keyscan -H github.com >> ~/.ssh/known_hosts
RUN docker-php-ext-install intl json && \
docker-php-ext-enable intl json
# Install Node
RUN curl -sL https://deb.nodesource.com/setup_16.x | bash -
RUN apt-get install -y nodejs
WORKDIR ${BUILD_ROOT_PATH}
COPY . ./
FROM php:${PHP_TEST_VERSION}-cli as test
ARG BUILD_ROOT_PATH
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
RUN apt-get update
RUN apt-get install -y \
# These are for extensions
zlib1g-dev \
libicu-dev \
g++
RUN pecl install xdebug-2.6.1
RUN docker-php-ext-install pcntl posix intl json
WORKDIR ${BUILD_ROOT_PATH}
COPY --from=build ${BUILD_ROOT_PATH} ${BUILD_ROOT_PATH}
# Install PHP dev dependencies
FROM build as vendor-dev
ARG BUILD_ROOT_PATH
WORKDIR ${BUILD_ROOT_PATH}
COPY --from=build ${BUILD_ROOT_PATH} ${BUILD_ROOT_PATH}
RUN composer config discard-changes true && composer install --no-dev --no-scripts
# WordPress for development
FROM wordpress:${WP_VERSION}-php${PHP_TEST_VERSION}-apache as dev
ARG PROJECT_MOUNT_PATH
ARG BUILD_ROOT_PATH
ARG DOCROOT_PATH
ARG WP_DOMAIN
COPY docker/wp-entrypoint.sh /usr/local/bin
COPY docker/wait-for-it.sh /usr/local/bin
RUN chmod +x /usr/local/bin/wp-entrypoint.sh /usr/local/bin/wait-for-it.sh
RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar \
&& chmod +x wp-cli.phar \
&& mv wp-cli.phar /usr/local/bin/wp
RUN sed -i "s|#ServerName www.example.com|ServerName ${WP_DOMAIN}|" /etc/apache2/sites-available/*.conf
RUN sed -i "s|#ServerName www.example.com|ServerName ${WP_DOMAIN}|" /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
RUN apt-get update
RUN apt-get install -y \
zip \
unzip \
curl \
# These are for extensions
zlib1g-dev \
libicu-dev \
g++
RUN docker-php-ext-install pcntl posix intl json
RUN apt-get remove -y \
# These are for extensions
zlib1g-dev \
libicu-dev \
g++
WORKDIR ${DOCROOT_PATH}
COPY --from=vendor-dev ${BUILD_ROOT_PATH} ${PROJECT_MOUNT_PATH}
ENTRYPOINT ["wp-entrypoint.sh"]
CMD ["apache2-foreground"]