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