swoole / docker-swoole

🏄 Official Docker Image of Swoole
https://hub.docker.com/r/phpswoole/swoole
Apache License 2.0
534 stars 113 forks source link

example 00 cannot run as expected #19

Closed wereset closed 3 years ago

wereset commented 3 years ago

example 00 cannot run as expected, if I configured like this: volumes:

when I configure with this volumn, 80 port not work; But it's ok when I remove the config.

wereset commented 3 years ago

example 02-www is also not ok, when configured the item COPY ./rootfilesystem/ / , 80 port not run , but it's ok when i remove this config

deminy commented 3 years ago

I just tested and both examples worked fine.

How did you build and start the containers? Did you clone the repository and run the examples without making any changes? Or, did you copy file Dockerfile to some other places and tried to build an image with that?

wereset commented 3 years ago

Yes, i did not change anythins. Example 00 has not Dockerfile , and the docker-compose.yml is:

# This docker-compose.yml file shows how Supervisor program(s) are reloaded automatically when file changes detected
# under web root /var/www. There are two environment variables used:
#     1. AUTORELOAD_PROGRAMS: space-separated Supervisor program(s) to be reloaded when file changes detected. e.g.,
#            AUTORELOAD_PROGRAMS: "swoole"       # Autoreload Supervisor program "swoole" only.
#            AUTORELOAD_PROGRAMS: "swoole nginx" # Autoreload Supervisor program "swoole" and "nginx".
#     2. AUTORELOAD_ANY_FILES: Optional. If set to "true", "1", "yes", or "y", reload Supervisor program(s) when any
#        files under the root directory (/var/www in this example) is changed; otherwise, reload only when PHP file(s)
#        are changed.
#
version: '3'

services:
  app:
    image: phpswoole/swoole
    environment:
      AUTORELOAD_PROGRAMS: "swoole"
      AUTORELOAD_ANY_FILES: 0
    ports:
      - 80:9501
    volumes:
      - ./rootfilesystem/var/www:/var/www
wereset commented 3 years ago

root@**:/var/www# supervisorctl autoreload RUNNING pid 17, uptime 0:00:40 swoole FATAL command at '/var/www/server.php' is not executable supervisor>

This is my supervisorctl info, swoole command run failure. And it's ok when i change the command to: php /var/www/server.php

deminy commented 3 years ago

So the problem is that, the server.php PHP files in your local copy are not executable. However, all of them are set to executable in the Git repository.

I'm wondering if the issue happens under certain environments only. Could you please share some more information about your local development environment? Are you using Linux or Windows? How did you clone the repository? (or, which tool did you use to clone the repository?) Thanks

wereset commented 3 years ago

Thank you very much! My steps:

  1. I download the project from GitHub as zip
  2. Unzip and upload to my linux(centos 7)
  3. cd ./bin
  4. sh ./example.sh start 00

So,if i download as zip ,It's not executable when i upload it , and i must set it to executable. Thanks!

leocavalcante commented 3 years ago

It is happening here (macOS Big Sur + Docker CE 2.5.0.1) too. Fortunately using my own Dockerfile then a RUN chmod +x /var/www/server.php solves.

PS.: if you are on a Windows host, make sure line-endings of the /var/www/server.php file are LF, not CRLF.

deminy commented 3 years ago

I made an adjustment in the Supervisor configuration files to start the servers by running PHP commands explicitly (commit). Hope that helps.

leocavalcante commented 3 years ago

That is awesome because this removes the need for #!/usr/bin/env php (that I always forget xD) as well.

wereset commented 3 years ago

I made an adjustment in the Supervisor configuration files to start the servers by running PHP commands explicitly (commit). Hope that helps.

Thanks!