Files
wp-graphql-woocommerce/Dockerfile
T
Geoff TaylorandGitHub 1807b2e798 Add authenticated download URLs for headless frontends (#995)
* feat: add authenticated download URLs for headless frontends

- Add downloadNonce and downloadUrl fields to DownloadableItem type
  using the existing Protected Router session transfer pattern
- Add preAuthDownloadUrl field (toggleable via settings) that generates
  tokenized download URLs for direct file access without cookie auth
- Add download_url nonce handling to Protected_Router
- Add enable_pre_auth_download_urls and download_url_nonce_param settings
- Add GraphQLE2E helpers for checkout and account shortcode pages
- Rewrite ProtectedRouterCest to test redirect flow without JS-dependent
  page content assertions, add account and payment method URL tests
- Add DownloadableItemAuthCest with 5 e2e tests covering both options

* fix: test suite stability and code coverage collection

- Add WC_Unit_Tests_Bootstrap stub to wpunit bootstrap to bypass
  wc_get_product_visibility_term_ids static cache between suites
- Add setWooGraphQLSetting helper to GraphQLE2E for safe individual
  field updates to woographql_settings option with proper defaults
- Update all functional tests to use setWooGraphQLSetting instead of
  replacing the entire woographql_settings option
- Fix createRelated factory to use explicit shared category instead
  of relying on default Uncategorized category
- Add download_url to ProtectedRouterTest nonce names assertion
- Remove debug logs from ProductQueriesTest and ProductsQueriesTest
- Fix CI workflow to run suites separately and aggregate coverage
  via phpcov merge
- Wire c3.php into WordPress index.php for remote coverage collection
- Update .coveralls.yml service_name to github-actions
- Clean up Xdebug 2 settings in Dockerfile

* chore: Linter compliances met

* fix: ensure tests/_output is writable for c3.php coverage collection

* devops: .env.docker removed from setup

* devops: split CI into separate jobs per suite with retry and coverage aggregation

* devops: add +Coverage indicator to CI job names

* devops: add --fail-fast to first run, fix retry to mark job as passing on retry success
2026-03-26 17:20:55 -04:00

105 lines
3.5 KiB
Docker

ARG PHP_VERSION
FROM wordpress:php${PHP_VERSION}-apache
RUN apt-get update; \
apt-get install -y --no-install-recommends \
# WP-CLI dependencies.
bash less mariadb-client git \
# MailHog dependencies.
msmtp \
# Dockerize dependencies.
wget;
# Setup xdebug. The latest version supported by PHP 5.6 is 2.5.5.
RUN pecl install xdebug; \
docker-php-ext-enable xdebug; \
echo "xdebug.default_enable = 1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \
echo "xdebug.remote_autostart = 0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \
echo "xdebug.remote_connect_back = 0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \
echo "xdebug.remote_enable = 1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \
echo "xdebug.remote_port = 9000" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \
echo "xdebug.remote_log = ${PLUGINS_DIR}/wp-graphql-woocommerce/xdebug.log" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \
echo "xdebug.mode = coverage" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini;
ENV XDEBUG_MODE=coverage
# Install PDO MySQL driver.
RUN docker-php-ext-install pdo_mysql
# Install composer
ENV COMPOSER_ALLOW_SUPERUSER=1
RUN curl -sS https://getcomposer.org/installer | php -- \
--filename=composer \
--install-dir=/usr/local/bin
# Install WP-CLI
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
# Add composer global binaries to PATH
ENV PATH "$PATH:~/.composer/vendor/bin"
# Install wp-browser globally
RUN composer global require --optimize-autoloader \
wp-cli/wp-cli-bundle:* \
"lucatume/wp-browser:>3.1 <3.5" \
phpunit/phpunit:^9.6 \
codeception/module-asserts:* \
codeception/module-cli:* \
codeception/module-db:* \
codeception/module-filesystem:* \
codeception/module-phpbrowser:* \
codeception/module-rest:* \
codeception/module-webdriver:* \
codeception/util-universalframework:* \
guzzlehttp/guzzle \
league/factory-muffin \
league/factory-muffin-faker \
stripe/stripe-php \
wp-graphql/wp-graphql-testcase:^3.2
# Remove exec statement from base entrypoint script.
RUN sed -i '$d' /usr/local/bin/docker-entrypoint.sh
COPY local/php.ini /usr/local/etc/php/php.ini
# Disable SSL for MySQL client globally
RUN mkdir -p /etc/mysql/conf.d && \
echo '[client]' > /etc/mysql/conf.d/disable-ssl.cnf && \
echo 'ssl=0' >> /etc/mysql/conf.d/disable-ssl.cnf
RUN echo 'ServerName localhost' >> /etc/apache2/apache2.conf
RUN service apache2 restart
# Set project environmental variables
ENV WP_ROOT_FOLDER="/var/www/html"
ENV WORDPRESS_DB_HOST=${DB_HOST}
ENV WORDPRESS_DB_PORT=${DB_PORT}
ENV WORDPRESS_DB_USER=${DB_USER}
ENV WORDPRESS_DB_PASSWORD=${DB_PASSWORD}
ENV WORDPRESS_DB_NAME=${DB_NAME}
ENV PLUGINS_DIR="${WP_ROOT_FOLDER}/wp-content/plugins"
ENV PROJECT_DIR="${PLUGINS_DIR}/wp-graphql-woocommerce"
# Set up Apache
RUN echo 'ServerName localhost' >> /etc/apache2/apache2.conf
RUN a2enmod rewrite
WORKDIR /var/www/html
# Set codecept wrapper
COPY bin/codecept /usr/local/bin/codecept
RUN chmod 755 /usr/local/bin/codecept
# Set stall script.
ADD https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh /usr/local/bin/wait-for-it
RUN chmod 755 /usr/local/bin/wait-for-it
# Set up entrypoint
COPY bin/entrypoint.sh /usr/local/bin/app-entrypoint.sh
RUN chmod 755 /usr/local/bin/app-entrypoint.sh
ENTRYPOINT ["app-entrypoint.sh"]
CMD ["apache2-foreground"]