docker-php-tutorial
docker-php-tutorial copied to clipboard
docker-test.sh use bash syntax for function and not POSIX one
My default shell is dash and not bash and make docker-test failed with error:
sh ./.docker/docker-test.sh
./.docker/docker-test.sh: 3: Syntax error: "(" unexpected
make: *** [Makefile:29: docker-test] Error 2
To fix it I add a SH variable in the Makefile: SH=/bin/bash and change the according line:
- sh $(DOCKER_COMPOSE_DIR)/docker-test.sh
+ $(SH) $(DOCKER_COMPOSE_DIR)/docker-test.sh
There's many way to make that change usefull and configurable to avoid changing the Makefile directly. You can add a conf.mk file with default values and include it in the main Makefile.
For example I have an another issue that can be solved with that conf.mk file. I change the NGINX_HOST_HTTP_PORT (because the 80 is already used !) but of course the last test in docker-test.sh failed.
Anyway thanks for the stuff. I really like it.
Hi,
unfortunately, I have the same problem as @nikrou with my Ubuntu 18.04 running on WSL (Windows subsystem). The workaround with the SH variable within the Makefile doesn't work for me. :/
I also changed the Shebang call to /bin/bash which through other Syntax Errors... I am still in the process of figuring out how to solve it.
Please refer to the updated article at https://www.pascallandau.com/blog/docker-from-scratch-for-php-applications-in-2022/
The Makefile should be set up in a way to force the usage of bash
as shell