Created
May 2, 2018 04:46
-
-
Save GWillmann/cceeeffe3d3e56e971349e324249bb64 to your computer and use it in GitHub Desktop.
Running your php/js tests with docker (for GitLab CI and others)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
image: kinoba/docker-custom-php:latest | |
services: | |
- mysql:5.7 | |
variables: | |
DOCKER_DRIVER: overlay2 | |
APP_ENV: test | |
... | |
before_script: | |
- php --ini | |
- node --version | |
# Install the project's php dependencies | |
- composer install | |
# Install the project's node dependencies | |
- yarn config set cache-folder .yarn | |
- yarn install | |
- yarn run encore dev | |
- php bin/console doctrine:schema:update --force --env=test | |
- php bin/console doctrine:fixtures:load --env=test | |
cache: | |
paths: | |
- vendor/ | |
- node_modules/ | |
- .yarn | |
test:app: | |
script: | |
- phpunit --configuration phpunit.xml.dist | |
test:app_js: | |
script: | |
- Xvfb :10 -ac & | |
- export DISPLAY=:10 | |
- sleep 3 | |
- php bin/console server:start | |
- yarn test | |
- php bin/console server:stop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM php:7.1 | |
RUN apt-get update | |
# Install first dependencies | |
RUN apt-get install zlib1g-dev \ | |
libpng-dev \ | |
libxslt-dev \ | |
git -yq | |
# Here you can install any other extension that you need | |
RUN docker-php-ext-install zip | |
RUN docker-php-ext-configure mysqli | |
RUN docker-php-ext-install pdo_mysql zip xsl gd pcntl | |
# Install nodejs | |
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - \ | |
&& apt-get install nodejs -yq | |
# Install yarn | |
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 \ | |
&& apt-get update \ | |
&& apt-get install yarn -yq | |
# Install puppeteer dependencies and chromium | |
RUN apt-get install chromium \ | |
xvfb \ | |
gconf-service \ | |
libasound2 \ | |
libatk1.0-0 \ | |
libc6 \ | |
libcairo2 \ | |
libcups2\ | |
libdbus-1-3 \ | |
libexpat1 \ | |
libfontconfig1 \ | |
libgcc1 \ | |
libgconf-2-4 \ | |
libgdk-pixbuf2.0-0 \ | |
libglib2.0-0 \ | |
libgtk-3-0 \ | |
libnspr4 \ | |
libpango-1.0-0 \ | |
libpangocairo-1.0-0 \ | |
libstdc++6 \ | |
libx11-6 \ | |
libx11-xcb1 \ | |
libxcb1 \ | |
libxcomposite1 \ | |
libxcursor1 \ | |
libxdamage1 \ | |
libxext6 \ | |
libxfixes3 \ | |
libxi6 \ | |
libxrandr2 \ | |
libxrender1 \ | |
libxss1 \ | |
libxtst6 \ | |
ca-certificates \ | |
fonts-liberation \ | |
libappindicator1 \ | |
libnss3 \ | |
lsb-release \ | |
xdg-utils \ | |
wget -yq | |
RUN curl -fsSL https://getcomposer.org/installer | php \ | |
&& mv composer.phar /usr/local/bin/composer \ | |
&& composer global require phpunit/phpunit ^7.0 --no-progress --no-scripts --no-interaction | |
ENV PATH /root/.composer/vendor/bin:$PATH | |
COPY entrypoint.sh /usr/local/bin/ | |
RUN chmod +x /usr/local/bin/entrypoint.sh | |
ENTRYPOINT ["entrypoint.sh"] | |
CMD ["php", "-a"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment