iotedgedev icon indicating copy to clipboard operation
iotedgedev copied to clipboard

[FEATURE REQ] Documentation around using the dev conatainer

Open iainwhiteigs opened this issue 11 months ago • 2 comments

Description.

I need some basic help with configuring the dev-container specified here: https://hub.docker.com/_/microsoft-iotedge-iotedgedev

I guess I need to create a .devcontainer/devcontainer.json file but I've attempted this and failed - Just a simple example and guide to setting this up would be very useful. If documentation already exists, please forgive me - but I can't find it.

iainwhiteigs avatar Feb 26 '24 16:02 iainwhiteigs

Please use this quickstart guide to set up the devcontainer https://github.com/Azure/iotedgedev/blob/main/docs/quickstart.md#quickstart-steps

konichi3 avatar Feb 27 '24 19:02 konichi3

Hi, seems we are traveling the same path :). Here is what i have so far, im using a Dockerfile and compose:

.devcontainer/devcontainer.json:

{
	"name": "iotedge-devcontainer",
	"dockerComposeFile": "docker-compose.yml",
	"service": "iotedgedev",
	"workspaceFolder": "/workspaces/edge",

	
	//"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/edge,type=bind,consistency=cached",
	//"image": "mcr.microsoft.com/iotedge/iotedgedev",
	// "runArgs": [
	// 	"-v",
	// 	"/var/run/docker.sock:/var/run/docker.sock" // Without this volume the container would not be able to talk with docker on the host. i.e. "docker container ls will fail"
	// ],
		// Use this environment variable if you need to bind mount your local source code into a new container.
	"remoteEnv": {
		"LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}"
	},
	// "remoteUser": "root", // Default user for when opening a terminal inside the container.
	"customizations": {
		"vscode": {
			"settings": {
				"terminal.integrated.defaultProfile.linux": "bash",
				"terminal.integrated.profiles.linux": {
					"bash": {
						"path": "/bin/bash"
					}
				}
			},
			"extensions": [ // List of extensions to install in the container
				"esbenp.prettier-vscode",
				"ms-dotnettools.csdevkit",
				"ms-dotnettools.csharp",
				"ms-azuretools.vscode-docker"
			]
		}
	},		
	"features": {
		"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
		"ghcr.io/devcontainers/features/dotnet:2": {}
	},
	//"postCreateCommand": "az extension add --name azure-iot"
}

docker-compose.yml

version: '3'

services:
  iotedgedev:
    build: 
      context: .
      dockerfile: Dockerfile
    volumes:
      # # Forwards the local Docker socket to the container [NOT NEEDED AS WE ARE USING DOCKER-OUTSIDE-DOCKER]
      # - /var/run/docker.sock:/var/run/docker-host.sock 
      # Update this to wherever you want VS Code to mount the folder of your project
      - ../:/workspaces/edge:cached
    # # Overrides default command so things don't shut down after the process ends.
    command: /bin/sh -c "while sleep 1000; do :; done"

    # Uncomment the next four lines if you will use a ptrace-based debuggers like C++, Go, and Rust.
    # cap_add:
    #  - SYS_PTRACE
    # security_opt:
    #   - seccomp:unconfined

    # Use "forwardPorts" in **devcontainer.json** to forward an app port locally. 
    # (Adding the "ports" property to this file will not forward from a Codespace.)
volumes:
  cloudedge:
    external: true

Dockerfile

# Note: You can use any Debian/Ubuntu based image you want. 
FROM mcr.microsoft.com/iotedge/iotedgedev:latest as base

# Missing from base imagea
RUN sudo apt-get update && sudo az extension add --name azure-iot

# USER iotedgedev
# USER root

Hope this helps.

They need to clean up a lot of there documentation and this Rep... its a painful journey

RollsChris avatar Mar 08 '24 14:03 RollsChris