Skip to content

Run composer install in dev container #738

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Draft
wants to merge 1 commit into
base: 1.x
Choose a base branch
from

Conversation

leonlarsson
Copy link

Today, starting a dev container using curl -s "https://laravel.build/example-app?with=mysql,redis&devcontainer" | bash (or any version with a dev container I assume), it works great. However, if I push that repo to GitHub and clone it back down, the dev container will not start.

That happens because the docker-compose.yml refers to ./vendor, which of course doesn't exist (yet).

I have done some testing on my end, and running this command before creating the dev container ensures that ./vendor/laravel/sail/runtimes/8.3(/Dockerfile) exists before trying to create the container.

The command is from https://laravel.com/docs/11.x/sail#installing-composer-dependencies-for-existing-projects

For this to work, you would need to add the following to the .env file:

WWWGROUP=1000
WWWUSER=1000

This PR, or something like it, aims to make it easier for new developers to get started with the Laravel dev container.

Note: I am completely new to Laravel and somewhat new to Docker. If this is not the fix here, please let me know.

Today, when you start a dev container using `curl -s "https://laravel.build/example-app?with=mysql,redis&devcontainer" | bash` (or any version with a dev container I assume), it works great. However, if I push that repo to GitHub and then clone it back down, the dev container will not start.

That happens because the docker-compose.yml refers to ./vendor, which of course doesn't exist (yet).

I have done some testing on my end, and running this command before creating the dev container ensures that `./vendor/laravel/sail/runtimes/8.3(/Dockerfile)` exists before trying to create the container.

The command is from https://laravel.com/docs/11.x/sail#installing-composer-dependencies-for-existing-projects

For this to work, you would need to add the following to the .env file:
```
WWWGROUP=1000
WWWUSER=1000
```

Note: I am completely new to Laravel and somewhat new to Docker. If this is not the fix here, please let me know.
@leonlarsson
Copy link
Author

leonlarsson commented Oct 10, 2024

Right now the command uses php83. I am not sure how that should be changed or if it can be dynamic.
It could also be commented out initially.

@taylorotwell taylorotwell marked this pull request as draft October 11, 2024 14:28
@martinbean
Copy link

@leonlarsson Does this make dev containers work for Laravel? Because I’ve always liked the thought of using them but could never get them to work, I think because of the issues you describe (you need the Sail package instead by Composer, but you don’t have that package—or any Composer package—installed in a fresh checkout).

@leonlarsson
Copy link
Author

@leonlarsson Does this make dev containers work for Laravel? Because I’ve always liked the thought of using them but could never get them to work, I think because of the issues you describe (you need the Sail package instead by Composer, but you don’t have that package—or any Composer package—installed in a fresh checkout).

Dev containers also work without this, but I believe this makes it significantly more user-friendly. Without this, you would need to run this command manually, outside of the dev container (because the container can only start if it already has Sail under ./vendor).

You could try it locally by adding my addition to your dev container config and see if it helps your workflow

@leonlarsson
Copy link
Author

It seems like there are not a lot of people having the same "issue", so this could probably be closed

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

Successfully merging this pull request may close these issues.

2 participants