symfony-docker icon indicating copy to clipboard operation
symfony-docker copied to clipboard

docker-compose build fails; secrets missing

Open HansPeterOrding opened this issue 1 year ago • 1 comments

I setup up the default installation and added some secrets with symfonys secrets:set command. When running docker-compose build, it fails on composer install because the secrets are not in the .env. I am definitely missing something, but I couldn't work it out on my own.

This is the output of bin/console secrets:list:

` // Use "%env()%" to reference a secret in a config file.

// To reveal the secrets run php bin/console secrets:list --reveal


Secret Value Local Value


DATABASE_URL ****** ****** MESSENGER_TRANSPORT_DSN ****** SLACK_TOKEN ****** TWINGLE_WEBHOOK_SECRET ****** WEBLING_API_KEY ******


// Local values override secret values. // Use secrets:set --local to define them. `

And this error message is thrown on docker-compose build --pull --no-cache:

` #0 4.331 Executing script cache:clear [KO] #0 4.632 [KO] #0 4.632 Script cache:clear returned with error code 1 #0 4.632 !! #0 4.632 !! In EnvVarProcessor.php line 172: #0 4.632 !! #0 4.632 !! Environment variable not found: "SLACK_TOKEN". #0 4.632 !! #0 4.632 !! #0 4.632 !! #0 4.632 Script @auto-scripts was called via post-install-cmd

failed to solve: executor failed running [/bin/sh -c set -eux; mkdir -p var/cache var/log; composer install --prefer-dist --no-dev --no-progress --no-scripts --no-interaction; composer dump-autoload --classmap-authoritative --no-dev; composer symfony:dump-env prod; composer run-script --no-dev post-install-cmd; chmod +x bin/console; sync]: exit code: 1 `

If I add the missing env vars with defaults to my .env[.local] file, the build runs, but the secrets are no more considered because .env entries override secrets.

Same goes for github action which also fails. I'd appreciate any suggestions what I could be missing!

HansPeterOrding avatar Jul 19 '22 19:07 HansPeterOrding

Try to add env(SLACK_TOKEN): '' in the parameters section on the services.yaml file

maxhelias avatar Jul 20 '22 07:07 maxhelias