R
R
Ruslan2018-07-06 13:45:15
Continuous Integration
Ruslan, 2018-07-06 13:45:15

How is .gitlab-ci.yml properly configured for a docker project?

crashes on code-review

$ docker exec -t $(docker-compose ps -q php) ./vendor/bin/phpcs --extensions=php --standard=PSR2 ./
Error: No such container: ./vendor/bin/phpcs

But maybe I misunderstood something, because of this I set it up incorrectly.
It is necessary that the ./vendor/bin/phpcs --extensions=php --standard=PSR2 ./ command be executed in the php container to check the code according to the standard.
.gitlab-ci.yml
image: docker:latest

services:
  - docker:dind

before_script:
  - apk add --no-cache python py2-pip
  - pip install --no-cache-dir docker-compose==1.16.0
  - cp env_dist .env
  - chmod -R 777 docker/nginx/run_nginx.sh
  - export APP_ENV=testing

stages:
    - prepare
    - testing
#    - build
#    - deploy
variables:
    COMPOSER_CACHE_DIR: "/cache/composer"
    DOCKER_DRIVER: overlay

installing-dependencies:
    stage: prepare
    tags:
      - docker
    script:
        - docker info
        - docker-compose up -d
        - sleep 15
        - docker exec -t $(docker-compose ps -q php) composer install --prefer-dist --optimize-autoloader -n --no-interaction -v --no-suggest
        - docker exec -t $(docker-compose ps -q php) composer dump-autoload --optimize
    artifacts:
        name: "vendor"
        untracked: true
        expire_in: 60 mins
        paths:
            - $CI_PROJECT_DIR/vendor

code-review:
    stage: testing
    dependencies:
        - installing-dependencies
    script:
         - docker exec -t $(docker-compose ps -q php) ./vendor/bin/phpcs --extensions=php --standard=PSR2 ./

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
chupasaurus, 2018-07-06
@chupasaurus

docker-compose exec php ./vendor/bin/phpcs --extensions=php --standard=PSR2 ./

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question