mirror of
https://github.com/deployphp/deployer.git
synced 2025-02-24 09:12:51 +01:00
The E2E docker-compose stack has been modified to include code coverage for all scripts that are kept in /project and are not in the exclusion list. The start command for `deployer` container has been replaced with a `start-e2e-test.sh` script, which will execute E2E tests, generate a Clover report and then return the exit code of E2E test process to make sure that CI is aware of the test result. Whole idea for collecting E2E coverage has been inspired by the [this][1] article. All of scripts in `deployer` container will now start with additional wrapper-like PHP code, which checks if the `PHP_CCOV_START_FILE` variable is present. If not, then nothing happens, but if the variable points to a PHP file, then that file is being included. The `docker-compose.yml` file has `PHP_CCOV_START_FILE` configured to point to a file, which sets up code coverage, that starts counting which instructions in `/project` directory have been called. Once `php` interpreter starts shutting down, the coverage report is being dumped into temporary files. Once all tests have been processed, a script for merging partial coverage reports is executed and finally a Clover code coverage file is stored in the path defined in the `PHP_CCOV_OUTPUT_FILE` env var. [1]: https://tarunlalwani.com/post/php-code-coverage-web-selenium/
102 lines
3.0 KiB
Docker
102 lines
3.0 KiB
Docker
FROM php:7.3-cli-alpine AS composer
|
|
RUN apk add wget
|
|
COPY ./scripts/install-composer.sh /tmp/install-composer.sh
|
|
RUN sh /tmp/install-composer.sh
|
|
|
|
|
|
|
|
|
|
|
|
FROM php:7.3-cli-alpine AS deployer
|
|
RUN apk add \
|
|
git \
|
|
openssh-client \
|
|
rsync
|
|
|
|
RUN ssh-keygen \
|
|
-q \
|
|
-b 2048 \
|
|
-t rsa \
|
|
-f ~/.ssh/id_rsa
|
|
|
|
RUN git config --global user.email "e2e@deployer.test" \
|
|
&& git config --global user.name "E2E Deployer"
|
|
|
|
ARG XDEBUG_VERSION=2.9.8
|
|
RUN set -eux; \
|
|
apk add --no-cache --virtual .build-deps $PHPIZE_DEPS; \
|
|
pecl install xdebug-$XDEBUG_VERSION; \
|
|
docker-php-ext-enable xdebug; \
|
|
apk del .build-deps
|
|
|
|
COPY scripts/php-code-coverage/coverage-start-wrapper.php /usr/local/etc/php/php-code-coverage/
|
|
COPY conf/10-coverage.ini /usr/local/etc/php/conf.d/
|
|
|
|
COPY --from=composer /tmp/composer /bin/composer
|
|
VOLUME [ "/project" ]
|
|
WORKDIR /project
|
|
|
|
|
|
|
|
|
|
|
|
FROM php:7.3-apache AS server
|
|
RUN apt-get update && apt-get install -y \
|
|
acl \
|
|
git \
|
|
openssh-server \
|
|
sudo \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# SSH login fix. Otherwise user is kicked off after login
|
|
RUN mkdir /run/sshd \
|
|
&& sed -i 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' /etc/pam.d/sshd
|
|
|
|
# Configure Apache to expose healthcheck & configure site to use /var/www/html/current ad document root
|
|
COPY conf/healthcheck.conf /etc/apache2/sites-available/healthcheck.conf
|
|
COPY ./initial-site /var/www/html/initial-site
|
|
|
|
ENV APACHE_DOCUMENT_ROOT /var/www/html/current/public
|
|
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/000-default.conf \
|
|
&& sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf \
|
|
&& ln -s /var/www/html/initial-site /var/www/html/current \
|
|
&& chown -R www-data:www-data /var/www/html \
|
|
&& echo "Listen 81" >> /etc/apache2/ports.conf \
|
|
&& a2enmod rewrite \
|
|
&& a2ensite healthcheck
|
|
|
|
RUN useradd \
|
|
--create-home \
|
|
deployer \
|
|
&& echo 'deployer:deployer' | chpasswd \
|
|
&& echo 'deployer ALL=(ALL) ALL' >> /etc/sudoers \
|
|
&& mkdir ~deployer/.ssh \
|
|
&& touch ~deployer/.ssh/authorized_keys \
|
|
&& chown -R deployer:deployer ~deployer/.ssh \
|
|
&& chmod 700 ~deployer/.ssh \
|
|
&& chmod 600 ~deployer/.ssh/authorized_keys
|
|
|
|
RUN useradd \
|
|
--create-home \
|
|
git \
|
|
&& mkdir ~git/.ssh \
|
|
&& touch ~git/.ssh/authorized_keys \
|
|
&& chown -R git:git ~git/.ssh \
|
|
&& chmod 700 ~git/.ssh \
|
|
&& chmod 700 ~git/.ssh/authorized_keys \
|
|
&& mkdir ~git/repository \
|
|
&& git init --bare ~git/repository \
|
|
&& chown -R git:git ~git/repository
|
|
|
|
COPY scripts/start-servers.sh /usr/local/bin/start-servers
|
|
COPY --from=composer /tmp/composer /usr/local/bin/composer
|
|
COPY --from=deployer /root/.ssh/id_rsa.pub /tmp/root_rsa.pub
|
|
|
|
RUN chmod a+x /usr/local/bin/start-servers \
|
|
&& cat /tmp/root_rsa.pub >> ~deployer/.ssh/authorized_keys \
|
|
&& cat /tmp/root_rsa.pub >> ~git/.ssh/authorized_keys \
|
|
&& rm -rf /tmp/root_rsa.pub
|
|
|
|
EXPOSE 22 80 81
|
|
CMD [ "start-servers" ]
|