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

WSL2 - Docker can't build PHP container #454

Closed
eyeskiller opened this issue Dec 10, 2020 · 7 comments
Closed

WSL2 - Docker can't build PHP container #454

eyeskiller opened this issue Dec 10, 2020 · 7 comments

Comments

@eyeskiller
Copy link

Hi, I am trying to install Sylius via Docker on WSL2 and I am receiving following error while building PHP container

ERROR: Service 'php' failed to build : COPY failed: stat /var/lib/docker/tmp/docker-builder139509019/composer.lock: no such file or directory

@achref-riahi
Copy link

After the clone of repo, you should run composer install to generate this file (composer.lock) and to download the project Dependencies, But Note, you should run composer with php version 7.3. For example
/usr/bin/php7.3 /usr/bin/composer install
To know your php versions path and the composer path on Linux you can use:
whereis composer and whereis php

good luck!

@HaukeHa
Copy link

HaukeHa commented Dec 29, 2020

But why isn't there a composer.lock to begin with? Shouldn't it be part of this repo? In older Sylius Versions it used to be there

@Cool-and-Deadly
Copy link

Am having the same problem. I would have expected to run composer install from inside the container. Is it true that this should be done from outside?

@eiannone
Copy link

I'm getting the same error. This is due to these lines in Dockerfile:

# prevent the reinstallation of vendors at every changes in the source code
COPY composer.json composer.lock symfony.lock ./
RUN set -eux; \
	composer install --prefer-dist --no-autoloader --no-scripts --no-progress --no-suggest; \
	composer clear-cache

Before running composer install, it is expecting that composer.lock file is already there, so it should be included in the repository. Currently this file is excluded through .gitignore, but there is a pull request (#505) to include it again, as requested in issue #503.

Running composer install, as proposed by @achref-riahi , produces this warning message:
No lock file found. Updating dependencies instead of installing from lock file. Use composer update over composer install if you do not have a lock file.

So in this way it does an update instead of an install.

Anyway, if you exclude composer.lock from copying, Docker will build the image succesfully.

@cristi-contiu
Copy link

cristi-contiu commented May 23, 2021

This error also appears when following the install instructions provided here: https://sylius.com/download/ in the "How to install with Docker" section

ERROR: Service 'php' failed to build: COPY failed: stat /.../composer.lock: no such file or directory

So in order to build the image you need to run composer install, but you may not have PHP & Composer installed locally and rely on Docker to provide them.

Yes, you could manually fiddle with the Dockerfile, remove composer.lock from the COPY command, then run composer install inside the service, then put the composer.lock back in the COPY command and build the image again, but it seems like a little overly-complicated way of setting up the project. Maybe there can be some kind of flag, arg or env var that allows building the image without a composer.lock file?

@tarnawski
Copy link

The proposition of fix in #559

@lchrusciel
Copy link
Member

Should be fixed on master in #536

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants