Skip to content

Commit

Permalink
Add new tool: vs-code
Browse files Browse the repository at this point in the history
  • Loading branch information
atasoglou committed Jul 31, 2019
1 parent 64dd9ad commit 057932f
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 4 deletions.
19 changes: 15 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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 <PATH_TO_YOUR_CATKIN_WS>:/root/catkin_ws \\ \n-e ROS_IP=<HOST_IP or HOSTNAME> \\ \nturlucode/ros-indigo:cpu\n"

# TOOLS

tools_vscode: ## [Tools] Create a new image that contains Visual Studio Code. Use it as "make tools_vscode <existing_docker_image>".
docker build --build-arg="ARG_FROM=$(RUN_ARGS)" -t $(RUN_ARGS)-vscode tools/vscode
@printf "\033[92mDocker Image: $(RUN_ARGS)-vscode\033[0m\n"
34 changes: 34 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <existing_ros_docker_image>

# 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 `<existing_ros_docker_image>` with the name `<existing_ros_docker_image>-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 <local_path_to_store_configuration>:/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

Expand Down
15 changes: 15 additions & 0 deletions tools/vscode/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ARG ARG_FROM

FROM $ARG_FROM
MAINTAINER Athanasios Tasoglou <[email protected]>

# 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"]

0 comments on commit 057932f

Please sign in to comment.