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

Dockerfile and docker-compose update for php version 7.4 #536

Merged
merged 5 commits into from
May 28, 2021

Conversation

arti0090
Copy link
Contributor

@arti0090 arti0090 commented Apr 1, 2021

No description provided.

@arti0090 arti0090 requested a review from a team as a code owner April 1, 2021 06:19
@@ -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 ./
Copy link
Member

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?

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 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).

Copy link
Contributor Author

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 😄

Copy link

@olimination olimination May 18, 2021

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.

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)?

Copy link
Contributor Author

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 😄 .

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

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.

Copy link
Contributor Author

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? 😄

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 😉

@arti0090 arti0090 changed the title Dockerfile update to php version 7.4 Dockerfile and docker-compose update for php version 7.4 Apr 7, 2021
@arti0090
Copy link
Contributor Author

arti0090 commented Apr 7, 2021

I am looking for some suggestions for this PR:

  1. As I find out the quay.io is now private repositories thats why I deleted it. Is this an OK thing?
  2. I have changed some lines for nginx to resolve automatically the IP's of containers. Still in my opinion there is an issue that (in my case) I need to wait for about 10minutes for nginx to work properly (otherwise I have 502 bad gateway error). Any solutions?

Any other suggestions are really appreciated 😄

- quay.io/sylius/nodejs:latest
- quay.io/sylius/nginx:latest
image: quay.io/sylius/nodejs:latest
image: nodejs:latest

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

Copy link
Contributor Author

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.

@tonicospinelli
Copy link

@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.

@tonicospinelli
Copy link

I'm trying to help with these little changes at: arti0090#1

@arti0090
Copy link
Contributor Author

@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.

@gdarquie
Copy link

I can not wait to see this PR published, thanks @arti0090 and all reviewers ;-)

@lchrusciel lchrusciel changed the base branch from master to 1.9 May 28, 2021 09:10
@lchrusciel lchrusciel changed the base branch from 1.9 to master May 28, 2021 09:10
Comment on lines +50 to +54
# 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
Copy link
Member

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"

@lchrusciel lchrusciel added Bug Docker Docker-related issues and PRs. Maintenance labels May 28, 2021
@lchrusciel lchrusciel merged commit ba244da into Sylius:master May 28, 2021
@lchrusciel
Copy link
Member

Thank you, @arti0090! 🎉

@lchrusciel
Copy link
Member

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.

@3kynox
Copy link

3kynox commented May 31, 2021

Hello, could it be simply updated to PHP8, as Sylius 1.10 brings it? Any love to Kubernetes as well could be planned / provided?

@tonicospinelli
Copy link

@lchrusciel I add some adjusts to increase the development experience over docker. Take a look on #568 when you have time 🤗

@vasilvestre vasilvestre mentioned this pull request Aug 13, 2021
@vasilvestre
Copy link
Contributor

Hello, could it be simply updated to PHP8, as Sylius 1.10 brings it? Any love to Kubernetes as well could be planned/provided?

I would like PHP 8 too, maybe we could create two tags: PHP 7.4 and 8.0 ?
So people could pick the version they need

Comment on lines +13 to +14
fastcgi_pass $backendfpm;
# Comment the next line and uncomment the next to enable dynamic resolution (incompatible with Kubernetes);
Copy link
Contributor

Choose a reason for hiding this comment

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

Aren't they inversed ?

Zales0123 added a commit that referenced this pull request Sep 16, 2021
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
windragon0910 added a commit to windragon0910/symfony_ecom_framework that referenced this pull request Oct 25, 2023
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Docker Docker-related issues and PRs. Maintenance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants