2020-08-12 16:09:35 +02:00
|
|
|
# Inherit from the farmOS 2.x image.
|
|
|
|
FROM farmos/farmos:2.x
|
2020-04-20 04:09:56 +02:00
|
|
|
|
2020-06-06 13:35:43 +02:00
|
|
|
# Set the farmOS and composer project repository URLs and versions.
|
|
|
|
ARG FARMOS_REPO=https://github.com/farmOS/farmOS.git
|
|
|
|
ARG FARMOS_VERSION=2.x
|
|
|
|
ARG PROJECT_REPO=https://github.com/farmOS/composer-project.git
|
|
|
|
ARG PROJECT_VERSION=2.x
|
|
|
|
|
2021-10-16 17:56:24 +02:00
|
|
|
# Set OPcache's revalidation frequency to 0 seconds for development.
|
|
|
|
# See https://www.php.net/manual/en/opcache.configuration.php#ini.opcache.revalidate-freq
|
|
|
|
RUN sed -i 's|opcache.revalidate_freq=60|opcache.revalidate_freq=0|g' /usr/local/etc/php/conf.d/opcache-recommended.ini
|
|
|
|
|
|
|
|
# Install and configure XDebug.
|
|
|
|
RUN yes | pecl install xdebug \
|
|
|
|
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini
|
|
|
|
|
2020-07-31 16:19:37 +02:00
|
|
|
# Change the user/group IDs of www-data inside the image to match the ID of the
|
|
|
|
# developer's user on the host machine. This allows Composer to create files
|
|
|
|
# owned by www-data inside the container, while keeping those files editable by
|
|
|
|
# the developer outside of the container.
|
|
|
|
# This defaults to 1000, based on the assumption that the developer is running
|
|
|
|
# as UID 1000 on the host machine. It can be overridden at image build time with:
|
|
|
|
# --build-arg WWW_DATA_ID=$(id -u)
|
|
|
|
ARG WWW_DATA_ID=1000
|
2020-08-12 16:36:42 +02:00
|
|
|
RUN usermod -u ${WWW_DATA_ID} www-data && groupmod -g ${WWW_DATA_ID} www-data
|
|
|
|
|
2020-08-12 18:58:48 +02:00
|
|
|
# Create a fresh /var/farmOS directory owned by www-data.
|
2021-08-20 22:55:26 +02:00
|
|
|
# We do this in two steps because of a known issue with Moby.
|
|
|
|
# @see https://github.com/farmOS/farmOS/pull/440
|
|
|
|
RUN rm -r /var/farmOS
|
|
|
|
RUN mkdir /var/farmOS && chown www-data:www-data /var/farmOS
|
2020-08-12 18:58:48 +02:00
|
|
|
|
2020-08-12 18:45:17 +02:00
|
|
|
# Change to the www-data user.
|
|
|
|
USER www-data
|
|
|
|
|
2020-08-12 16:36:42 +02:00
|
|
|
# Build the farmOS codebase in /var/farmOS.
|
2020-08-12 17:17:39 +02:00
|
|
|
RUN /usr/local/bin/build-farmOS.sh
|
2020-04-26 17:40:35 +02:00
|
|
|
|
2020-07-31 14:29:56 +02:00
|
|
|
# Configure PHP CodeSniffer.
|
|
|
|
RUN { \
|
|
|
|
echo '<?xml version="1.0" encoding="UTF-8"?>'; \
|
|
|
|
echo '<ruleset name="farmOS">'; \
|
|
|
|
echo ' <description>PHP CodeSniffer configuration for farmOS development.</description>'; \
|
|
|
|
echo ' <file>.</file>'; \
|
|
|
|
echo ' <arg name="extensions" value="php,module,inc,install,test,profile,theme,css,info,txt,yml"/>'; \
|
|
|
|
echo ' <config name="drupal_core_version" value="9"/>'; \
|
2020-08-19 21:28:19 +02:00
|
|
|
echo ' <rule ref="Drupal">'; \
|
|
|
|
echo ' <exclude name="Drupal.InfoFiles.AutoAddedKeys.Version"/>'; \
|
2020-09-25 14:47:49 +02:00
|
|
|
echo ' <exclude name="Drupal.Arrays.Array.LongLineDeclaration"/>'; \
|
2021-03-11 17:07:50 +01:00
|
|
|
# @todo https://www.drupal.org/project/coder/issues/2159253
|
|
|
|
echo ' <exclude name="Drupal.Commenting.InlineComment.SpacingAfter"/>'; \
|
|
|
|
echo ' </rule>'; \
|
|
|
|
echo ' <rule ref="DrupalPractice">'; \
|
|
|
|
# @todo https://www.drupal.org/project/coder/issues/2159253
|
|
|
|
echo ' <exclude name="DrupalPractice.Commenting.CommentEmptyLine.SpacingAfter"/>'; \
|
2020-08-19 21:28:19 +02:00
|
|
|
echo ' </rule>'; \
|
2020-12-05 12:37:59 +01:00
|
|
|
echo ' <rule ref="Internal.Tokenizer.Exception"><severity>0</severity></rule>'; \
|
2020-07-31 14:29:56 +02:00
|
|
|
echo '</ruleset>'; \
|
|
|
|
} > /var/farmOS/phpcs.xml \
|
|
|
|
&& /var/farmOS/vendor/bin/phpcs --config-set installed_paths /var/farmOS/vendor/drupal/coder/coder_sniffer
|
|
|
|
|
2020-04-28 06:28:22 +02:00
|
|
|
# Configure PHPUnit.
|
2020-08-12 17:17:39 +02:00
|
|
|
RUN cp -p /var/farmOS/web/core/phpunit.xml.dist /var/farmOS/phpunit.xml \
|
|
|
|
&& sed -i 's|bootstrap="tests/bootstrap.php"|bootstrap="web/core/tests/bootstrap.php"|g' /var/farmOS/phpunit.xml \
|
2021-08-17 19:23:03 +02:00
|
|
|
&& sed -i '/failOnWarning="true"/a \ failOnIncomplete="true"' /var/farmOS/phpunit.xml \
|
|
|
|
&& sed -i '/failOnWarning="true"/a \ failOnSkipped="true"' /var/farmOS/phpunit.xml \
|
2021-08-17 00:19:21 +02:00
|
|
|
&& sed -i 's|name="SIMPLETEST_BASE_URL" value=""|name="SIMPLETEST_BASE_URL" value="http://www"|g' /var/farmOS/phpunit.xml \
|
2020-08-12 17:17:39 +02:00
|
|
|
&& sed -i 's|name="SIMPLETEST_DB" value=""|name="SIMPLETEST_DB" value="pgsql://farm:farm@db/farm"|g' /var/farmOS/phpunit.xml \
|
|
|
|
&& sed -i 's|name="BROWSERTEST_OUTPUT_DIRECTORY" value=""|name="BROWSERTEST_OUTPUT_DIRECTORY" value="/var/www/html/sites/simpletest/browser_output"|g' /var/farmOS/phpunit.xml \
|
2021-08-17 00:19:21 +02:00
|
|
|
&& sed -i 's|name="MINK_DRIVER_ARGS_WEBDRIVER" value='\'''\''|name="MINK_DRIVER_ARGS_WEBDRIVER" value='\''["chrome", { "chromeOptions": { "w3c": false, "args": ["--disable-gpu","--headless", "--no-sandbox"] } }, "http://chrome:4444/wd/hub"]'\''|g' /var/farmOS/phpunit.xml \
|
2020-08-12 17:17:39 +02:00
|
|
|
&& sed -i 's|\./|\./web/core/|g' /var/farmOS/phpunit.xml \
|
|
|
|
&& sed -i 's|\.\./web/core/|\./web/|g' /var/farmOS/phpunit.xml \
|
2020-12-03 19:02:00 +01:00
|
|
|
&& sed -i 's| </php>| <env name="SYMFONY_DEPRECATIONS_HELPER" value="quiet[]=indirect"/>'"\n"' </php>|g' /var/farmOS/phpunit.xml \
|
2020-08-12 17:17:39 +02:00
|
|
|
&& mkdir -p /var/farmOS/web/sites/simpletest/browser_output
|
|
|
|
|
2020-08-12 18:45:17 +02:00
|
|
|
# Change back to the root user.
|
|
|
|
USER root
|
|
|
|
|
|
|
|
# Copy the farmOS codebase into /opt/drupal.
|
|
|
|
RUN rm -r /opt/drupal && cp -rp /var/farmOS /opt/drupal
|
2020-08-12 19:31:17 +02:00
|
|
|
|
|
|
|
# Create a Composer config directory for the www-data user.
|
|
|
|
RUN mkdir /var/www/.composer && chown www-data:www-data /var/www/.composer
|