ezsystems / launchpad

CLI tool to bootstrap an eZ Platform project Docker stack | #justcode
https://ezsystems.github.io/launchpad
MIT License
22 stars 26 forks source link

Docker Compose v2 - read /dev/stderr: bad file descriptor triggered by proc_open #107

Open Plopix opened 2 years ago

Plopix commented 2 years ago
Q A
Bug report? yes
Feature request? no
BC Break report? no
Environment Mac

Coming from this issue: https://github.com/ezsystems/launchpad/issues/103

I also have read /dev/stderr: bad file descriptor with docker compose v2.

I have debugged and that is coming from proc_open.

I don't really understand how to fix this though. The problem is that somehow docker compose v2 detaches a thread/process or something and _procopen loses track of it.

It works like before for stop, start, etc. but for exec (used by ez enter) somehow something runs in the background, and Symfony Process triggers an exception.

read /dev/stderr: bad file descriptor is displayed by the proc_open

I did a reproducer, when you have a working project with eZ Launchpad

mkdir /tmp/testprocess
cd /tmp/testprocess
composer require symfony/process

Then use/adap this code:

<?PHP
// test.php

include "vendor/autoload.php";

use Symfony\Component\Process\Process;

$command = "<RUN `ez ps c` and copy/paste the string here> exec engine /bin/bash";

$process = Process::fromShellCommandline($command);
$process->setTimeout(2 * 3600);
$process->setTty(true);
$process->mustRun();

Example of $command

PROJECTNETWORKNAME=test PROJECTPORTPREFIX=42 PROJECTCOMPOSEPATH=/System/Volumes/Data/Users/plopix/Projects/Test PROVISIONINGFOLDERNAME=provisioning HOST_COMPOSER_CACHE_DIR=/System/Volumes/Data/Users/plopix/Projects/.composer_cache DEV_UID=501 DEV_GID=33 COMPOSER_CACHE_DIR=/var/www/composer_cache PROJECTMAPPINGFOLDER=/var/www/html/project BLACKFIRE_CLIENT_ID= BLACKFIRE_CLIENT_TOKEN= BLACKFIRE_SERVER_ID= BLACKFIRE_SERVER_TOKEN= DOCKER_HOST= DOCKER_CERT_PATH= DOCKER_TLS_VERIFY= PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin XDEBUG_ENABLED=0 docker-compose -p test -f /Users/plopix/Projects/Test/provisioning/dev/docker-compose.yml -f /Users/plopix/Projects/Test/provisioning/dev/docker-compose-osx.yml exec engine /bin/bash

This is ez ps c + exec engine /bin/bash

Run php test.php and see that is working => you get access to the container Change the Docker Compose version to version 2 => see the error.

Any ideas are welcome! ping @YohannsMonnier @bdunogier @lserwatka @SylvainGuittard @florianalexandre @amine-betari @yhanini @anaelChardan @kmadejski @hubformation @sklimaszewski

There is probably a simple trick, and experts of proc_open (and related) might see the problem easily here.

CodeCasterNL commented 2 years ago

Related: https://github.com/docker/compose/issues/9115

Plopix commented 2 years ago

hey, @CodeCasterNL that's exactly it.

@nicolasgreckas, I am pinging you here. You might have a solution for us to somehow change the Descriptors with Symfony? (Thanks :))

Webarkitekt commented 2 years ago

Hello, any news about the possibility to use Virtiofs and Docker compose v2 with launchpad ? I have serious latency with react components on the backend.

Thanks