bolt/project

Use of .env file by docker-compose has side-effect of copying it to the container

Closed this issue · 4 comments

In docker-compose.yml the .env file is used (specified with env_file) to configure a number of settings.

Using .env this way has the 'side effect' of copying .env into the container. (Or at least, that is what I saw in a comment on docker/compose#4140 - and it's the observed behavior by a bolt user on slack)

The effect is that you can edit almost all files when using docker, and the changes will be picked up, but if you edit .env the changes will not be picked up by the container. That is quite confusing.

I don't know if there is a real fix possible for this. A separate env file for docker with a comment explaining it won't be reloaded would be clear, but might mean duplication of config.

@simongroenewolt

The problem with using of the .env file like this is that it serves both for the docker and for the Symfony application as well.

In my pull request #31, I don't do that.

  • 1 / the .env file is dedicated to the Symfony application, the variables for the docker are directly in the docker-compose.yml file
  • 2 / the .env file is imported into the Dockerfile file, then we extract variables of the .env file and delete it. Very good for a production image.
  • 3 / the docker-compose.yml file (for the local environment) adds a volume to the root of the project, so that the .env file can be hot modified.

I invite you to test my PR to see if it solves your problems.

Is this also resolved now that #31 has landed?

@bobdenotter yes this one is resolved. The .env file is no longer used as env_file in docker-compose.yml, so it should not be handled as a special case anymore.

Okido, closing this one, then! :-)