-1

With a symfony 5 project / PHP7.4 / Docker, i have a deployment problem.

My dockerFile works fine in jenkins (in qualif environment and production environment) but when running in gitlab pipelines, it fails after "composer install" because of the cache:clear automaticaly launched (defined in the composer.json "auto-scripts" section)

my dockerfile is separated in 3 sections (composer dependencies / yarn dependencies / packaging)

extract of my dockerfile (section "composer dependencies") :

COPY --chown=www-data:www-data src/composer.* /temp/
COPY --chown=www-data:www-data src/src/ /temp/src/

ARG ENV=dev
ENV ENV=$ENV
# dump-autoload not working without src directory : https://stackoverflow.com/a/54337514/3825416
RUN if [ "$ENV" = "prod" ] ; then composer install --no-dev --no-interaction;composer dump-autoload --no-dev --classmap-authoritative; else composer install --no-interaction; fi

And the build error log :

#30 15.26 Script cache:clear returned with error code 1
#30 15.26 !!  
#30 15.26 !!  In DefinitionErrorExceptionPass.php line 54:
#30 15.26 !!                                                                                 
#30 15.26 !!    Cannot autowire service "App\Controller\CustomController": argument "$seri  
#30 15.26 !!    alizer" of method "__construct()" references interface "JMS\Serializer\Seri  
#30 15.26 !!    alizerInterface" but no such service exists. Did you create a class that im  
#30 15.26 !!    plements this interface?                                                     
#30 15.26 !!                                                                                 
#30 15.26 !!  
#30 15.26 !!  
#30 15.26 Script @auto-scripts was called via post-install-cmd

if i remove the src folder copy, pipelines are ok but the composer dump-autoload fails in production because of this problem : https://stackoverflow.com/a/54337514/3825416

Do you see something i am doing wrong ?

thanks

pop_up
  • 1,451
  • 2
  • 18
  • 35
  • Have you checked **why** that happens? Probably, that given `SerializerInterface` is not installed when using `--no-dev`? – Nico Haase Jun 08 '20 at 13:11
  • jms/serializer-bundle is in the "require" section of the composer.json file. When i deploy in production with `composer install --no-dev --no-interaction`, it works well. The problem is only with gitlab and the build in gitlab is done with the "qualif" environment so it does a composer install, including dev dependencies – pop_up Jun 08 '20 at 14:04
  • What happens if you try to run `composer install` using this "qualif enviroment" on your local machine? You could inspect all moving parts this way. Maybe it would help to share that configuration here, such that others can reproduce your problem? – Nico Haase Jun 08 '20 at 14:12
  • composer install works fine in local / jira. i can't share all my project, and i don't think the problem is linked to the composer.json or to the dockerfile because it deploys correctly in jira. I must have missed something specific with gitlab and pipelines and runners. I just don't understand why cache:clear works on pipeline if i remove the copy of the src folder and why not if i do this copy – pop_up Jun 08 '20 at 14:32

1 Answers1

0

i solved the problem by copying all the src folder.

COPY --chown=www-data:www-data src/ /temp/

Doing that, the pipelines are now successful.

pop_up
  • 1,451
  • 2
  • 18
  • 35