Skip to content

Instantly share code, notes, and snippets.

@rachelslurs
Last active January 26, 2021 23:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rachelslurs/76b61388d3f04dcb9fea1674a905df43 to your computer and use it in GitHub Desktop.
Save rachelslurs/76b61388d3f04dcb9fea1674a905df43 to your computer and use it in GitHub Desktop.
How to setup devcontainer in vscode for dashboard

Benefits

  • Run eslint in the docker container
  • Run jest in the docker container (and get updates when snapshots change)
  • Much more, share your tips!

Instructions adapted from here

  1. Install Remote development extension pack
  2. In VSCode, control+shift+p, Remote-Containers: Add Development Container Configuration Files. Choose From 'docker-compose.yml'. This should create a folder .devcontainer which is .gitignored.
  3. Edit the .devcontainer/devcontainer.json file. Ensuring a few different settings:
"dockerComposeFile": [
	"../docker-compose.yml",
	"docker-compose.yml"
],
  
"service": "dashboard",

"workspaceFolder": "/usr/src/app",
// Set *default* container specific settings.json values on container create.
"settings": {
	"eslint.debug": true,
	"eslint.alwaysShowStatus": true,
	"eslint.lintTask.enable": true,
	"eslint.format.enable": true,
	"eslint.validate": [
		"javascript",
		"javascriptreact"
	],
	"eslint.codeAction.showDocumentation": {
		"enable": true
	}
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
	"dbaeumer.vscode-eslint",
	"orta.vscode-jest"
],
  
  "forwardPorts": [5000]
  1. Then, in the .devcontainer/docker-compose.yml file, the main thing is you'll want to ensure is:
services:
  # Update this to the name of the service you want to work with in your docker-compose.yml file
  dashboard:
  1. control+shift+p, Remote-Containers: Rebuild and Reopen in Container. 🎉 Now you can run eslint fix commands using control+shift+p.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment