terra-ops / docker-drupal

Dockerfile for enhanced drupal
5 stars 6 forks source link

Setup certain PHP configs to be editable with environment variables #1

Open jonpugh opened 9 years ago

jonpugh commented 9 years ago

I need to up the PHP memory limit. I don't want to hard code it into the container.

Let's figure out how to use an environment variable to set it.

jlyon commented 9 years ago

+1 for this

From http://stackoverflow.com/questions/858431/is-it-possible-to-use-environment-variables-in-php-ini: According to the php manual you can access any env var in the php.ini via ${VARNAME}. – Marcus Pope Mar 17 '14 at 19:09

We'd need to make sure to set the default $PHP_MEMORY_LIMIT. Should this be done in terra-app?

jonpugh commented 9 years ago

Yep, environment vars are set here: https://github.com/terra-ops/terra-app/blob/master/src/terra/Factory/EnvironmentFactory.php#L305

To override for a specific app, we would use the docker-compose: overrides: app: environment: item in .terra.yml...

docker_compose:
  overrides:
    app:
      environment:
        PHP_MEMORY_LIMIT: 256MB

I'll need to test that the overrides behavior merges based on the environment name.

jlyon commented 9 years ago

After rebuilding docker-drupal with

memory_limit=${PHP_MEMORY_LIMIT}

I get a fatal PHP error. It seems like ${PHP_MEMORY_LIMIT} isn't getting set properly.

Allowed memory size of 262144 bytes exhausted (tried to allocate 4480 bytes) in /usr/share/nginx/html/includes/bootstrap.inc on line 201"
jonpugh commented 9 years ago

Did you add to the Docker file?

ENV PHP_MEMORY_LIMIT 128m

That will set the default environment variable. On Aug 5, 2015 8:53 PM, "Jeff Lyon" notifications@github.com wrote:

After rebuilding docker-drupal with

memory_limit=${PHP_MEMORY_LIMIT}

I get a fatal PHP error. It seems like ${PHP_MEMORY_LIMIT} isn't getting set properly.

Allowed memory size of 262144 bytes exhausted (tried to allocate 4480 bytes) in /usr/share/nginx/html/includes/bootstrap.inc on line 201"

— Reply to this email directly or view it on GitHub https://github.com/terra-ops/docker-drupal/issues/1#issuecomment-128197108 .