-
Notifications
You must be signed in to change notification settings - Fork 336
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
Dockerfile and docker-compose update for php version 7.4 #536
Conversation
@@ -76,9 +75,9 @@ WORKDIR /srv/sylius | |||
ARG APP_ENV=prod | |||
|
|||
# prevent the reinstallation of vendors at every changes in the source code | |||
COPY composer.json composer.lock symfony.lock ./ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you sure this should be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The composer.lock file is not needed anymore (since composer v2 as i remember?). The composer is creating it when building containers and modify directory on your machine (the composer.lock is created). I might be wrong with my thinking and the composer.lock file might be needed to prevent reinstalation.
When I checked manualy I made some changes in code of application, and run docker-compose build
and the composer was running from cache ( no reinstallation of vendors happened).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If somebody with docker experience is looking here please give an opinion, I am still learning docker 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arti0090 Thanks for your PR!
According to the composer docs here: https://getcomposer.org/doc/01-basic-usage.md#installing-with-composer-lock it is a good practice to commit your project's composer.lock file to version control. Also it makes sense to copy this file to Docker's context during image build, because composer then don't need to resolve the latest versions of a dependency but simply grabs the locked version of a dependency in the composer.lock file. This also ensures that you have a controlled Docker image build. Else it may happen that some dependencies changes during your Docker image build process which results in another behaviour.
So with the composer.lock file you can have controlled way of updating your dependencies, without it each composer install
execution may install some other versions of a dependency which may produce some error in your application.
As far as I see this Sylius-Standard repo also does not include such a composer.lock file, so you need to make sure that you have run composer install (or composer create-project...) before you build a Docker image, else the Docker image build will fail with the message that "the composer.lock file does not exist...". See also #503 which proposes to remove composer.lock file from the .gitignore file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a small question here, how would you run composer install
if you rely on the PHP & Composer provided by the Docker image (which, as you said, will fail to built on first run b/c there is no composer.lock
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @ilimination for your review comment, unfortunately I don't think that composer.lock file can be left. As in Sylius there are is a matrix of version supported (like php 7.4 or 8.0 and different mysql's) and leaving composer lock might interfere with it. Speaking about splitting prod and dev in two - well te bo honest I struggle with my experience at the moment to make it right 😄 .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A fix for being able to build the Docker image before composer install
(without an composer.lock
file) was proposed here: #559
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Including composer.lock
in the Sylius-Standard repo might indeed interfere with the various PHP versions, but only providing instructions to Docker to COPY your own composer.lock
file once it's initialized should not interfere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added the line from #559 into the PR. Credits to you @tarnawski , hope this won't be a problem to use your code here? 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A more proper way will be merge #559 and then rebase your changes to be aline with the master, but as is a small improvement - take it as yours 😉
I am looking for some suggestions for this PR:
Any other suggestions are really appreciated 😄 |
docker-compose.yml
Outdated
- quay.io/sylius/nodejs:latest | ||
- quay.io/sylius/nginx:latest | ||
image: quay.io/sylius/nodejs:latest | ||
image: nodejs:latest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nodejs
not is available image, the correct is node
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have changed any nodejs to node in files.
@arti0090 using docker I faced this prolonged response too. It's probably around php-fpm, the Nginx wait for it. Because of that you getting a Bad Gateway. |
I'm trying to help with these little changes at: arti0090#1 |
@tonicospinelli I was making some investigations about nginx 502 error. It looks like the php container was working too slow, or being precise - nginx and php were starting at the same time but php was than starting doctrine scripts and also building assets. When it finished the nginx was able to show Sylius page with no trouble. |
I can not wait to see this PR published, thanks @arti0090 and all reviewers ;-) |
# Quay does not work, should be replaced in future with f.e. ghcr.io | ||
# cache_from: | ||
# - quay.io/sylius/php:latest | ||
# - quay.io/sylius/nodejs:latest | ||
# - quay.io/sylius/nginx:latest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commented config (unless left for reference for users) should be removed - as it is just a dead "code"
Thank you, @arti0090! 🎉 |
Hey folks! Thanks for this amount of interest in Sylius docker - I hope we will be able to forge a better, more sustainable docker image for Sylius with you. Changes from this PR will be release in about ~2 weeks, until then you will have to use dev-master to take advantage of it. |
Hello, could it be simply updated to PHP8, as Sylius 1.10 brings it? Any love to Kubernetes as well could be planned / provided? |
@lchrusciel I add some adjusts to increase the development experience over docker. Take a look on #568 when you have time 🤗 |
I would like PHP 8 too, maybe we could create two tags: PHP 7.4 and 8.0 ? |
fastcgi_pass $backendfpm; | ||
# Comment the next line and uncomment the next to enable dynamic resolution (incompatible with Kubernetes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't they inversed ?
This PR was merged into the 1.9-dev branch. Discussion ---------- I think #536 has introduced a little error https://github.com/Sylius/Sylius-Standard/pull/536/files#diff-f583d11fcce9311b02b20054d21bc42d9c3ce8337322f0f4c66a16f36825f766R12-R13 Commits ------- 0cf0521 Fix inverted line
This PR was merged into the 1.9-dev branch. Discussion ---------- I think Sylius/Sylius-Standard#536 has introduced a little error https://github.com/Sylius/Sylius-Standard/pull/536/files#diff-f583d11fcce9311b02b20054d21bc42d9c3ce8337322f0f4c66a16f36825f766R12-R13 Commits ------- 0cf05217653166214397ce1a61c89b7f213bc517 Fix inverted line
No description provided.