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

[Docker] Fix fixture images not being available #885 #887

Closed
wants to merge 2 commits into from

Conversation

vvasiloi
Copy link
Contributor

@vvasiloi vvasiloi commented Dec 8, 2022

Fix #885

  1. mount media volume to migrations container so fixture images are available in php and nginx container
  2. change nginx user and group to match php's, so it can read image cache files

1. mount media volume to migrations container so fixture images are available in php and nginx container
2. change nginx user and group to match php's, so it can read image cache files
@vvasiloi vvasiloi requested a review from a team as a code owner December 8, 2022 12:03
@probot-autolabeler probot-autolabeler bot added the Docker Docker-related issues and PRs. label Dec 8, 2022
@@ -0,0 +1,31 @@
user www-data;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we can merge both configurations?

https://github.com/Sylius/Sylius-Standard/blob/1.12/docker/nginx/conf.d/default.conf

if they can be separate, then I would rather have them moved to conf.d directory and let nginx handle loading it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The files from conf.d are included in the http section, they can't be merged and this file can't go to conf.d.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ferror
Copy link
Contributor

Ferror commented Dec 8, 2022

I can see that the image files are now available, but the requests are returning 404. Fresh Sylius-Standard installation.

Screenshot 2022-12-08 at 23 09 50

Screenshot 2022-12-07 at 23 00 11


#gzip on;

include /etc/nginx/conf.d/*.conf;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ferror this is where the files from conf.d are included. This config file is a copy of the one that was shipped with this image, I just changed the user.

@vvasiloi
Copy link
Contributor Author

vvasiloi commented Dec 9, 2022

I hate root containers... the problem still persist becuase the migrations container runs as root and the image files are created with root user, but now the nginx and fpm process run with a non-root user...

@@ -22,4 +22,7 @@ php bin/console doctrine:migrations:migrate --no-interaction

if [ "$LOAD_FIXTURES" = "1" ]; then
php bin/console sylius:fixtures:load --no-interaction

# make the image files created by fixtures accessible by fpm which runs with user www-data
chown -R www-data:www-data public/media/image
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ferror this will fix the issue, but it's just like applying FlexTape... ideally we should adopt non-root containers and make GIDs and UIDs configurable via build args and env vars, like this: https://github.com/laradock/laradock/blob/96e0f2e92f6e5b128a71cc77a05b297ac4a0eadb/workspace/Dockerfile#L43-L47

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized that if I launched the fixtures manually from the php container, I had to reset the rights each time afterwards.

php bin/console sylius:fixtures:load -n && chown -R www-data:www-data public/media/image

@Ferror
Copy link
Contributor

Ferror commented Dec 9, 2022

PS. The pipeline probably fails because MySQL is taking a little more time to spin up. Let's try to increment the attempt amount to 25. It's still gonna be only 25 seconds in the worst-case scenario, and in real life, the database would be always available.

https://github.com/Sylius/Sylius-Standard/blob/1.12/docker/migrations/docker-entrypoint.sh#L4

@umpirsky
Copy link

umpirsky commented May 7, 2023

I have the same issue. Can we merge this?

@gabiudrescu
Copy link

@vvasiloi who do we need to bribe to get this merged in master?

@vvasiloi
Copy link
Contributor Author

@vvasiloi who do we need to bribe to get this merged in master?

This should not be merged. It's not a good solution. We should use non-root containers instead.

@vvasiloi vvasiloi closed this Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docker Docker-related issues and PRs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot resolve images shipped with fixtures
5 participants