Closed garrettw closed 1 year ago
Isn't this a duplicate of https://github.com/laravel/sail/issues/541 ?
No, the nature of the error is different, but I can try commenting out the mysql volume and see what it does.
Thank you for reporting this issue!
As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub.
If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team.
Thank you!
Crossposted to Codespaces discussion board. https://github.com/orgs/community/discussions/48069
Laravel sail error for: php artisan sail:install
#0 80.67 Setting up python3.10-minimal (3.10.6-1~22.04.2) ...
#0 81.03 [Errno 13] Permission denied: '/usr/lib/python3.10/__pycache__/__future__.cpython-310.pyc.139764667144704'dpkg: error processing package python3.10-minimal (--configure):
#0 81.03 installed python3.10-minimal package post-installation script subprocess returned error exit status 1
#0 81.47 Errors were encountered while processing:
#0 81.47 python3.10-minimal
#0 81.50 E: Sub-process /usr/bin/dpkg returned an error code (1)
------
I think the first mayor problem is that the docker-compose.yml is referencing a file that is in the vendor folder that doesnt exist yet
context: ./vendor/laravel/sail/runtimes/8.2
In this case the issue is not only codespaces not working. Because the devcontainer is not self-containing. The issue is the same as mentioned in docs if you want to you sail in a project that already exists you need to install sail via composer first if you freshly cloned the project.
That's the same issue that codespaces has.
So the devcontainer should be changed do be self-containing & not rely on any "vendor" stuff that cannot exist if you clone your repository.
First fix could be to publish the runtime images on hub and reference them as image in docker-compose.yaml
instead of building from vendor.
or running
php artisan sail:publish
Anyway... the devcontainer.json
setup is not "newcomer" friendly
@jbreuer95 Good catch!
@ItsReddi Thanks for your insights as well. This was actually a fresh project including Sail, not adding Sail to an existing project, but you are still correct about the rest.
I will see if I can figure out some workaround based on this info.
Hey @garrettw , if you want to install composer dependencies with Docker, while not having composer installed, do this:
docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/app" -w /app composer:2 composer install --ignore-platform-reqs
Also, I'll try to look at your repo, since you left the link 👍
Ok, so a few issues:
php artisan sail:publish
./vendor/bin/sail
. Inside, in its magic, it will figure out what user_id and group_id to use. What I did here was to default in the docker-compose.yml to 1000:1000, since Codespaces is running docker compose up
not by ./vendor/bin/sail up
and its magic.
The thing got working. Kind of. Because then it also needs the other usual steps, like .env
file, composer install
, key:generate
, storage:link
, etc
I've recently contributed an example on Gitpod which is solves the same problem as Codespaces, and I have set it up here: https://github.com/gitpod-samples/template-php-laravel-mysql/blob/main/.gitpod.yml
There is a multitude of things to do to put it to work, and I don't know Codespaces enough to do the other steps right now.
But be assured, there is nothing wrong with the current Sail repo. Wether it has a template ready for Codespaces, it's a separate discussion.
The link I provided should be of guidance. Have a nice one!
Further more, you can have a go in your browser, just by visiting: https://gitpod.io/#https://github.com/gitpod-samples/template-php-laravel-mysql
@garrettw Can you check @ijpatricio's solution? Thanks!
@ijpatricio @nunomaduro The solution that I have settled on for the moment, which seems to work at least well enough to get the containers going, is committing the entire laravel/sail repo into a subfolder in my repo (which required renaming its .git folder to make it work). It's certainly not ideal, but in the future I will probably look into doing what you have done, running composer as a prerequisite, if it is possible/workable with Codespaces.
Ok, so a few issues:
- When the environment starts, it's like starting empty, with the source code of the repo. So, vendor directory is not there. What I did here was to publish sail assets locally:
php artisan sail:publish
- This is not enough, because Sail is expected to be brought up by the executable
./vendor/bin/sail
. Inside, in its magic, it will figure out what user_id and group_id to use. What I did here was to default in the docker-compose.yml to 1000:1000, since Codespaces is runningdocker compose up
not by./vendor/bin/sail up
and its magic.The thing got working. Kind of. Because then it also needs the other usual steps, like
.env
file,composer install
,key:generate
,storage:link
, etc
I've recently contributed an example on Gitpod which is solves the same problem as Codespaces, and I have set it up here: https://github.com/gitpod-samples/template-php-laravel-mysql/blob/main/.gitpod.yml
There is a multitude of things to do to put it to work, and I don't know Codespaces enough to do the other steps right now.
But be assured, there is nothing wrong with the current Sail repo. Wether it has a template ready for Codespaces, it's a separate discussion.
The link I provided should be of guidance. Have a nice one!
I've followed this instructions and added the Laravel magic in .devcontainer/devcontainer.json
:
"postCreateCommand": "chown -R 1000:1000 /var/www/html && cp .env.example .env && composer install && php artisan key:generate && php artisan storage:link --force && php artisan migrate --force --seed && npm install",
"postStartCommand": "npm run dev",
It works !
Woohoo, glad it did!
@Daniel-Mendes awesome! One question though -- do you have it working with the standard docker-compose.yml
that comes with the repo?
@Daniel-Mendes awesome! One question though -- do you have it working with the standard
docker-compose.yml
that comes with the repo?
I had to change vendor/
call to the published version in the repo and changed '${WWWGROUP:-1000}'
docker-compose.yml
version: "3"
services:
laravel.test:
build:
context: ./docker/8.2
dockerfile: Dockerfile
args:
WWWGROUP: "${WWWGROUP:-1000}"
image: sail-8.2/app
extra_hosts:
- "host.docker.internal:host-gateway"
ports:
- "${APP_PORT:-80}:80"
- "${VITE_PORT:-5173}:${VITE_PORT:-5173}"
environment:
WWWUSER: "${WWWUSER:-1000}"
LARAVEL_SAIL: 1
IGNITION_LOCAL_SITES_PATH: "${PWD}"
volumes:
- ".:/var/www/html"
networks:
- sail
depends_on:
- mysql
- phpmyadmin
- redis
- mailpit
- minio
- soketi
mysql:
image: "mysql/mysql-server:8.0"
ports:
- "${FORWARD_DB_PORT:-3306}:3306"
environment:
MYSQL_ROOT_PASSWORD: "${DB_PASSWORD}"
MYSQL_ROOT_HOST: "%"
MYSQL_DATABASE: "${DB_DATABASE}"
MYSQL_USER: "${DB_USERNAME}"
MYSQL_PASSWORD: "${DB_PASSWORD}"
MYSQL_ALLOW_EMPTY_PASSWORD: 1
volumes:
- "sail-mysql:/var/lib/mysql"
- "./docker/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/create-testing-database.sh"
networks:
- sail
healthcheck:
test:
- CMD
- mysqladmin
- ping
- "-p${DB_PASSWORD}"
retries: 3
timeout: 5s
phpmyadmin:
image: "phpmyadmin:latest"
ports:
- 8080:80
networks:
- sail
environment:
PMA_ARBITRARY: 1
redis:
image: "redis:alpine"
ports:
- "${FORWARD_REDIS_PORT:-6379}:6379"
volumes:
- "sail-redis:/data"
networks:
- sail
healthcheck:
test:
- CMD
- redis-cli
- ping
retries: 3
timeout: 5s
mailpit:
image: "axllent/mailpit:latest"
ports:
- "${FORWARD_MAILPIT_PORT:-1025}:1025"
- "${FORWARD_MAILPIT_DASHBOARD_PORT:-8025}:8025"
networks:
- sail
minio:
image: "minio/minio:latest"
ports:
- "${FORWARD_MINIO_PORT:-9000}:9000"
- "${FORWARD_MINIO_CONSOLE_PORT:-8900}:8900"
environment:
MINIO_ROOT_USER: sail
MINIO_ROOT_PASSWORD: password
volumes:
- "sail-minio:/data/minio"
networks:
- sail
command: 'minio server /data/minio --console-address ":8900"'
healthcheck:
test:
- CMD
- curl
- "-f"
- "http://localhost:9000/minio/health/live"
retries: 3
timeout: 5s
soketi:
image: "quay.io/soketi/soketi:latest-16-alpine"
environment:
SOKETI_DEBUG: "${SOKETI_DEBUG:-1}"
SOKETI_METRICS_SERVER_PORT: "9601"
SOKETI_DEFAULT_APP_ID: "${PUSHER_APP_ID}"
SOKETI_DEFAULT_APP_KEY: "${PUSHER_APP_KEY}"
SOKETI_DEFAULT_APP_SECRET: "${PUSHER_APP_SECRET}"
ports:
- "${PUSHER_PORT:-6001}:6001"
- "${PUSHER_METRICS_PORT:-9601}:9601"
networks:
- sail
networks:
sail:
driver: bridge
volumes:
sail-mysql:
driver: local
sail-redis:
driver: local
sail-minio:
driver: local
.devcontainer/devcontainer.json
// https://aka.ms/devcontainer.json
{
"name": "Laravel Sail",
"dockerComposeFile": [
"../docker-compose.yml"
],
"service": "laravel.test",
"workspaceFolder": "/var/www/html",
"customizations": {
"vscode": {
"extensions": [
"onecentlin.laravel-extension-pack",
"Vue.volar",
"nhedger.inertia",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
],
"settings": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"files.autoSave": "onFocusChange",
"[vue]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
}
},
"remoteUser": "sail",
"postCreateCommand": "chown -R 1000:1000 /var/www/html && cp .env.example .env && composer install && php artisan key:generate && php artisan storage:link --force && php artisan migrate --force --seed && npm install",
"postStartCommand": "npm run dev",
"forwardPorts": [
80,
8025,
8080,
6001,
5173,
8900
],
"portsAttributes": {
"80": {
"label": "Application",
"onAutoForward": "notify"
},
"8025": {
"label": "Mailpit"
},
"8080": {
"label": "phpMyAdmin"
},
"5173": {
"label": "Vite (hmr)"
},
"6001": {
"label": "Soketi"
},
"8900": {
"label": "Minio"
}
}
}
@Daniel-Mendes oh ok, so this doesn't change my inclusion of the sail repo inside of my own -- just adds the extra Laravel sprinkles that were missing.
Edit: I did some Googling and I see now what sail:publish
does. As that seems more idiomatic, I'll go that route.
Description:
My repo: https://github.com/garrettw/laravel-skeleton
Not sure if this is the right place to report this bug, but I found someone else that had this error yesterday and they said changing their Dockerfile container config fixed the problem -- so I thought I'd start here and see if anyone knew what part of this setup might be incompatible with Codespaces.
I am trying to create a new codespace based on the devcontainer file that Laravel Sail generated -- I haven't modified the docker-compose file. When I create the codespace, the build fails. Below is the creation log.
I have a hunch as to what might be going on... maybe Codespaces doesn't support multi-container compose files and just wants to throw everything in a single container. Haven't tested this theory yet.Don't think that's it... found evidence around the web of people being able to run multi-container setups. Also I'm seeing something about a docker-in-docker setup... is that the only way to get this working?