-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Laradock integration with VSCode Remote Development #2248
Comments
I have a working // For format details, see https://aka.ms/vscode-remote/devcontainer.json or the definition README at
// https://github.com/microsoft/vscode-dev-containers/tree/master/containers/docker-existing-docker-compose
{
// See https://aka.ms/vscode-remote/devcontainer.json for format details.
"name": "Existing Docker Compose (Extend)",
// Update the 'dockerComposeFile' list if you have more compose files or use different names.
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
"dockerComposeFile": [
"../../laradock/docker-compose.yml"
],
// The 'service' property is the name of the service for the container that VS Code should
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
"service": "workspace",
// The optional 'workspaceFolder' property is the path VS Code should open by default when
// connected. This is typically a file mount in .devcontainer/docker-compose.yml
"workspaceFolder": "/var/www/first-project",
// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
// "shutdownAction": "none",
// Uncomment the next line if you want to add in default container specific settings.json values
// "settings": { "workbench.colorTheme": "Quiet Light" },
// Uncomment the next line to run commands after the container is created - for example installing git.
// "postCreateCommand": "apt-get update && apt-get install -y git",
// Add the IDs of any extensions you want installed in the array below.
"extensions": [
"onecentlin.laravel-blade",
"felixfbecker.php-intellisense",
"amiralizadeh9480.laravel-extra-intellisense",
"fterrag.vscode-php-cs-fixer"
]
} Be sure to make the following path point to your Laradock "dockerComposeFile": [
"../../laradock/docker-compose.yml"
], Also make sure that the following path is pointing to the folder of the project you want to work on this is the path inside of the "workspaceFolder": "/var/www/first-project", You're also free to add and remove extensions from:
note: this |
Thanks @boumanb your snippet works like a charm. Cheers. |
@boumanb Thank your very much. I have also been using this configuration for a few weeks now and it really brings development to a new level! One thing I would like to achieve to improve my workflow even more, is to automatically start the dev containers, if they are not running already. I think my configuration should actually work, but the problem is that the command you see in the picture fails. It fails, because somehow the env variables are not present when this command is run from a different location than the laradock directory itself. So how can I provide the .env file to the devcontainer? I know this is probably not the best place to ask, because it is rather a configuration of the vscode remote containers extension, but maybe you know how to solve this issue. Edit: I got from the extension's docs that I can append run arguments, but this does not help, because for the above command these are not applied. It bascially what is discsussed here. So docker-compose uses the env. file from the executing context instead of the location where the compose file lives. It looks it has not been solved and the solution would be to copy the env file to the projects folders, which is definitely not what I want. |
@MannikJ , have you tried the sample configuration now shipped with laradock? https://github.com/laradock/laradock/blob/master/.devcontainer/devcontainer.example.json Just go to folder |
Hey, as I tried to explain, I have a working configuration. At least when the containers are running before I connect via remote container extension. {
"name": "Laradock",
"dockerComposeFile": [
"../../laradock/docker-compose.yml"
],
"runArgs": ["--env-file", "../../laradock/.env"],
"service": "workspace",
"workspaceFolder": "/var/www/projectA",
"extensions": [
"dotjoshjohnson.xml",
"ryu1kn.partial-diff",
"artdiniz.quitcontrol-vscode",
"emallin.phpunit",
"eamodio.gitlens",
"octref.vetur",
"eg2.vscode-npm-script",
"sasa.vscode-sass-format",
"onecentlin.laravel-extension-pack",
"bmewburn.vscode-intelephense-client",
"amiralizadeh9480.laravel-extra-intellisense",
"fterrag.vscode-php-cs-fixer"
],
"remoteUser": "laradock",
"shutdownAction": "none",
"runServices": ["mysql", "redis", "nginx"],
}
From the default configuration it looks like the docker-composer file is located in the project directory (one level up from devcontainer.json) which I don't quite understand. |
@MannikJ , the trick here, assuming you have a |
Ok, I understand that. But the point is still my scenario is different. My laradock folder is not in the project directory but one level up like the laradock docs propose for a multi project setup. |
Hi @MannikJ, No problem. I found your request interesting and played with it all day, never ran into this since my containers are always up. To my surprise, it's very confusing. My setup (tried to replicate yours based on your comments, please say so if I'm wrong): What I've found out:
So besides from placing the Laradock
*The default .env file is picked up from the root of the project, but you can use env_file in your Docker Compose file to specify an alternate location. |
This is just to keep track of what's needed to have laradock workspace container properly supported in Visual Studio Code Remote Development (Containers).
Current pending issues from VSCode side (please add more, if needed):
[Dev Container] allow passing another user to "docker-compose exec" command when connecting to a container - [Dev Container] allow passing another user to "docker-compose exec" command when connecting to a container microsoft/vscode-remote-release#538Open folder in container starts all compose services - Open folder in container starts all compose services microsoft/vscode-remote-release#211Once theses issues are addressed, it would be interesting if laradock provides an example
devcontainer.json
configuration to make VSCode attach to laradock workspace container.The text was updated successfully, but these errors were encountered: