swoole / library

📚 Swoole Library
https://wiki.swoole.com/#/library
Apache License 2.0
237 stars 58 forks source link

Docker image does not build #28

Closed stefanos82 closed 4 years ago

stefanos82 commented 4 years ago

I have tried to test the library and go the following output (I will beautify it a bit for readability purposes):

$ docker-compose up
Building app
Step 1/2 : FROM phpswoole/swoole
 ---> 5435a480e26f
Step 2/2 : RUN     
pecl update-channels        
&&     pecl install redis-5.2.1    
&&     docker-php-ext-enable redis 
&&     docker-php-ext-install mysqli pdo_mysql 
&&     echo "swoole.enable_library=off" >> /usr/local/etc/php/conf.d/docker-php-ext-swoole.ini 
&&     {         
echo '[supervisord]';         
echo 'user = root';         echo '';         
echo '[program:wordpress]';         
echo 'command = php /var/www/examples/fastcgi/proxy/wordpress.php';         
echo 'user = root';         
echo 'autostart = true';         
echo 'stdout_logfile=/proc/self/fd/1';         
echo 'stdout_logfile_maxbytes=0';         
echo 'stderr_logfile=/proc/self/fd/1';         
echo 'stderr_logfile_maxbytes=0';     } > /etc/supervisor/service.d/wordpress.conf
 ---> Running in 720d70847ea1
ERROR: Service 'app' failed to build: no status provided on response: unknown

Is this behavior normal?

deminy commented 4 years ago

I ran following commands and tried some examples; everything looked good.

docker-compose build --no-cache
docker-compose up --force-recreate
stefanos82 commented 4 years ago

Hey @deminy thank you for your feedback.

I ran following commands and tried some examples; everything looked good.


docker-compose build --no-cache

This command worked just fine

docker-compose up --force-recreate


This one though caused some issues with port binding:
docker-compose up --force-recreate
Recreating swoole-library_php-fpm_1 ... done
Recreating swoole-library_redis_1   ... done
Recreating swoole-library_mysql_1   ... done
Recreating swoole-library_wordpress_1 ... done
Recreating swoole-library_app_1       ... error

ERROR: for swoole-library_app_1  
Cannot start service app: driver failed programming external connectivity on 
endpoint swoole-library_app_1 
(0ca9b3de3c9b7b15ff0296ef0d1dbb4fef818ada60b1deb4a6e9740ad6201efc): 
Error starting userland proxy: listen tcp 0.0.0.0:80: 
bind: address already in use

ERROR: for app  Cannot start service app: driver failed programming 
external connectivity on endpoint swoole-library_app_1 
(0ca9b3de3c9b7b15ff0296ef0d1dbb4fef818ada60b1deb4a6e9740ad6201efc): 
Error starting userland proxy: listen tcp 0.0.0.0:80: bind: address already in use
ERROR: Encountered errors while bringing up the project.
stefanos82 commented 4 years ago

OK, I changed my docker's port to 8080, but now an interesting issue takes place with a PHP file.

docker-compose up --force-recreate
Removing swoole-library_app_1
Recreating swoole-library_redis_1   ... done
Recreating swoole-library_php-fpm_1 ... done
Recreating swoole-library_mysql_1   ... done
Recreating swoole-library_wordpress_1 ... done
Recreating a50551073635_swoole-library_app_1 ... done
Attaching to swoole-library_redis_1, swoole-library_php-fpm_1, swoole-library_mysql_1, swoole-library_wordpress_1, swoole-library_app_1
redis_1      | 1:C 27 Apr 2020 09:32:19.081 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis_1      | 1:C 27 Apr 2020 09:32:19.081 # Redis version=5.0.9, bits=64, commit=00000000, modified=0, pid=1, just started
redis_1      | 1:C 27 Apr 2020 09:32:19.081 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
php-fpm_1    | [27-Apr-2020 09:32:19] NOTICE: fpm is running, pid 1
php-fpm_1    | [27-Apr-2020 09:32:19] NOTICE: ready to handle connections
wordpress_1  | [27-Apr-2020 09:32:21] NOTICE: fpm is running, pid 1
redis_1      | 1:M 27 Apr 2020 09:32:19.082 * Running mode=standalone, port=6379.
app_1        | INFO: Supervisord configuration files copied from folder '/etc/supervisor/service.d/'.
redis_1      | 1:M 27 Apr 2020 09:32:19.082 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
redis_1      | 1:M 27 Apr 2020 09:32:19.082 # Server initialized
mysql_1      | 2020-04-27 09:32:20+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.29-1debian10 started.
wordpress_1  | [27-Apr-2020 09:32:21] NOTICE: ready to handle connections
redis_1      | 1:M 27 Apr 2020 09:32:19.082 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
mysql_1      | 2020-04-27 09:32:20+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
redis_1      | 1:M 27 Apr 2020 09:32:19.082 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
mysql_1      | 2020-04-27 09:32:20+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.29-1debian10 started.
mysql_1      | 2020-04-27T09:32:20.316491Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
mysql_1      | 2020-04-27T09:32:20.317569Z 0 [Note] mysqld (mysqld 5.7.29) starting as process 1 ...
redis_1      | 1:M 27 Apr 2020 09:32:19.082 * DB loaded from disk: 0.000 seconds
redis_1      | 1:M 27 Apr 2020 09:32:19.082 * Ready to accept connections
mysql_1      | 2020-04-27T09:32:20.319733Z 0 [Note] InnoDB: PUNCH HOLE support available
mysql_1      | 2020-04-27T09:32:20.319745Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
mysql_1      | 2020-04-27T09:32:20.319748Z 0 [Note] InnoDB: Uses event mutexes
mysql_1      | 2020-04-27T09:32:20.319750Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
mysql_1      | 2020-04-27T09:32:20.319752Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
mysql_1      | 2020-04-27T09:32:20.319754Z 0 [Note] InnoDB: Using Linux native AIO
mysql_1      | 2020-04-27T09:32:20.319973Z 0 [Note] InnoDB: Number of pools: 1
mysql_1      | 2020-04-27T09:32:20.320096Z 0 [Note] InnoDB: Using CPU crc32 instructions
mysql_1      | 2020-04-27T09:32:20.321280Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
mysql_1      | 2020-04-27T09:32:20.326504Z 0 [Note] InnoDB: Completed initialization of buffer pool
mysql_1      | 2020-04-27T09:32:20.328532Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
mysql_1      | 2020-04-27T09:32:20.340196Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
mysql_1      | 2020-04-27T09:32:20.353775Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
mysql_1      | 2020-04-27T09:32:20.354862Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
mysql_1      | 2020-04-27T09:32:20.412177Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
mysql_1      | 2020-04-27T09:32:20.413073Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
mysql_1      | 2020-04-27T09:32:20.413091Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
mysql_1      | 2020-04-27T09:32:20.413941Z 0 [Note] InnoDB: 5.7.29 started; log sequence number 12481229
mysql_1      | 2020-04-27T09:32:20.414406Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
mysql_1      | 2020-04-27T09:32:20.414682Z 0 [Note] Plugin 'FEDERATED' is disabled.
mysql_1      | 2020-04-27T09:32:20.416899Z 0 [Note] InnoDB: Buffer pool(s) load completed at 200427  9:32:20
mysql_1      | 2020-04-27T09:32:20.422623Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
mysql_1      | 2020-04-27T09:32:20.422652Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
mysql_1      | 2020-04-27T09:32:20.423407Z 0 [Warning] CA certificate ca.pem is self signed.
mysql_1      | 2020-04-27T09:32:20.423451Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
mysql_1      | 2020-04-27T09:32:20.424177Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
mysql_1      | 2020-04-27T09:32:20.424241Z 0 [Note] IPv6 is available.
mysql_1      | 2020-04-27T09:32:20.424251Z 0 [Note]   - '::' resolves to '::';
mysql_1      | 2020-04-27T09:32:20.424264Z 0 [Note] Server socket created on IP: '::'.
mysql_1      | 2020-04-27T09:32:20.430538Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
mysql_1      | 2020-04-27T09:32:20.437362Z 0 [Note] Event Scheduler: Loaded 0 events
mysql_1      | 2020-04-27T09:32:20.437592Z 0 [Note] mysqld: ready for connections.
mysql_1      | Version: '5.7.29'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server (GPL)
app_1        | 2020-04-27 09:32:21,939 INFO Included extra file "/etc/supervisor/conf.d/wordpress.conf" during parsing
app_1        | 2020-04-27 09:32:21,939 INFO Set uid to user 0 succeeded
app_1        | 2020-04-27 09:32:21,950 INFO RPC interface 'supervisor' initialized
app_1        | 2020-04-27 09:32:21,950 CRIT Server 'unix_http_server' running without any HTTP authentication checking
app_1        | 2020-04-27 09:32:21,950 INFO supervisord started with pid 20
app_1        | 2020-04-27 09:32:22,953 INFO spawned: 'wordpress' with pid 23
app_1        | 
app_1        | Warning: require(/var/www/examples/../vendor/autoload.php): failed to open stream: No such file or directory in /var/www/examples/bootstrap.php on line 20
app_1        | 
app_1        | Fatal error: require(): Failed opening required '/var/www/examples/../vendor/autoload.php' (include_path='.:/usr/local/lib/php') in /var/www/examples/bootstrap.php on line 20
app_1        | 2020-04-27 09:32:22,995 INFO exited: wordpress (exit status 255; not expected)
app_1        | 2020-04-27 09:32:23,998 INFO spawned: 'wordpress' with pid 24
app_1        | 
app_1        | Warning: require(/var/www/examples/../vendor/autoload.php): failed to open stream: No such file or directory in /var/www/examples/bootstrap.php on line 20
app_1        | 
app_1        | Fatal error: require(): Failed opening required '/var/www/examples/../vendor/autoload.php' (include_path='.:/usr/local/lib/php') in /var/www/examples/bootstrap.php on line 20
app_1        | 2020-04-27 09:32:24,037 INFO exited: wordpress (exit status 255; not expected)
app_1        | 2020-04-27 09:32:26,042 INFO spawned: 'wordpress' with pid 25
app_1        | 
app_1        | Warning: require(/var/www/examples/../vendor/autoload.php): failed to open stream: No such file or directory in /var/www/examples/bootstrap.php on line 20
app_1        | 
app_1        | Fatal error: require(): Failed opening required '/var/www/examples/../vendor/autoload.php' (include_path='.:/usr/local/lib/php') in /var/www/examples/bootstrap.php on line 20
app_1        | 2020-04-27 09:32:26,094 INFO exited: wordpress (exit status 255; not expected)
app_1        | 2020-04-27 09:32:29,100 INFO spawned: 'wordpress' with pid 26
app_1        | 
app_1        | Warning: require(/var/www/examples/../vendor/autoload.php): failed to open stream: No such file or directory in /var/www/examples/bootstrap.php on line 20
app_1        | 
app_1        | Fatal error: require(): Failed opening required '/var/www/examples/../vendor/autoload.php' (include_path='.:/usr/local/lib/php') in /var/www/examples/bootstrap.php on line 20
app_1        | 2020-04-27 09:32:29,135 INFO exited: wordpress (exit status 255; not expected)
app_1        | 2020-04-27 09:32:30,136 INFO gave up: wordpress entered FATAL state, too many start retries too quickly
^CGracefully stopping... (press Ctrl+C again to force)
Stopping swoole-library_app_1                ... done
Stopping swoole-library_wordpress_1          ... done
Stopping swoole-library_mysql_1              ... done
Stopping swoole-library_php-fpm_1            ... done
Stopping swoole-library_redis_1              ... done
stefanos82 commented 4 years ago

I ran following commands and tried some examples; everything looked good.

docker-compose build --no-cache
docker-compose up --force-recreate

@deminy how do we tell docker to run composer during docker-compose up?

Seems like vendor/autoload.php cannot be found, because indeed composer was not run during the building procedure.

deminy commented 4 years ago

It seems that you didn't follow instructions on the README page to have Composer packages installed. So far I don't see any issues with the library itself; I'm closing the issue.

The Issues section is mainly to submit bugs, but not to provide technical supports. If you need helps from the community, please consider to join the Swoole Slack channel. Thanks

stefanos82 commented 4 years ago

It seems that you didn't follow instructions on the README page to have Composer packages installed. So far I don't see any issues with the library itself; I'm closing the issue.

Allow me to disagree. The very first thing I did was to read the README which happens to be the default thing you read as soon as you open https://github.com/swoole/library/

All I did was to read the following and produced the errors immediately:

image

The Issues section is mainly to submit bugs, but not to provide technical supports. If you need helps from the community, please consider to join the Swoole Slack channel. Thanks

deminy commented 4 years ago

@stefanos82 You are right; I'm sorry.

I'm making adjustment to setup local environments. Before it's ready, please run following command first before starting Docker containers with docker-compose up:

docker run --rm -v "$(pwd)":/var/www -t phpswoole/swoole composer update -n

Thanks for reporting the issue!

stefanos82 commented 4 years ago

Very nice; now it seems to work.

I will experiment more and if I find any other problems, I will open a new ticket if necessary.

Keep up the good work :+1: