V8-archive: Add ability to increase Max Size of file uploads without building custom image

Created on 29 Jan 2020  路  7Comments  路  Source: directus/v8-archive

The Max Size of file uploads is set to 2MB by default. This is a PHP setting. To overcome this in the past, we have needed to build custom images and define our own configuration variables.
Talk has been ongoing for at least the past couple of years about how to handle this and similar cases. For instance, https://github.com/directus/docker/pull/30
Obviously, 2MB isn't going to work for many installations, so I would think now that api and app have been integrated and the Docker solution is more mature, we should address this. Not handling this defeats the value of having Docker images available.

docker

Most helpful comment

There is a way to change this on both docker-compose.yml and AWS/ECS without having to recreate the container.

Here is what one should do on docker-compose.yml:

directus:
    image: directus/directus:v8.7.2-apache
    entrypoint:
      - "bash"
      - "-c"
      - "/usr/local/bin/directus-entrypoint pwd;php-ini-add 'post_max_size=32M';php-ini-add 'upload_max_filesize=32M';apache2-foreground"

And here is the equivalent syntax on ECS:

      "entryPoint": [
        "bash",
        "-c",
        "/usr/local/bin/directus-entrypoint pwd;php-ini-add 'post_max_size=32M';php-ini-add 'upload_max_filesize=32M';apache2-foreground"
      ],

All 7 comments

As a workaround, if it's for kubernetes, we use this lifecycle

          lifecycle:
            postStart:
              exec:
                command: ["/bin/sh", "-c", "php-ini-add 'upload_max_filesize=20M' && php-ini-add 'post_max_size=20M'"]

We've been editing the images/apache/Dockerfile

Search for Port

And before that section, we paste in

#

Add max upload file soze

#
RUN php-ini-add "memory_limit=512M" && \
php-ini-add "post_max_size=64M" && \
php-ini-add "upload_max_filesize=64M"

Then just rebuild, tag with ECR value, push to ECR, and redeploy.

I'm going to look into your suggestion. Thanks

Haven't tried that approach but it should work.

btw We use the approach Nacho previously posted. It has worked flawlessly for over a month.

There is a way to change this on both docker-compose.yml and AWS/ECS without having to recreate the container.

Here is what one should do on docker-compose.yml:

directus:
    image: directus/directus:v8.7.2-apache
    entrypoint:
      - "bash"
      - "-c"
      - "/usr/local/bin/directus-entrypoint pwd;php-ini-add 'post_max_size=32M';php-ini-add 'upload_max_filesize=32M';apache2-foreground"

And here is the equivalent syntax on ECS:

      "entryPoint": [
        "bash",
        "-c",
        "/usr/local/bin/directus-entrypoint pwd;php-ini-add 'post_max_size=32M';php-ini-add 'upload_max_filesize=32M';apache2-foreground"
      ],

Marc's answer worked for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cdwmhcc picture cdwmhcc  路  3Comments

magikstm picture magikstm  路  3Comments

vuhrmeister picture vuhrmeister  路  3Comments

benhaynes picture benhaynes  路  4Comments

gitlabisbetterthangithub picture gitlabisbetterthangithub  路  3Comments