Skip to content
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

Wiki: Using with VS Code and Remote-Containers #26

Closed
SebastianGrans opened this issue Apr 13, 2021 · 2 comments
Closed

Wiki: Using with VS Code and Remote-Containers #26

SebastianGrans opened this issue Apr 13, 2021 · 2 comments
Labels
documentation 📖 Improvements or additions to documentation

Comments

@SebastianGrans
Copy link

SebastianGrans commented Apr 13, 2021

I use your images with VS Code and the Remote-Containers add-on. This requires some setup which includes a devcontainer.json file to specify the run command. I thought that someone else might find this useful, so here's a short instruction that you could add to the wiki pages.

I've also added the functionality of having the Blender configuration persist between runs.

Cheers :)

Instructions

  1. Create a project folder and open it in VS Code. Add a .devcontainer folder.
  2. Create a devcontainer.json file inside it with the content as shown below.
  3. Also create an empty .config/blender folder.
  4. Execute the container by pressing Ctrl+⇧Shift+P and run the command Remote-Containers: Reopen in Container.
  5. From the integrated terminal, run blender.

Folder structure

This is the folder structure before running the container.

.
├── .devcontainer
│   └── devcontainer.json
│   ├── .config
│   │   └── blender
├── Docker (Not required)
│   └── Dockerfile
Folder structure after execution After running the container once, including running Blender, the folder structure should look something similar to this:
 .
├── blender_file.blend
├── .devcontainer
│   ├── .config
│   │   └── blender
│   │       └── 2.92
│   │           └── config
│   │               ├── platform_support.txt
│   │               ├── recent-files.txt
│   │               └── userpref.blend
│   └── devcontainer.json
├── Docker
│   └── Dockerfile

devcontainer.json

{
	"name": "blender",
	//// Use this if you use a custom image.
	//"build": {
	//	"dockerfile": "../Docker/Dockerfile",
	// },
	// Use this if you only need to run the image directly. 
	"image": "nytimes/blender:latest",
	"settings": {
		"terminal.integrated.shell.linux": "/bin/bash"
	},

	"workspaceMount": "source=${localWorkspaceFolder},target=/root/${localWorkspaceFolderBasename},type=bind", 
	"workspaceFolder": "/root/${localWorkspaceFolderBasename}",
	// We also mount the config folder from the host system. This way, settings 
	// inside the container are kept between runs.
	"mounts": [
		"source=${localWorkspaceFolder}/.devcontainer/.config/blender,target=/root/.config/blender/,type=bind"
	],
	"runArgs": [
		"-it", 
		"--rm", // Removes the container on exit. Remove this if you want the container to keep running.
		"--gpus", "all",
		"-v", "/tmp/.X11-unix:/tmp/.X11-unix:rw", 
		"-v", "/tmp/.docker.xauth:/tmp/.docker.xauth:rw", 
		"-e", "DISPLAY=${localEnv:DISPLAY}", 
		"-e", "XAUTHORITY=/tmp/.docker.xauth", 
		"--device", "/dev/dri/card0:/dev/dri/card0"
	],
	"extensions": []
}

Issues

I've tried doing this is VS Codium (the open source version of VS Code), and I couldn't get it to work.

@juniorxsound juniorxsound added the documentation 📖 Improvements or additions to documentation label Apr 13, 2021
@juniorxsound
Copy link
Contributor

This is great! Thanks for the contribution @SebastianGrans. Added it to the Community Guides section of the wiki

@mikehemberger
Copy link

Hi @SebastianGrans,
I'm intrigued by your post and will dig into it soon. Could you give a brief context on what this can be used for?
All the best,
M

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation 📖 Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants