Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add phpq (MacFJA/phpqa-extensions) extensions to docker image or bin/suggested-tools.sh #168

Closed
kaystrobach opened this issue May 3, 2019 · 3 comments

Comments

@kaystrobach
Copy link

Using the docker image in Gitlab is a breeze.

Sadly some of the tools are not useable due to the limitations you have in the bin/suggested-tools.sh, I suggest, that you include the plugins in the docker image.

Thank you for taking care.

PS: Otherwise it would be nice to cherry-pick the related analyzers into phpqa itself.

@zdenekdrahos
Copy link
Member

Well, it's not that simple. Even when I add new tools, somebody will need different versions (#159 (comment)), different php versions etc.

I recommend building custom docker image. Take a look at troubleshooting in composer docker image.

@kaystrobach
Copy link
Author

Ok, thank you - closing for now

@zdenekdrahos
Copy link
Member

Custom docker image example

1. Build an image

Add necessary php extensions, composer, phpqa...

FROM php:7.0-cli-alpine
RUN apk update \
    && apk add zlib-dev postgresql-libs postgresql-dev postgresql-client libxml2-dev libxslt-dev \
    && docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
    && docker-php-ext-configure opcache --enable-opcache \
    && docker-php-ext-install pdo pdo_pgsql pgsql zip opcache xml soap mbstring xsl \
    && apk del postgresql-dev
RUN curl -sS https://getcomposer.org/installer | \
    php -- --install-dir=/usr/local/bin/ --filename=composer
RUN composer global require edgedesign/phpqa --update-no-dev \
    && ln -s /root/.composer/vendor/bin/phpqa /usr/local/bin/
CMD sh -c "php -v && php -m | xargs && phpqa tools"

Build an image, test it before pushing to a Container Registry.

# test local image
docker build --file Dockefile --tag registry.gitlab.com/my_project/php7_ci/master:20190507 app/.docker
docker run --rm -it registry.gitlab.com/my_project/php7_ci/master:20190507
docker run --rm -it registry.gitlab.com/my_project/php7_ci/master:20190507 sh

2. Gitlab CI

You can use an image from a private Container Registry.

stages:
  - test

test:
  stage: test
  # it works because of CI_REGISTRY_PASSWORD and CI_REGISTRY_USER, secret variable DOCKER_AUTH_CONFIG is not necessary`
  image: registry.gitlab.com/my_project/php7_ci/master:20190507
  variables:
    BACKEND_QA: "*/backend/var/QA"
    BACKEND_CACHE: $CI_PROJECT_DIR/.composercache
  cache:
    paths:
    - $BACKEND_CACHE
  script:
    - 'export COMPOSER_CACHE_DIR=$BACKEND_CACHE'
    - 'composer install --no-progress --no-suggest'
    - 'phpqa --report --tools phpcs:0,phpunit:0 --buildDir var/QA --analyzedDirs ./ --ignoredDirs var,vendor'
  artifacts:
    when: always
    paths:
    - $BACKEND_QA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants