Closed jaydrogers closed 6 months ago
Hey @jsayer101,
Thanks for the detailed report! I spent some time working through this, but unfortunately I wasn't able to replicate it.
I recorded a 7 minute video here showing my thoughts:
I also published the code I attempted to replicate it with:
https://github.com/jaydrogers/docker-php-issue-315
Let me know if this helps finding the source of the issue š
Hello,
First of all, thank you for your time ! This is much appreciated. I don't usually ask for help, I always try everything I can because I don't want to waste other people's time. But things happening here are weird.
It seems that my rights are kind of messed up. I work on a computer with Ubuntu 22.04. When I start the container even with the new Dockerfile I still get my files associated with the root user in /var/www/html.
I tried on my Windows host with WSL Ubuntu 22.04 and it works fine, all my files are www-data and using composer install
is OK. I'll try to get a better look this afternoon...
I use docker compose up -d --build
, do you think that it could be cache related ? (my uid and gid are 1000 on WSL-Ubuntu and on Ubuntu)
These things make me pull my hair out as it is almost not reproducible.
You bet!
Try running with this command:
docker compose up -d --build --force-recreate
It could be a local container cache.
Hey,
I've tried on my Ubuntu host but it didn't worked, I also recorded a video to show you : https://streamable.com/hteu87 (will expire in 2days)
I have no clue why it's not working Thanks again for your time
Hey Jules,
I wonder if this is something with you using Docker Desktop instead of Docker engine?
I would try replicating it with my repository: https://github.com/jaydrogers/docker-php-issue-315
Here is a 5 minute video of how it works: https://www.dropbox.com/scl/fi/isx9o1kbo29awsf4eaxsx/DockerPermissions.mp4?rlkey=ggn5va1edzevl22fn88ga0uas&dl=0
Here is how I brought up development:
docker compose -f docker-compose.yml -f docker-compose.dev.yml up --build --force-recreate
And how I brought up production:
docker compose -f docker-compose.yml -f docker-compose.prod.yml up --build --force-recreate
Just putting a note here that I am going to close this issue until we can get it to replicate š
Keep me posted of your results and I can re-open if needed š
Migrated comment
Originally posted by @jsayer101 in #311 (comment)
Hello, I've started from scratch so see if all my problems were solved, but I found that I had problems using composer.
I got a project with this Dockerfile and this docker-compose.yml :
############################################ # Base Image ############################################ FROM serversideup/php-dev:311-8.2-fpm-nginx-alpine as base ############################################ # Development Image ############################################ FROM base as development # Switch to root so we can do root things USER root # Install the necessary packages for our development environment RUN apk update && apk add libraw libjpeg RUN install-php-extensions gd imagick bcmath intl # Save the build arguments as a variable ARG USER_ID ARG GROUP_ID # Use the build arguments to change the UID # and GID of www-data while also changing # the file permissions for NGINX RUN docker-php-serversideup-set-id www-data $USER_ID:$GROUP_ID && \ \ # Update the file permissions for our NGINX service to match the new UID/GID docker-php-serversideup-set-file-permissions --owner $USER_ID:$GROUP_ID --service nginx # Drop back to our unprivileged user USER www-data ############################################ # Production Image ############################################ # Since we're calling "base", production isn't # calling any of that permission stuff FROM base as production # Switch to root so we can do root things USER root RUN apk update && apk add libraw libjpeg RUN install-php-extensions gd imagick bcmath intl # Drop back to our unprivileged user USER www-data # Copy our app files as www-data (33:33) COPY --chown=www-data:www-data . /var/www/html
services: api: build: dockerfile: ./Dockerfile context: . target: development args: # UID and GID must be set as environment variables on the host machine USER_ID: ${UID:-1000} GROUP_ID: ${GID:-1000} container_name: pix-api restart: unless-stopped environment: PHP_FPM_POOL_NAME: "pixsell_api" AUTORUN_ENABLED: "true" AUTORUN_LARAVEL_ROUTE_CACHE: "false" AUTORUN_LARAVEL_VIEW_CACHE: "false" AUTORUN_LARAVEL_CONFIG_CACHE: "false" AUTORUN_LARAVEL_EVENT_CACHE: "false" PHP_DATE_TIMEZONE: "Europe/Paris" PHP_DISPLAY_ERROR: "On" PHP_DISPLAY_STARTUP_ERRORS: "On" PHP_ERROR_REPORTING: "32767" PHP_MEMORY_LIMIT: "4G" volumes: - .:/var/www/html ports: - "8000:8080" networks: - pix-network depends_on: - db # .....
Composer got errors while trying to write to vendor/ and it can't install the dependencies. Running composer install in the container get me this error :
var/www/html $ composer install Composer could not detect the root package (laravel/laravel) version, defaulting to '1.0.0'. See https://getcomposer.org/root-version Installing dependencies from lock file (including require-dev) Verifying lock file contents can be installed on current platform. Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. It is recommended that you run `composer update` or `composer update <package name>`. Package operations: 138 installs, 0 updates, 0 removals In Filesystem.php line 260: /var/www/html/vendor does not exist and could not be created: install [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--dry-run] [--download-only] [--dev] [--no-suggest] [--no-dev] [--no-autoloader] [--no-progress] [--no-install] [--audit] [--audit-format AUDIT-FORMAT] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--] [<packages>...]
Edit : So i've figured out on how to be able to execute composer install inside the container. I've commented "USER www-data" in the dev stage of the dockerfile, logged in into the container and ran composer install.
I wonder how to implement this automatically using this technique as in the dev stage we don't copy the app as it is mounted using compose š¤
I tried using entrypoints but I couldn't make it work
I think you have to check the permissions of your project; I solved that, when I changed the owner of my project from root to www-data, and next add some options to avoid conflicts with git, then that's all.
Migrated comment
Originally posted by @jsayer101 in https://github.com/serversideup/docker-php/issues/311#issuecomment-2067998174
Hello, I've started from scratch so see if all my problems were solved, but I found that I had problems using composer.
I got a project with this Dockerfile and this docker-compose.yml :
Composer got errors while trying to write to vendor/ and it can't install the dependencies. Running composer install in the container get me this error :
Edit : So i've figured out on how to be able to execute composer install inside the container. I've commented "USER www-data" in the dev stage of the dockerfile, logged in into the container and ran composer install.
I wonder how to implement this automatically using this technique as in the dev stage we don't copy the app as it is mounted using compose š¤
I tried using entrypoints but I couldn't make it work