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

[BUG] Makefile don't work on OSX #994

Open
clawfire opened this issue Oct 25, 2021 · 21 comments
Open

[BUG] Makefile don't work on OSX #994

clawfire opened this issue Oct 25, 2021 · 21 comments
Labels
bug Features or code that is not working correctly

Comments

@clawfire
Copy link

Describe the bug
Error while running make setup

To Reproduce
Steps to reproduce the behavior:

  1. Clone project
  2. Run make setup
  3. See error

Expected behavior
A clear and concise description of what you expected to happen.

Logs
You can see the logs here https://pastebin.com/KbTQfSUs

Environment the bug happens in (Desktop, Mobile, CLI) (please complete the following information):

  • OS: Mac

Version of Attendize you are using

  • Master
@clawfire clawfire added the bug Features or code that is not working correctly label Oct 25, 2021
@quentincaffeino
Copy link
Contributor

I'm not using the setup provided by this repo so this is just an assumption based on provided logs: try running composer install before running make

@clawfire
Copy link
Author

It's a docker based environment, you cannot "run composer install" in your terminal before the containers works 😁
The issue here is the container setup, not attendize setup ;)

But thanks

@quentincaffeino
Copy link
Contributor

quentincaffeino commented Oct 25, 2021

Run composer install locally, not in the docker container. I think current setup assumes that you have everything prepared locally and then just packages that to container. Therefore this is not an issue at all, maybe just a bad design

@johannac
Copy link
Member

The docker file will run the composer install for you. In the log output you attached, it shows docker is building the images from cache, so it's not going to run the setup script again (which is what does the composer install). Can you try building the images again? Either by deleting the images or running the docker build commands directly with --no-cache?

@clawfire
Copy link
Author

Even deleting the image it takes from cache because the docker commands are :
docker build --tag attendize_worker --target worker --cache-from attendize_base:latest .
and
docker build --tag attendize_web --target web --cache-from attendize_worker:latest .

@quentincaffeino
Copy link
Contributor

quentincaffeino commented Oct 25, 2021

@clawfire, I see you use new buildx engine, to actually delete build cache you need to docker system prune. Simply deleting image won't do as buildx has its own cache.

Add --no-cache to docker build command as suggested by @johannac

@johannac
Copy link
Member

@clawfire the first docker build command doesn't have a cache flag, since it's building the base image. This is the important one because it will run the set up script. Try running

docker build --tag attendize_base --target base --no-cache .

And then run the other two from the build step in the Makefile.

@clawfire
Copy link
Author

I runned a docker system pruneas recommended by @quentincaffeino 😃 (👍🏼 for that) and now trying the make setup again. It's just taking ages to run so ... waiting 😃

@clawfire
Copy link
Author

Hum ... sadly it didn't work

make setup         
docker build --tag attendize_base --target base .
[+] Building 8462.9s (11/11) FINISHED                                                       
 => [internal] load build definition from Dockerfile                                   0.1s
 => => transferring dockerfile: 1.55kB                                                 0.1s
 => [internal] load .dockerignore                                                      0.0s
 => => transferring context: 113B                                                      0.0s
 => [internal] load metadata for docker.io/wyveo/nginx-php-fpm:php74                   5.3s
 => [auth] wyveo/nginx-php-fpm:pull token for registry-1.docker.io                     0.6s
 => [base 1/5] FROM docker.io/wyveo/nginx-php-fpm:php74@sha256:bdcb447188f7beb38527a  79.2s
 => => resolve docker.io/wyveo/nginx-php-fpm:php74@sha256:bdcb447188f7beb38527a366347  0.0s
 => => sha256:094b0a784a769dad0006ed4169f02a5ce6b3598a17ceb16033 134.80MB / 134.80MB  65.8s
 => => sha256:bdcb447188f7beb38527a3663478c0e8d125ce5caf0f524a46e8fcb 1.57kB / 1.57kB  0.0s
 => => sha256:980172b2a9ea15e7c16bd0bc1d4a66713bbe9b4e4dab5114a6d0bdb 9.20kB / 9.20kB  0.0s
 => => sha256:0bc3020d05f1e08b41f1c5d54650a157b1690cde7fedb1fafbc9 50.44MB / 50.44MB  54.5s
 => => sha256:61e7739dd01cd8ec68702ee16687c0e8c68af05512ee27825eafbdb6ea1 902B / 902B  1.5s
 => => sha256:3a0f337fbd2602ebc80fadc0d3e19c0fd5e821c3142076fc84623d5 1.08kB / 1.08kB  1.9s
 => => sha256:d63a3dc279a379d723c2efdd46f4a9db70aea1df270278175fde650 5.29kB / 5.29kB  2.3s
 => => sha256:b4225a1c9532cbd0cee9060696b7e10a33e3e645a1543fe67f864ca70f0 325B / 325B  3.1s
 => => extracting sha256:0bc3020d05f1e08b41f1c5d54650a157b1690cde7fedb1fafbc9cda70ee2  8.9s
 => => extracting sha256:094b0a784a769dad0006ed4169f02a5ce6b3598a17ceb160333fb1ed803  12.5s
 => => extracting sha256:61e7739dd01cd8ec68702ee16687c0e8c68af05512ee27825eafbdb6ea1c  0.0s
 => => extracting sha256:3a0f337fbd2602ebc80fadc0d3e19c0fd5e821c3142076fc84623d57a0a7  0.0s
 => => extracting sha256:d63a3dc279a379d723c2efdd46f4a9db70aea1df270278175fde65064887  0.0s
 => => extracting sha256:b4225a1c9532cbd0cee9060696b7e10a33e3e645a1543fe67f864ca70f0d  0.0s
 => [internal] load build context                                                     11.6s
 => => transferring context: 69.51MB                                                  11.6s
 => [base 2/5] RUN apt-get update && apt-get install -y wait-for-it libxrender1       10.4s
 => [base 3/5] WORKDIR /usr/share/nginx/html                                           0.0s
 => [base 4/5] COPY . .                                                                0.6s
 => [base 5/5] RUN ./scripts/setup                                                   144.4s
 => exporting to image                                                                14.5s
 => => exporting layers                                                               14.4s
 => => writing image sha256:f5deb4e36af5d903f577eb9868c7ff35f6f1c563140239d214fdd7fe5  0.0s
 => => naming to docker.io/library/attendize_base                                      0.0s
                                                                                            
Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
docker build --tag attendize_worker --target worker --cache-from attendize_base:latest .
[+] Building 9.0s (12/12) FINISHED                                                          
 => [internal] load build definition from Dockerfile                                   0.1s
 => => transferring dockerfile: 93B                                                    0.0s
 => [internal] load .dockerignore                                                      0.0s
 => => transferring context: 90B                                                       0.0s
 => [internal] load metadata for docker.io/wyveo/nginx-php-fpm:php74                   5.6s
 => [auth] wyveo/nginx-php-fpm:pull token for registry-1.docker.io                     1.7s
 => importing cache manifest from attendize_base:latest                                0.0s
 => [base 1/5] FROM docker.io/wyveo/nginx-php-fpm:php74@sha256:bdcb447188f7beb38527a3  0.0s
 => [internal] load build context                                                      0.3s
 => => transferring context: 316.75kB                                                  0.3s
 => CACHED [base 2/5] RUN apt-get update && apt-get install -y wait-for-it libxrender  0.0s
 => CACHED [base 3/5] WORKDIR /usr/share/nginx/html                                    0.0s
 => CACHED [base 4/5] COPY . .                                                         0.0s
 => CACHED [base 5/5] RUN ./scripts/setup                                              0.0s
 => exporting to image                                                                 0.0s
 => => exporting layers                                                                0.0s
 => => writing image sha256:98347452ab26fc22fa4101b6f6823aa268d9f3d5443ffdbf0bc003dfa  0.0s
 => => naming to docker.io/library/attendize_worker                                    0.0s

Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
docker build --tag attendize_web --target web --cache-from attendize_worker:latest .
[+] Building 6878.4s (15/15) FINISHED                                                       
 => [internal] load build definition from Dockerfile                                   0.0s
 => => transferring dockerfile: 93B                                                    0.0s
 => [internal] load .dockerignore                                                      0.0s
 => => transferring context: 90B                                                       0.0s
 => [internal] load metadata for docker.io/wyveo/nginx-php-fpm:php74                   0.6s
 => [base 1/5] FROM docker.io/wyveo/nginx-php-fpm:php74@sha256:bdcb447188f7beb38527a3  0.0s
 => [internal] load build context                                                      0.3s
 => => transferring context: 316.75kB                                                  0.3s
 => importing cache manifest from attendize_worker:latest                              0.0s
 => CACHED [base 2/5] RUN apt-get update && apt-get install -y wait-for-it libxrender  0.0s
 => CACHED [base 3/5] WORKDIR /usr/share/nginx/html                                    0.0s
 => CACHED [base 4/5] COPY . .                                                         0.0s
 => CACHED [base 5/5] RUN ./scripts/setup                                              0.0s
 => [web 1/4] COPY nginx.conf /etc/nginx/conf.d/default.conf                           0.0s
 => [web 2/4] RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/  181.8s
 => [web 3/4] COPY self-signed.conf /etc/nginx/snippets/self-signed.conf               0.0s
 => [web 4/4] COPY ssl-params.conf /etc/nginx/snippets/ssl-params.conf                 0.0s
 => exporting to image                                                                 0.1s
 => => exporting layers                                                                0.1s
 => => writing image sha256:2d276ff6c0575a4483ebabb1ea8abd688c16e343677db278e05c38eb8  0.0s
 => => naming to docker.io/library/attendize_web                                       0.0s

Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
cp .env.example .env
docker-compose up -d
[+] Running 28/28
 ⠿ redis Pulled                                                                      155.0s
   ⠿ 7d63c13d9b9b Pull complete                                                      147.1s
   ⠿ a2c3b174c5ad Pull complete                                                      147.1s
   ⠿ 283a10257b0f Pull complete                                                      147.1s
   ⠿ 7a08c63a873a Pull complete                                                      147.1s
   ⠿ 0531663a7f55 Pull complete                                                      147.1s
   ⠿ 9bf50efb265c Pull complete                                                      147.1s
 ⠿ db Pulled                                                                         267.9s
   ⠿ f17d81b4b692 Pull complete                                                       65.9s
   ⠿ c691115e6ae9 Pull complete                                                       65.9s
   ⠿ 41544cb19235 Pull complete                                                       65.9s
   ⠿ 254d04f5f66d Pull complete                                                       65.9s
   ⠿ 4fe240edfdc9 Pull complete                                                       65.9s
   ⠿ 0cd4fcc94b67 Pull complete                                                      104.0s
   ⠿ 8df36ec4b34a Pull complete                                                      104.0s
   ⠿ 006c5ba50345 Pull complete                                                      104.0s
   ⠿ 1a7081a7f092 Pull complete                                                      218.2s
   ⠿ 46bb21de7ef9 Pull complete                                                      252.0s
   ⠿ 56064f7c9c1b Pull complete                                                      260.0s
 ⠿ maildev Pulled                                                                    155.0s
   ⠿ e6b0cf9c0882 Pull complete                                                       56.2s
   ⠿ 93f9cf0467ca Pull complete                                                      121.6s
   ⠿ a564402f98da Pull complete                                                      121.6s
   ⠿ b68680f1d28f Pull complete                                                      127.0s
   ⠿ d83a90929b44 Pull complete                                                      147.1s
   ⠿ 5bb08f80fc87 Pull complete                                                      147.1s
   ⠿ 021ced319bab Pull complete                                                      147.1s
   ⠿ 7a42c2dca0ef Pull complete                                                      147.1s
[+] Running 7/7
 ⠿ Network attendize_default      Created                                              0.6s
 ⠿ Volume "attendize_mysql-data"  Created                                              0.0s
 ⠿ Container attendize-redis-1    Started                                             19.1s
 ⠿ Container attendize-db-1       Started                                             19.1s
 ⠿ Container attendize-maildev-1  Started                                             19.1s
 ⠿ Container attendize-worker-1   Started                                             22.5s
 ⠿ Container attendize-web-1      Started                                             23.1s
docker-compose exec web sh -c 'wait-for-it db:3306 -t 180 && php artisan key:generate && php artisan migrate'
 so .wait-for-it: waiting 180 seconds for db:3306
wait-for-it: db:3306 is available after 0 seconds
PHP Warning:  require(/usr/share/nginx/html/vendor/autoload.php): failed to open stream: No such file or directory in /usr/share/nginx/html/artisan on line 18
PHP Fatal error:  require(): Failed opening required '/usr/share/nginx/html/vendor/autoload.php' (include_path='.:/usr/share/php') in /usr/share/nginx/html/artisan on line 18
make: *** [setup] Error 255

@avm99963
Copy link

Can reproduce this exact issue in macOS 10.15.7 with a fresh Attendize install. Also ran docker system prune -a, but didn't fix the issue.

@johannac
Copy link
Member

@avm99963 and @clawfire could you both comment what version of docker you're using? Output from docker -v. Thanks!

@avm99963
Copy link

Thanks @johannac for the reply :)

Docker version 20.10.7, build f0df350.

I think there's an update available, so I'll try to update.

@clawfire
Copy link
Author

On my side I have Docker version 20.10.8, build 3967b7d

@avm99963
Copy link

avm99963 commented Nov 1, 2021

I just realized what the issue is. All the docker images (base, worker and web) contain the vendor/autoload.php file, but afterwards the docker-compose.yml file replaces the whole /usr/share/nginx/html folder (which contained the vendor/autoload.php file) with the host checkout of the repository (see lines 10 and 26):

volumes:
- .:/usr/share/nginx/html
- .:/var/www

volumes:
- .:/usr/share/nginx/html
- .:/var/www

Thus, if the composer install command hasn't been run in the checkout in the host, this issue occurs.

@clawfire
Copy link
Author

clawfire commented Nov 8, 2021

hum ... how could it be fixed? I'm not enough skilled with docker for now to seek an alternative solution

@quentincaffeino
Copy link
Contributor

quentincaffeino commented Nov 8, 2021

hum ... how could it be fixed? I'm not enough skilled with docker for now to seek an alternative solution

So basically my first thought was correct, run composer install on your host

Edit: Or you mean if there's an actual fix for this issue so this won't happen?

@avm99963
Copy link

avm99963 commented Nov 8, 2021

So basically my first thought was correct, run composer install on your host

Yup, indeed! I didn't see your message before, sorry :(

The only thing is composer install is also called while building the Docker image, so running that shouldn't be necessary.

hum ... how could it be fixed? I'm not enough skilled with docker for now to seek an alternative solution

I'd change the volumes lists to only bind directories where persistent data is saved, instead of the whole .../nginx/html directory.

@quentincaffeino
Copy link
Contributor

I'd change the volumes lists to only bind directories where persistent data is saved, instead of the whole .../nginx/html directory.

That's not an ideal solution because:

  1. you would have to map every directory by hand
  2. it is binded to whole directory because it makes development easier

Best solution would be:

  1. to split base image into two: system dependencies, php pecl packages and stuff; and composer packages where second would be used only for prod build.
  2. Add an entrypoint script to dev which would be ran on container start. This way composer install would write all the changes to the volume.

@quentincaffeino
Copy link
Contributor

quentincaffeino commented Nov 8, 2021

I might post my docker setup some day as a separate repo. But my solution has one problem is that it runs on swoole both in prod and dev and currently swoole is very painful in dev.

@dalarworld
Copy link

dalarworld commented Nov 25, 2021

Any one successful to run this on Mac ? I am on macOS Big Sur [ 11.6.1]

da-mac:Attendize da$ make setup
docker build --tag attendize_base --target base .
[+] Building 7.0s (7/10)                                                                                                                                                                                
 => [internal] load build definition from Dockerfile                                                                                                                                               0.0s
 => => transferring dockerfile: 43B                                                                                                                                                                0.0s
 => [internal] load .dockerignore                                                                                                                                                                  0.0s
 => => transferring context: 34B                                                                                                                                                                   0.0s
 => [internal] load metadata for docker.io/wyveo/nginx-php-fpm:php74                                                                                                                               4.1s
 => [auth] wyveo/nginx-php-fpm:pull token for registry-1.docker.io                                                                                                                                 0.0s
 => CACHED [base 1/5] FROM docker.io/wyveo/nginx-php-fpm:php74@sha256:bdcb447188f7beb38527a3663478c0e8d125ce5caf0f524a46e8fcbb785dbf3f                                                             0.0s
 => [internal] load build context                                                                                                                                                                  0.1s
 => => transferring context: 155.06kB                                                                                                                                                              0.1s
 => ERROR [base 2/5] RUN apt-get update && apt-get install -y wait-for-it libxrender1                                                                                                              2.8s
------                                                                                                                                                                                                  
 > [base 2/5] RUN apt-get update && apt-get install -y wait-for-it libxrender1:                                                                                                                         
#6 0.684 Err:1 http://security.debian.org/debian-security buster/updates InRelease                                                                                                                      
#6 0.684   Connection failed [IP: 151.101.66.132 80]                                                                                                                                                    
#6 0.687 Err:2 http://deb.debian.org/debian buster InRelease                                                                                                                                            
#6 0.687   Connection failed [IP: 199.232.22.132 80]                                                                                                                                                    
#6 0.769 Err:3 http://deb.debian.org/debian buster-updates InRelease
#6 0.769   Connection failed [IP: 199.232.22.132 80]
#6 0.780 Get:4 https://packages.sury.org/php buster InRelease [6837 B]
#6 0.867 Err:5 http://nginx.org/packages/mainline/debian buster InRelease
#6 0.867   Connection failed [IP: 3.125.197.172 80]
#6 2.120 Get:6 https://packages.sury.org/php buster/main amd64 Packages [350 kB]
#6 2.338 Fetched 357 kB in 2s (200 kB/s)
#6 2.338 Reading package lists...
#6 2.519 W: Failed to fetch http://deb.debian.org/debian/dists/buster/InRelease  Connection failed [IP: 199.232.22.132 80]
#6 2.519 W: Failed to fetch http://security.debian.org/debian-security/dists/buster/updates/InRelease  Connection failed [IP: 151.101.66.132 80]
#6 2.519 W: Failed to fetch http://deb.debian.org/debian/dists/buster-updates/InRelease  Connection failed [IP: 199.232.22.132 80]
#6 2.519 W: Failed to fetch http://nginx.org/packages/mainline/debian/dists/buster/InRelease  Connection failed [IP: 3.125.197.172 80]
#6 2.519 W: Some index files failed to download. They have been ignored, or old ones used instead.
#6 2.605 Reading package lists...
#6 2.785 Building dependency tree...
#6 2.806 Reading state information...
#6 2.823 E: Unable to locate package wait-for-it
#6 2.823 E: Unable to locate package libxrender1
------
executor failed running [/bin/sh -c apt-get update && apt-get install -y wait-for-it libxrender1]: exit code: 100
make: *** [build] Error 1

@LuchoTurtle
Copy link

LuchoTurtle commented Sep 14, 2023

I had problems running on Mac M1 as well (Ventura 13.5.2). Here's how I got it working with attendize's latest branch (the one that runs on php@7.3.

  • you need to install composer to update and install the dependencies before you run make setup. For this, run the following command (I'm using brew because it's easier):
brew install composer

This will install php as well, version 8. We need 7.4 because the latest branch uses it.
Therefore, run the following commands.

brew tap shivammathur/php
brew install shivammathur/php/php@7.4

Now you need to unlink php@8 and link this latest one you've installed. Run brew unlink php and brew link php@7.4 so it works.

  • run composer update and composer install.
  • run sudo make setup.

And this should work now!

If it doesn't, try running docker-compose exec web sh -c 'composer install && wait-for-it db:3306 -t 180 && php artisan key:generate && php artisan migrate' as a last resort (ref #1011).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Features or code that is not working correctly
Projects
None yet
Development

No branches or pull requests

6 participants