Search code examples
drupalcontainersamazon-ecsbitnamiaws-fargate

How to set private file directory of Drupal by Bitnami on AWS ECS Fargate?


Drupal 9 requires that the private file directory be set by editing the Drupal settings.php file. However, when I deploy the Drupal by Bitnami container (https://hub.docker.com/r/bitnami/drupal/) on AWS ECS Fargate, I am unable to SSH in to the machine and update the settings.php file.

I'm aware that one solution may be to configure ECS Exec (https://aws.amazon.com/blogs/containers/new-using-amazon-ecs-exec-access-your-containers-fargate-ec2/) so that I can tunnel into the container and edit the settings.php file. I'm wondering if that's the ideal solution, or if there is some way to use Docker/ECS commands to potentially:

  1. Copy a custom settings.php file from an outside source (local, or S3) or
  2. Append text to the settings.php file this container creates after site installation or
  3. Something I'm not considering

The ultimate goal would be to set a private file directory which I can mount to an EFS system to. So, if there's an EFS related shortcut I'm missing here, that could also prove useful.

I tried looking through the Drupal by Bitnami documentation to see if there was an environment variable or parameter I could set for the private file directory, but I did not see anything.

Thanks in advance, Jordan


Solution

  • Trying to modify the settings after the container is running is the wrong way to do something like this. That method doesn't scale, and doesn't work in any sort of automated/fault-tolerant/highly-available environment. You shouldn't think of a running docker container as a server that you can then modify after the fact.

    If you absolutely want to change the volume path in settings.php then you probably need to create custom docker image, using this Bitnami image as the base, and as part of the Dockerfile for that custom docker image you would either copy a new settings.php file in, or modify the existing file.

    However, I'm confused why you need to edit settings.php to change the path. The documentation for the image you are using clearly states that you need to create a persistent volume that is mapped to the /bitnami/drupal path. There's no need to change that to anything else, just configure your ECS Fargate task definition to map an EFS volume into the container at /bitnami/drupal.