Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory exhaused error for docker install #957

Open
rkhyd opened this issue Mar 19, 2024 · 7 comments
Open

Memory exhaused error for docker install #957

rkhyd opened this issue Mar 19, 2024 · 7 comments

Comments

@rkhyd
Copy link

rkhyd commented Mar 19, 2024

When i run docker-compose up -d or docker compose -f docker-compose.prod.yml up -d, i get the "Fatal error: Allowed memory size of 1610612736 bytes exhausted" in both cases.

I added - COMPOSER_MEMORY_LIMIT=-1 to the environment of php service, added mem_limit: 5g as well. But the install fails.
here is the output

` => [html-migrations internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 5.24kB 0.0s
=> [html-nginx internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 5.24kB 0.0s
=> [html-node internal] load metadata for docker.io/library/composer:2.4 0.8s
=> [html-migrations internal] load metadata for docker.io/mlocati/php-extension-installer:latest 1.1s
=> [html-migrations internal] load metadata for docker.io/library/node:16-alpine3.15 0.8s
=> [html-php internal] load metadata for docker.io/library/php:8.1-fpm-alpine3.15 0.8s
=> [html-php internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 5.24kB 0.0s
=> [html-node internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 5.24kB 0.0s
=> [html-nginx internal] load metadata for docker.io/library/nginx:1.21-alpine 0.8s
=> [html-nginx internal] load .dockerignore 0.0s
=> => transferring context: 463B 0.0s
=> [html-php internal] load .dockerignore 0.0s
=> => transferring context: 463B 0.0s
=> [html-node internal] load .dockerignore 0.0s
=> => transferring context: 463B 0.0s
=> [html-migrations internal] load .dockerignore 0.0s
=> => transferring context: 463B 0.0s
=> [html-nginx sylius_nginx 1/5] FROM docker.io/library/nginx:1.21-alpine@sha256:a74534e76ee1121d418fa7394ca930eb67440deda413848bc67c68138535b989 0.0s
=> [html-nginx internal] load build context 0.0s
=> => transferring context: 12.27kB 0.0s
=> [html-migrations sylius_node 1/13] FROM docker.io/library/node:16-alpine3.15@sha256:ecf74556cdeee48382e555a377ddb12d36161bd33349dc79290f733f763df711 0.0s
=> [html-migrations composer 1/1] FROM docker.io/library/composer:2.4@sha256:4d13375bfb862c565d269e2d3ad5c2db002d3299d0788770639164452bf84f3a 0.0s
=> [html-migrations php_extension_installer 1/1] FROM docker.io/mlocati/php-extension-installer:latest@sha256:f9b2171089d4d90b48dd8309acb17220d5fadb1fe9e6550b95d92f28ab88fed1 0.0s
=> [html-node base 1/23] FROM docker.io/library/php:8.1-fpm-alpine3.15@sha256:fc434d1e2897c4bbad93714eadd590af0900772b6dd4d3be48486ab8591abc48 0.0s
=> [html-node internal] load build context 0.0s
=> => transferring context: 10.50kB 0.0s
=> [html-php internal] load build context 0.0s
=> => transferring context: 10.69kB 0.0s
=> [html-migrations internal] load build context 0.0s
=> => transferring context: 13.22kB 0.0s
=> CACHED [html-nginx sylius_nginx 2/5] COPY docker/nginx/conf.d/default.conf /etc/nginx/conf.d/ 0.0s
=> CACHED [html-nginx sylius_nginx 3/5] WORKDIR /srv/sylius 0.0s
=> CACHED [html-nginx sylius_node 2/13] WORKDIR /srv/sylius 0.0s
=> CACHED [html-nginx sylius_node 3/13] RUN set -eux; apk add --no-cache --virtual .build-deps g++ gcc make ; 0.0s
=> CACHED [html-nginx sylius_node 4/13] COPY package.json yarn.* ./ 0.0s
=> CACHED [html-nginx sylius_node 5/13] RUN set -eux; yarn install; yarn cache clean 0.0s
=> CACHED [html-nginx base 2/23] RUN apk add --no-cache acl file gettext unzip ; 0.0s
=> CACHED [html-nginx base 3/23] COPY --from=php_extension_installer /usr/bin/install-php-extensions /usr/local/bin/ 0.0s
=> CACHED [html-nginx base 4/23] RUN install-php-extensions apcu exif gd intl pdo_mysql opcache zip 0.0s
=> CACHED [html-nginx base 5/23] COPY --from=composer /usr/bin/composer /usr/bin/composer 0.0s
=> CACHED [html-nginx base 6/23] COPY docker/php/prod/php.ini /usr/local/etc/php/php.ini 0.0s
=> CACHED [html-nginx base 7/23] COPY docker/php/prod/opcache.ini /usr/local/etc/php/conf.d/opcache.ini 0.0s
=> CACHED [html-nginx base 8/23] COPY config/preload.php /srv/sylius/config/preload.php 0.0s
=> CACHED [html-nginx base 9/23] RUN set -eux; composer clear-cache 0.0s
=> CACHED [html-nginx base 10/23] WORKDIR /srv/sylius 0.0s
=> CACHED [html-nginx base 11/23] COPY composer.* symfony.lock ./ 0.0s
=> ERROR [html-nginx base 12/23] RUN set -eux; composer install --prefer-dist --no-autoloader --no-interaction --no-scripts --no-progress --no-dev; composer clear-cache 41.9s

[html-nginx base 12/23] RUN set -eux; composer install --prefer-dist --no-autoloader --no-interaction --no-scripts --no-progress --no-dev; composer clear-cache:
#0 0.220 + composer install --prefer-dist --no-autoloader --no-interaction --no-scripts --no-progress --no-dev
#0 0.390 No composer.lock file present. Updating dependencies to latest instead of installing from lock file. See https://getcomposer.org/install for more information.
#0 0.390 Loading composer repositories with package information
#0 37.75 Updating dependencies
#0 41.41
#0 41.41 Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 67108864 bytes) in phar:///usr/bin/composer/src/Composer/DependencyResolver/Solver.php on line 190
#0 41.44
#0 41.44 Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.

failed to solve: process "/bin/sh -c set -eux; composer install --prefer-dist --no-autoloader --no-interaction --no-scripts --no-progress --no-dev; composer clear-cache" did not complete successfully: exit code: 255
`

Any solution?

@dhenze
Copy link

dhenze commented Mar 22, 2024

@rkhyd I was facing the same issues, tried few different methods to change the composer memory limit as outlined in https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors but to no avail.

I could get it to work by adding these two lines before the composer install command in the Dockerfile:

ENV COMPOSER_MEMORY_LIMIT=-1
RUN composer self-update --2

Credits: Solution from this stackoverflow post.

UPDATE: The correct solution would most likely be to change the COMPOSER_VERSION argument at the beginning of Dockerfile from

ARG COMPOSER_VERSION=2.4
to
ARG COMPOSER_VERSION=2.7.2

and adding the
ENV COMPOSER_MEMORY_LIMIT=-1

Tested both approaches to be working.

But it appears this docker setup is not maintained as all the versions are quite outdated, e.g. alpine version 3.15 where the latest combination of php 8.1 and alpine is [8.1-fpm-alpine3.19](https://hub.docker.com/layers/library/php/8.1-fpm-alpine3.19/images/sha256-0396ed0b83c93a957834197aca8f34a0d6b8ec75f9f7cd6b337cd4ec3541464b?context=explore)

Would be nice to hear about the plans from Sylius for this.

@Prometee
Copy link
Contributor

Hello @dhenze and @rkhyd I re-test the last release of sylius/sylius-standard and the issue is no more here.

You can simply edit the new compose.override.yml file and change the external ports (because for ex, I'm running MySQL database on the 3306 port already and I need to expose it to a another port). Then clean your existing docker compose stack : make clean and finally make init.
During my tests I had only one error about missing git binary missing because composer wants to download a package via it, but retrying the make init fix the issue.

@patbsh
Copy link

patbsh commented Apr 24, 2024

@Prometee this is not true in my case, just tried the latest release of sylius-standard and I still had to turn off the memory limit because it would crash on cache:clear command due to exhausted memory.

@Prometee
Copy link
Contributor

Prometee commented Apr 24, 2024

@patbsh are you sure your fork the last version ?
Can you describe how you changed the memory limit with the new config ?

@patbsh
Copy link

patbsh commented Apr 24, 2024

@Prometee I used composer-create project so to my understanding it used the latest version?

When it crashed due to memory limit I simply went into the newly created directory and re-run composer install with COMPOSER_MEMORY_LIMIT=-1 composer install and this time it went without issues. It could probably also be achieved by adding the same to the Dockerfile directly.

@Prometee
Copy link
Contributor

@patbsh it seems you are using your local PHP binary instead of the docker one doing so.
You do not need to composer create-project sylius/sylius-standard, please follow the dedicated documentation page to install Sylius instead : https://docs.sylius.com/en/1.13/book/installation/installation_with_docker.html

Usually the memory issue is coming from XDebug extension being enabled, what I suspect is that your local PHP install has it, making the memory blowing up.

@patbsh
Copy link

patbsh commented Apr 26, 2024

@Prometee you are right, after cloning the repository directly it runs without any tweaking. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants