fballiano / docker-magento2

Cluster ready Magento2 + Varnish 7 + PHP 8.1 + Redis 6.2 + Elasticsearch 7.17 + SSL
355 stars 164 forks source link

Is the mount for `.composer/auth.json` wrong? #18

Closed bennythejudge closed 5 years ago

bennythejudge commented 6 years ago

In this line in the docker-compose.yml file,

should:

     - ~/.composer/auth.json:/root/.composer/auth.json

be

     - ~/.composer:/root/.composer

and ~/.composer on the host contain a auth.json file (content according to this page?

bennythejudge commented 6 years ago

When I tried my theory, the apache container would not start. Could you please explain this? This is clearly not an issue other than my lack of understanding/knowledge.

nutellinoit commented 6 years ago

If you run composer as www-data user inside apache container, you need to link your auth file on your host to the www-data home folder

./yourhostauthjson.json:/var/www/.composer/auth.json
LiamKarlMitchell commented 6 years ago

It kept having errors so I just commented out the file from the docker composer config.

ERROR: for apache  Cannot start service apache: error while creating mount source path '/host_mnt/c/Users/megab/.composer/auth.json': mkdir /host_mnt/c/Users/megab/.composer: permission denied
ERROR: Encountered errors while bringing up the project.

The permission denied thing, I needed to goto advanced security on the folder I was trying to use as a volume and give the docker-user group write access. (Windows Docker).

But then I still needed a login to run composer update in the end I changed it to use ./ rather than ~/ and made an auth.json with the login for my Magento2 keys. Phew~

Generate key here: https://marketplace.magento.com/customer/accessKeys/

{                                                              
    "http-basic": {                                            
        "repo.magento.com": {                                  
            "username": "Your Public Key",    
            "password": "Your Private Key"     
        }                                                      
    }                                                          
}                                                              

Guide: https://devdocs.magento.com/guides/v2.2/install-gde/prereq/connect-auth.html

fballiano commented 5 years ago

Hello everybody, the mount can be configured in many different ways (or removed completely), it really depends on how you want to use it.

I wanted to mount only the auth.json but you could mount the whole .composer directory, for the root user or the www-data user, it really depends on how you want to use it.