Skip to content

Commit

Permalink
Docker: VS Code server and default setup script (#286)
Browse files Browse the repository at this point in the history
Co-authored-by: Filip Parag <[email protected]>
  • Loading branch information
dovvla and filiparag authored Jan 9, 2024
1 parent b03b6aa commit 5382297
Show file tree
Hide file tree
Showing 6 changed files with 320 additions and 103 deletions.
79 changes: 47 additions & 32 deletions docker/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,37 @@ RUN useradd -d /memristor -m \
echo "memristor ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

# Essentials
RUN apt-get update && apt-get install -y -o Dpkg::Options::="--force-overwrite" \
ros-humble-navigation2 \
ros-humble-nav2-bringup \
ros-humble-rviz2 \
ros-humble-teleop-twist-keyboard \
ros-humble-dynamixel-sdk \
ros-humble-can-msgs \
ros-humble-ruckig \
ros-humble-laser-filters \
ros-humble-domain-bridge \
ros-humble-rmw-cyclonedds-cpp \
ros-humble-ros2-control \
ros-humble-ros2-controllers \
ros-humble-rqt-common-plugins \
ros-humble-webots-ros2 \
ros-humble-dynamixel-workbench-toolbox \
ros-humble-behaviortree-cpp \
libopencv-dev \
python3-pip \
python3-pil \
alsa \
libxshmfence1 \
libgtk-3-dev \
git \
git-lfs \
curl \
wget \
vim \
rsync \
dialog \
fish
RUN apt-get update && apt-get install --no-install-recommends -y -o Dpkg::Options::="--force-overwrite" \
ros-humble-navigation2 \
ros-humble-nav2-bringup \
ros-humble-rviz2 \
ros-humble-teleop-twist-keyboard \
ros-humble-dynamixel-sdk \
ros-humble-can-msgs \
ros-humble-ruckig \
ros-humble-laser-filters \
ros-humble-domain-bridge \
ros-humble-rmw-cyclonedds-cpp \
ros-humble-ros2-control \
ros-humble-ros2-controllers \
ros-humble-rqt-common-plugins \
ros-humble-webots-ros2 \
ros-humble-dynamixel-workbench-toolbox \
ros-humble-behaviortree-cpp \
libopencv-dev \
python3-pip \
python3-pil \
alsa \
libxshmfence1 \
libgtk-3-dev \
git \
git-lfs \
curl \
wget \
vim \
rsync \
dialog \
fish



Expand All @@ -57,7 +57,19 @@ RUN su memristor -c 'code --install-extension eamodio.gitlens' && \
su memristor -c 'code --install-extension ms-python.python' && \
su memristor -c 'code --install-extension ms-vscode.cpptools-extension-pack' && \
su memristor -c 'code --install-extension usernamehw.errorlens' && \
su memristor -c 'code --install-extension redhat.vscode-xml'
su memristor -c 'code --install-extension redhat.vscode-xml' && \
su memristor -c 'code --install-extension ms-iot.vscode-ros'



# VS Code server
RUN su memristor -c 'curl -fsSL https://code-server.dev/install.sh | sh' && \
su memristor -c 'code-server --install-extension eamodio.gitlens' && \
su memristor -c 'code-server --install-extension ms-python.python' && \
su memristor -c 'code-server --install-extension ms-vscode.cpptools-extension-pack' && \
su memristor -c 'code-server --install-extension usernamehw.errorlens' && \
su memristor -c 'code-server --install-extension redhat.vscode-xml' && \
su memristor -c 'code-server --install-extension ms-iot.vscode-ros'

# Webots
RUN curl -L -o /tmp/webots.deb \
Expand All @@ -77,6 +89,7 @@ RUN wget -O /tmp/diff_drive_controller.deb http://snapshots.ros.org/humble/2022-
COPY ./config/bashrc /tmp/bashrc
COPY ./config/fish/. /memristor/.config/fish/
COPY ./config/starship.toml /memristor/.config/starship.toml
COPY ./config/vscode-server/config.yaml /memristor/.config/code-server/config.yaml
COPY ./config/vscode/. /memristor/ros2_ws/.vscode/
COPY ./config/Cyberobotics/. /memristor/.config/Cyberbotics/
COPY --chmod=755 ./config/setup.sh /usr/bin/
Expand All @@ -88,3 +101,5 @@ RUN cat /tmp/bashrc >> /memristor/.bashrc && \

USER memristor
WORKDIR /memristor/ros2_ws

EXPOSE 31415
33 changes: 30 additions & 3 deletions docker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ IMAGE=ghcr.io/memristor/mep3

.PHONY: all

all: destroy build run setup exec pull
all: destroy test-nvidia run setup-default exec start-code-server

vnc:
$(eval FLAVOR=vnc)
$(eval IMAGE=ghcr.io/memristor/mep3-vnc)
@true

run:
@${MAKE} -s test-nvidia
@docker run \
--net=host \
--ipc=host \
Expand All @@ -31,14 +32,40 @@ run:
-v ${PROJECT_DIR}:/memristor/ros2_ws/src/mep3:rw \
-d -it ${IMAGE}

test-nvidia:
$(eval NC=\033[1;0m)
$(eval RED=\033[1;31m)
$(eval GREEN=\033[1;32m)

@lspci | grep -qi nvidia && base64 --decode massage | unxz || true

@docker run --rm \
-e NVIDIA_DRIVER_CAPABILITIES=all ${NVIDIA_GPU} \
-e DISPLAY=${DISPLAY} \
${IMAGE} | grep -qi 'nvidia' && \
printf '%b\n' "${RED}Detected NVIDIA GPU in system, but missing packets, look up NVIDIA GPU section in README!\n${NC}" || \
printf '%b\n' "${GREEN}Everything set up!${NC}"

start-code-server:
@docker exec -d -it mep3-${FLAVOR} bash -c 'pgrep code-server || code-server /memristor/ros2_ws/src/mep3' && \
xdg-open 'localhost:31415?folder=/memristor/ros2_ws/src/mep3'

stop-code-server:
@docker exec -it mep3-${FLAVOR} pkill -f code-server

exec:
@docker exec -it mep3-${FLAVOR} bash

destroy:
@docker container kill mep3-${FLAVOR} || true
@docker container rm -f mep3-${FLAVOR} || true

setup:
@docker exec -it mep3-${FLAVOR} /usr/bin/setup.sh
setup-default:
@docker exec -it mep3-${FLAVOR} sh -c '/usr/bin/setup.sh --all'
@echo 'Restarting mep3-${FLAVOR} container...'
@docker restart mep3-${FLAVOR}

setup-interactive:
@docker exec -it mep3-${FLAVOR} sh -c '/usr/bin/setup.sh --all --interactive'
@echo 'Restarting mep3-${FLAVOR} container...'
@docker restart mep3-${FLAVOR}
21 changes: 20 additions & 1 deletion docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,29 @@

5) _Optional:_ run container setup script
```sh
make setup
make setup-default
# If you prefer to manually configure setup, you can just do make setup and go through the prompts
make setup-interactive
```
6) Acces the environment from any terminal window
```sh
docker exec -it mep3-devel bash
```
Graphical applications started inside this terminal will use your existing Xorg session to display.


## Code Server
If you prefer to use browser based VS Code, you can start it in the container and then access it locally through your browser at `localhost:31415`

```sh
# This will start the VS code server with your mep3 repo
make start-code-server
# To stop the VS code server
make stop-code-server
```

## Remote development environment (VNC)


Expand All @@ -48,3 +63,7 @@ and set `DISPLAY` environment variable on step 4 to its value (eg `:0`).
```sh
export DISPLAY=:0
```

## NVIDIA GPU
If you happen to have NVIDIA GPUs that you wish to use within these development environments, make sure
to have NVIDIA Container Toolkit installed on your system. More info, specific to your distribution [here](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html).
Loading

0 comments on commit 5382297

Please sign in to comment.