Skip to content
This repository has been archived by the owner on Jul 16, 2021. It is now read-only.

add native support for dev containers #2660

Open
videlalvaro opened this issue Jul 7, 2021 · 3 comments
Open

add native support for dev containers #2660

videlalvaro opened this issue Jul 7, 2021 · 3 comments

Comments

@videlalvaro
Copy link

Hi everyone,

I'm working with the VS Code & GitHub teams and we like to propose the following idea.

When working in projects that have a complex infrastructure - say a MySQL backend, with Redis for caching - it's hard to get the project started due to infrastructure setup. Thanks to Sail, Laravel addresses most of those problems, making it easy to start new projects. We want to improve that experience even further by enabling the current project setup to “just work” in VS Code.

Imagine opening a folder with a Laravel project and the editor takes care of setting up the environment automatically for the user. Not only on the infrastructure level, but also installing the required editor extensions so the developer can start hacking right away.

By adding a .devcontainer/devcontainer.json file to a project VSCode will detect that the project can be opened inside a container and do all the heavy lifting for the user. This is what such a file looks like:

// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.183.0/containers/docker-existing-docker-compose
// If you want to run as a non-root user in the container, see .devcontainer/docker-compose.yml.
{
	"name": "Existing Docker Compose (Extend)",

	// Update the 'dockerComposeFile' list if you have more compose files or use different names.
	"dockerComposeFile": [
		"../docker-compose.yml"
	],

	// The 'service' property is the name of the service for the container that VS Code should use.
	"service": "laravel.test",

	// The optional 'workspaceFolder' property is the path VS Code should open by default when
	// connected. This is typically a file mount in ../docker-compose.yml
	"workspaceFolder": "/var/www/html",

	// Set *default* container specific settings.json values on container create.
	"settings": {},

	// Add the IDs of extensions you want installed when the container is created.
    // here we could add PHP related extensions that are relevant to laravel.
	"extensions": [
		"mikestead.dotenv", 
		"amiralizadeh9480.laravel-extra-intellisense", 
		"ryannaddy.laravel-artisan", 
		"onecentlin.laravel5-snippets",
		"onecentlin.laravel-blade"
	],

	// Use 'forwardPorts' to make a list of ports inside the container available locally.
	// "forwardPorts": [],

	// Uncomment the next line if you want start specific services in your Docker Compose config.
	// "runServices": [],

	// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
	"shutdownAction": "none",

	// Uncomment the next line to run commands after the container is created - for example installing curl.
	// "postCreateCommand": "apt-get update && apt-get install -y curl",

	// Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root.
	"remoteUser": "sail"
}

With this proposal, we at the VS Code team would like to see how to best integrate a dev container into laravel new, so new projects can benefit from this VS Code feature out of the box.

This will help developers and the community have a standardized way to setup working environments for new projects, so programmers can focus on the programming side without needing to spend so much time solving infrastructure issues. Also, the goal is to follow Laravel's own idiomatic way of doing things, like with sail, using the tools that are already there.

What do you think? How could we help to contribute this .devcontainer.json file to Laravel?

@JustSteveKing
Copy link

Sounds like an awesome idea!

@videlalvaro
Copy link
Author

Here's a sample repo that implements this idea https://github.com/videlalvaro/test-app

@avido
Copy link

avido commented Jul 12, 2021

sounds out a scope to me

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

No branches or pull requests

3 participants