diff --git a/Makefile b/Makefile index e897613..c7a2547 100755 --- a/Makefile +++ b/Makefile @@ -1,3 +1,12 @@ +# If the first argument is ... +ifeq (tools_vscode,$(firstword $(MAKECMDGOALS))) + # use the rest as arguments + RUN_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) + # ...and turn them into do-nothing targets + #$(eval $(RUN_ARGS):;@:) +endif + + .PHONY: help help: ## This help. @@ -66,10 +75,6 @@ nvidia_ros_indigo_cuda10_cudnn7_opencv3: nvidia_ros_indigo_cuda10_cudnn7 ## [NVI docker build -t turlucode/ros-indigo:cuda10-cudnn7-opencv3 nvidia/indigo/cuda10/cudnn7/opencv3 @printf "\n\033[92mDocker Image: turlucode/ros-indigo:cuda10-cudnn7-opencv3\033[0m\n" -nvidia_ros_indigo_cuda10_cudnn7_opencv3_vscode: nvidia_ros_indigo_cuda10_cudnn7 ## [NVIDIA] Build ROS Indigo Container | (CUDA 10 - cuDNN 7) | OpenCV 3.4.7 | VS Code - docker build -t turlucode/ros-indigo:cuda10-cudnn7-opencv3-vscode nvidia/indigo/cuda10/cudnn7/opencv3/vscode - @printf "\n\033[92mDocker Image: turlucode/ros-indigo:cuda10-cudnn7-opencv3-vscode\033[0m\n" - nvidia_ros_indigo_cuda10-1_cudnn7_opencv3: nvidia_ros_indigo_cuda10-1_cudnn7 ## [NVIDIA] Build ROS Indigo Container | (CUDA 10.1 - cuDNN 7) | OpenCV 3.4.7 docker build -t turlucode/ros-indigo:cuda10.1-cudnn7-opencv3 nvidia/indigo/cuda10.1/cudnn7/opencv3 @printf "\n\033[92mDocker Image: turlucode/ros-indigo:cuda10.1-cudnn7-opencv3\033[0m\n" @@ -167,3 +172,9 @@ cpu_ros_melodic: ## [CPU] Build ROS Melodic Container ## Helper TASKS cpu_run_help: ## [CPU] Prints help and hints on how to run an [CPU]-based image @printf "\nCommand example:\ndocker run --rm -it --runtime=nvidia --privileged --net=host --ipc=host \\ \n--device=/dev/dri:/dev/dri \\ \n-v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY \\ \n-v $HOME/.Xauthority:/root/.Xauthority -e XAUTHORITY=/root/.Xauthority \\ \n-v :/root/catkin_ws \\ \n-e ROS_IP= \\ \nturlucode/ros-indigo:cpu\n" + +# TOOLS + +tools_vscode: ## [Tools] Create a new image that contains Visual Studio Code. Use it as "make tools_vscode ". + docker build --build-arg="ARG_FROM=$(RUN_ARGS)" -t $(RUN_ARGS)-vscode tools/vscode + @printf "\033[92mDocker Image: $(RUN_ARGS)-vscode\033[0m\n" \ No newline at end of file diff --git a/Readme.md b/Readme.md index 170c7a6..9c266e4 100644 --- a/Readme.md +++ b/Readme.md @@ -247,6 +247,40 @@ If you have a virtual device node like `/dev/video0`, e.g. a compatible usb came ```` --device /dev/video0 ```` +# Tools + +# Visual Studio Code + +You can have the option to create a new container that contais [Visual Studio Code](https://code.visualstudio.com/). This allows to use Visual Studio Code wihtin the ROS docker image and in turn use it for development and debugging. + +## Create image + +To create the new image run: +```sh +make tools_vscode + +# E.g. +make tools_vscode turlucode/ros-indigo:cuda10.1-cudnn7-opencv3 +# which creates the image turlucode/ros-indigo:cuda10.1-cudnn7-opencv3-vscode +``` + +This will create a new docker image that uses as base `` with the name `-vscode`. If the image doesn't exist, the command will terminate with an error, so make sure you build the ros-docker-image first, before you use it as a base-image to install Visual Studio Code. + +## Run image + +You can run the newly created image as you were running the rest of the ROS images. If you want to keep the Visual Studio Code configuration consistent then you need to mount `.vscode`, e.g.: + +```sh +# Mount argument for the docker run command: +- v :/home/$(id -un)/.vscode +``` + +If you are running the images as `root` then you need to follow the Visual Studio Code recommendations, which state: +``` +You are trying to start vscode as a super user which is not recommended. If you really want to, you must specify an alternate user data directory using the --user-data-dir argument. +``` + +So act accordingly. # Base images diff --git a/tools/vscode/Dockerfile b/tools/vscode/Dockerfile new file mode 100644 index 0000000..cdffa65 --- /dev/null +++ b/tools/vscode/Dockerfile @@ -0,0 +1,15 @@ +ARG ARG_FROM + +FROM $ARG_FROM +MAINTAINER Athanasios Tasoglou + +# Install VS Code +RUN wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | apt-key add - && \ +add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" + +RUN apt-get update && apt-get install -y \ +code && \ +apt-get clean && rm -rf /var/lib/apt/lists/* + +# Launch terminator +CMD ["terminator"] \ No newline at end of file