docker-library/drupal

How can I manage composer files?

emircanerkul opened this issue · 1 comments

How can I manage composer.json and composer.lock files that hosting under /opt/drupal that I can't use volume mount these files without creating exact one in host machine (or at least I don't know).

Logic: copy composer.(json|lock) from container /opt/drupal/composer.(json|lock) if not in the host machine.

After that volume binding will work.

drupal:
  image: drupal:9.4
  volumes:
    - ../src/composer.json:/opt/drupal/composer.json
    - ../src/composer.lock:/opt/drupal/composer.lock 

WHY: To be able to easily organize files with git. Not only

  - ../src/modules:/var/www/html/modules
  - ../src/profiles:/var/www/html/profiles
  - ../src/themes:/var/www/html/themes
  - ../src/sites:/var/www/html/sites

are important. Also, composer files are needed.

You don't manage them at you host, you manage them in your repo.

Composer files are a part of what defines your app. Your app is built into an image using a Dockerfile. The image is used by docker to create containers that are hosted. Containers should define volumes for paths in your app that contains persistent data, ie web/sites/default/files (drupal standard).

drupal:
  image: my-drupal-site:9.4
  volumes:
      - site_data:/opt/drupal/web/sites/default/files