0

I have two amazon EC2 instances with different CPU architectures.

  1. x86_64 ubuntu 20.04
  2. arm64 ubuntu 22.04

Both are running the same docker service. However, each service is based on the corresponding CPU architecture docker image.

I've mounted a few directories from the localhost to the docker service for both instances the same way.

And when I run the PHP function like:

realpath('../tmp');

It works for the x86_64 service but it doesn't work for the arm64.

I'm not sure if the CPU architecture affects but this is the only difference between them.

Update:

When I run the Linux command realpath:

/var/www/html/public# realpath ../tmp

I get the correct path:

/var/www/html/tmp

And the PHP config is also the same for both instances/services.

  • Is it possible that the base images you're using have slightly different `php.ini` configs? – Siguza Jun 30 '22 at 06:14
  • Do you personally created `tmp` dir or you want to reach system's tmp dir? Maybe look at [sys_get_temp_dir](https://www.php.net/manual/en/function.sys-get-temp-dir.php) – Justinas Jun 30 '22 at 07:18
  • @Siguza Thank you for your feedback. The configuration is the same. What I'm thinking of is maybe the PHP for the ARM has a bug? I'm not sure how the PHP realpath function works maybe it's based on the Linux realpath. If I run in the command line the Linux command like"$ realpath ../tmp" It returns me the correct path. But PHP's function doesn't. – Dmitriy Antonenko Jun 30 '22 at 09:26
  • @Justinas Thanks for the hint. But I have a number of different directories, not only tmp. And none of them works. The folder is being created automatically with command: --mount type=bind,source=${ASSET_PATH}/tmp,target=/var/www/html/tmp – Dmitriy Antonenko Jun 30 '22 at 09:31
  • Are your x86 and ARM images running PHP as the same user with the same UID & do your app directories have the same permissions? "_The running script must have executable permissions on all directories in the hierarchy, otherwise [realpath()](https://www.php.net/realpath) will return false._" – RickN Jun 30 '22 at 12:28
  • @RickN Thanks for the feedback. Yes, I'm using the same Dockerfile, so users are the same with the same ID. And permissions were the first things I checked. Everything is correct. I'm afraid this is a PHP bug in the package for the ARM architecture. :( – Dmitriy Antonenko Jul 01 '22 at 03:35
  • Does `realpath()` returns `false`, `""` or something else? Does it work in a different directory or one not volume mounted by Docker? (for example `php -r 'chdir("/home"); var_dump(realpath("../tmp"));'`) – RickN Jul 01 '22 at 07:39
  • @RickN. Yes, It returns `false`. And it doesn't work only for the mounted directories. For all other directories, it works fine. – Dmitriy Antonenko Jul 03 '22 at 09:24

0 Answers0