prestashop-flashlight icon indicating copy to clipboard operation
prestashop-flashlight copied to clipboard

Idea - Linux bind www-data to current user to have read/write for develop-a-module

Open MaximeOh opened this issue 2 months ago • 0 comments

I am a web developer, i am Debian/Ubuntu users and i use Docker to have multiple development environment. I try to use prestashop-flashlight to test my personal modules and i follow the guidelines for that (develop-a-module) and with no surprise, i have trouble with read/write access.

In my system, my user has classical uid/gid set to 1000:1000, and usually i use devilbox docker image which use a mecanism to set uid/gid for www-data user in container.

So, i analyse alpine Dockerfile and scripts to understand how i can change uid/gid with my own value.

First, in alpine-base-install.sh we need to add shadow packet (line 5) to have usermod and groupmod tools. Secondly just after installation, so before executing php-configuation.sh and change owner for www-data user.

Just add 2 lines :

usermod -u 1000 www-data
groupmod -g 1000 www-data

To finish, i build image in local with build.sh and i test bidirectionnal read/write, success.

I try to do the same thing for debian image with debian-base-install.sh, add just before php-configuration.sh execution, the image was generate too, but it is unstable, i have a lot of 502 nginx error and sometimes it's ok...

I think it's possible to make it customizable with 2 environment variables (HOST_UID & HOST_GID) and use it directly from docker-compose file, but i need to understand the ARG/ENV mechanism used in Dockerfiles.

MaximeOh avatar Apr 25 '24 13:04 MaximeOh