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

docker compose yml and flightphp website ? #87

Open
abda11ah opened this issue Dec 7, 2024 · 4 comments
Open

docker compose yml and flightphp website ? #87

abda11ah opened this issue Dec 7, 2024 · 4 comments

Comments

@abda11ah
Copy link

abda11ah commented Dec 7, 2024

Hi,

I would like to host a flightphp website on workerman using docker but http://localhost is loading in an infinite loop and i got a blank page.

I don't know if i'm using the right docker image .....

Here is my docker-compose file :

version: "3.8"
services:
  php-cli:
    build:
      dockerfile_inline: >
        FROM amd64/php:8.2-cli

        # Install required PHP extensions

        RUN apt-get update && apt-get install -y \
            libpng-dev \
            libjpeg-dev \
            libfreetype6-dev \
            && docker-php-ext-configure gd --with-freetype --with-jpeg \
            && docker-php-ext-install gd pdo pdo_mysql posix

        # Install Xdebug

        RUN pecl install xdebug \
            && docker-php-ext-enable xdebug

        COPY --from=ghcr.io/mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/

         RUN install-php-extensions pcntl
    container_name: php-cli-container
    volumes:
      - /home/client/worker:/usr/src/myapp # Mount the current directory to /usr/src/myapp
      - /home/client/worker/php-ini:/usr/local/etc/php/conf.d # Mount custom ini directory
    working_dir: /usr/src/myapp # Set the working directory inside the container
    ports:
      - 8080:8080 # Expose port 8080 on the host
    command: php server.php start # Command to run your PHP script
    environment:
      PHP_INI_DIR: /usr/local/etc/php # Set the PHP INI directory
      PHP_INI_SCAN_DIR: /usr/local/etc/php/conf.d # Add custom ini directory
networks:
  default:
    {}
    # Default network configuration (optional)

@abda11ah
Copy link
Author

abda11ah commented Dec 7, 2024

I tried to launch a phpinfo file, it worked but i got phpinfo as text instead of HTML

@joanhey
Copy link
Owner

joanhey commented Dec 7, 2024

With any CLI server, the phpinfo will be always with text (almost for now, till php-src acept our requests).

@joanhey
Copy link
Owner

joanhey commented Dec 16, 2024

Remember than first you need to modify the index.php and start.php as any framework is different.
We have a list of recipes for frameworks in https://github.com/joanhey/AdapterMan/tree/master/recipes

I tried it with flightphp (as it's in the thechempower benchmark) but it isn't working for now. Also happens with others frameworks as Codeigniter, Fatfree,...

But the problem it is NOT with Adapterman, it's a problem in the frameworks than only test it in shared nothing mode.
For example with Flightphp and Codeigniter it's working, but always show the same route, possibly because they are using a singleton or a static property for the routes.

We need to send issues to the frameworks to fix it, as this problem it isn't only with Adapterman. It'll have it also with Swoole, php-runtime, ...

But the easier way to test it, it's with Adapterman as they don't need to change the code, they only need to fix the problems that occur when bootstraping the app only 1 time (persistent apps).

Also Laravel need to change it to work with Octane, and still a lot of apps and libs in Laravel are not ready.
Recommendations for Octane:
https://laravel.com/docs/11.x/octane#dependency-injection-and-octane

But also any global variable or static property used in the core, sometimes need to change with any request.

@joanhey
Copy link
Owner

joanhey commented Dec 16, 2024

My tests in the Techempower benchmark with FlightPHP:

flight-workerman: Adapterman v0.6.1 OK
flight-workerman: Workerman[server.php] start in DEBUG mode
flight-workerman: ------------------------------------------- WORKERMAN --------------------------------------------
flight-workerman: Workerman version:4.2.1          PHP version:8.3.14           Event-Loop:\Workerman\Events\Event
flight-workerman: -------------------------------------------- WORKERS ---------------------------------------------
flight-workerman: proto   user            worker               listen                 processes    status           
flight-workerman: tcp     root            AdapterMan-Flight    http://0.0.0.0:8080    32            [OK]            
flight-workerman: --------------------------------------------------------------------------------------------------
flight-workerman: Press Ctrl+C to stop. Start success.
flight-workerman: Verifying framework URLs
--------------------------------------------------------------------------------
VERIFYING DB                                                                                                                                                   
--------------------------------------------------------------------------------
Accessing URL http://tfb-server:8080/db:                                                                                                                       
Accessing URL http://tfb-server:8080/db: 
--------------------------------------------------------------------------------
VERIFYING QUERY COUNT FOR http://tfb-server:8080/db                                                                                                            
--------------------------------------------------------------------------------
New configuration template added to /home/ubuntu/.siege                                                                                                        
Run siege -C to view the current settings in that file
** SIEGE 4.0.7
** Preparing 512 concurrent users for battle.
The server is now under siege...
Transactions:                    512 hits
Availability:                 100.00 %
Elapsed time:                   0.24 secs
Data transferred:               0.00 MB
Response time:                  0.15 secs
Transaction rate:            2133.33 trans/sec
Throughput:                     0.00 MB/sec
Concurrency:                  317.13
Successful transactions:         512
Failed transactions:               0
Longest transaction:            0.22
Shortest transaction:           0.02
 

   PASS for http://tfb-server:8080/db
     Executed queries: 520/512
   PASS for http://tfb-server:8080/db
     Rows read: 511/512
--------------------------------------------------------------------------------
VERIFYING JSON                                                                                                                                                 
--------------------------------------------------------------------------------
Accessing URL http://tfb-server:8080/json:                                                                                                                     
   FAIL for http://tfb-server:8080/json
     Empty response
     See https://github.com/TechEmpower/FrameworkBenchmarks/wiki/Project-Information-Framework-Tests-Overview#specific-test-requirements
{'Content-Type': 'text/html;charset=utf-8', 'Server': 'workerman', 'Date': 'Mon, 16 Dec 2024 11:54:50 GMT', 'Content-Length': '0'}
...

Only work the first URL, after only send and empty response.

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

2 participants