Skip to content

Commit 5382297

Browse files
dovvlafiliparag
andauthored
Docker: VS Code server and default setup script (#286)
Co-authored-by: Filip Parag <filip@parag.rs>
1 parent b03b6aa commit 5382297

File tree

6 files changed

+320
-103
lines changed

6 files changed

+320
-103
lines changed

docker/Dockerfile.base

Lines changed: 47 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,37 +13,37 @@ RUN useradd -d /memristor -m \
1313
echo "memristor ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
1414

1515
# Essentials
16-
RUN apt-get update && apt-get install -y -o Dpkg::Options::="--force-overwrite" \
17-
ros-humble-navigation2 \
18-
ros-humble-nav2-bringup \
19-
ros-humble-rviz2 \
20-
ros-humble-teleop-twist-keyboard \
21-
ros-humble-dynamixel-sdk \
22-
ros-humble-can-msgs \
23-
ros-humble-ruckig \
24-
ros-humble-laser-filters \
25-
ros-humble-domain-bridge \
26-
ros-humble-rmw-cyclonedds-cpp \
27-
ros-humble-ros2-control \
28-
ros-humble-ros2-controllers \
29-
ros-humble-rqt-common-plugins \
30-
ros-humble-webots-ros2 \
31-
ros-humble-dynamixel-workbench-toolbox \
32-
ros-humble-behaviortree-cpp \
33-
libopencv-dev \
34-
python3-pip \
35-
python3-pil \
36-
alsa \
37-
libxshmfence1 \
38-
libgtk-3-dev \
39-
git \
40-
git-lfs \
41-
curl \
42-
wget \
43-
vim \
44-
rsync \
45-
dialog \
46-
fish
16+
RUN apt-get update && apt-get install --no-install-recommends -y -o Dpkg::Options::="--force-overwrite" \
17+
ros-humble-navigation2 \
18+
ros-humble-nav2-bringup \
19+
ros-humble-rviz2 \
20+
ros-humble-teleop-twist-keyboard \
21+
ros-humble-dynamixel-sdk \
22+
ros-humble-can-msgs \
23+
ros-humble-ruckig \
24+
ros-humble-laser-filters \
25+
ros-humble-domain-bridge \
26+
ros-humble-rmw-cyclonedds-cpp \
27+
ros-humble-ros2-control \
28+
ros-humble-ros2-controllers \
29+
ros-humble-rqt-common-plugins \
30+
ros-humble-webots-ros2 \
31+
ros-humble-dynamixel-workbench-toolbox \
32+
ros-humble-behaviortree-cpp \
33+
libopencv-dev \
34+
python3-pip \
35+
python3-pil \
36+
alsa \
37+
libxshmfence1 \
38+
libgtk-3-dev \
39+
git \
40+
git-lfs \
41+
curl \
42+
wget \
43+
vim \
44+
rsync \
45+
dialog \
46+
fish
4747

4848

4949

@@ -57,7 +57,19 @@ RUN su memristor -c 'code --install-extension eamodio.gitlens' && \
5757
su memristor -c 'code --install-extension ms-python.python' && \
5858
su memristor -c 'code --install-extension ms-vscode.cpptools-extension-pack' && \
5959
su memristor -c 'code --install-extension usernamehw.errorlens' && \
60-
su memristor -c 'code --install-extension redhat.vscode-xml'
60+
su memristor -c 'code --install-extension redhat.vscode-xml' && \
61+
su memristor -c 'code --install-extension ms-iot.vscode-ros'
62+
63+
64+
65+
# VS Code server
66+
RUN su memristor -c 'curl -fsSL https://code-server.dev/install.sh | sh' && \
67+
su memristor -c 'code-server --install-extension eamodio.gitlens' && \
68+
su memristor -c 'code-server --install-extension ms-python.python' && \
69+
su memristor -c 'code-server --install-extension ms-vscode.cpptools-extension-pack' && \
70+
su memristor -c 'code-server --install-extension usernamehw.errorlens' && \
71+
su memristor -c 'code-server --install-extension redhat.vscode-xml' && \
72+
su memristor -c 'code-server --install-extension ms-iot.vscode-ros'
6173

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

89102
USER memristor
90103
WORKDIR /memristor/ros2_ws
104+
105+
EXPOSE 31415

docker/Makefile

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ IMAGE=ghcr.io/memristor/mep3
77

88
.PHONY: all
99

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

1212
vnc:
1313
$(eval FLAVOR=vnc)
1414
$(eval IMAGE=ghcr.io/memristor/mep3-vnc)
1515
@true
1616

1717
run:
18+
@${MAKE} -s test-nvidia
1819
@docker run \
1920
--net=host \
2021
--ipc=host \
@@ -31,14 +32,40 @@ run:
3132
-v ${PROJECT_DIR}:/memristor/ros2_ws/src/mep3:rw \
3233
-d -it ${IMAGE}
3334

35+
test-nvidia:
36+
$(eval NC=\033[1;0m)
37+
$(eval RED=\033[1;31m)
38+
$(eval GREEN=\033[1;32m)
39+
40+
@lspci | grep -qi nvidia && base64 --decode massage | unxz || true
41+
42+
@docker run --rm \
43+
-e NVIDIA_DRIVER_CAPABILITIES=all ${NVIDIA_GPU} \
44+
-e DISPLAY=${DISPLAY} \
45+
${IMAGE} | grep -qi 'nvidia' && \
46+
printf '%b\n' "${RED}Detected NVIDIA GPU in system, but missing packets, look up NVIDIA GPU section in README!\n${NC}" || \
47+
printf '%b\n' "${GREEN}Everything set up!${NC}"
48+
49+
start-code-server:
50+
@docker exec -d -it mep3-${FLAVOR} bash -c 'pgrep code-server || code-server /memristor/ros2_ws/src/mep3' && \
51+
xdg-open 'localhost:31415?folder=/memristor/ros2_ws/src/mep3'
52+
53+
stop-code-server:
54+
@docker exec -it mep3-${FLAVOR} pkill -f code-server
55+
3456
exec:
3557
@docker exec -it mep3-${FLAVOR} bash
3658

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

41-
setup:
42-
@docker exec -it mep3-${FLAVOR} /usr/bin/setup.sh
63+
setup-default:
64+
@docker exec -it mep3-${FLAVOR} sh -c '/usr/bin/setup.sh --all'
65+
@echo 'Restarting mep3-${FLAVOR} container...'
66+
@docker restart mep3-${FLAVOR}
67+
68+
setup-interactive:
69+
@docker exec -it mep3-${FLAVOR} sh -c '/usr/bin/setup.sh --all --interactive'
4370
@echo 'Restarting mep3-${FLAVOR} container...'
4471
@docker restart mep3-${FLAVOR}

docker/README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,29 @@
2525

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

39+
40+
## Code Server
41+
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`
42+
43+
```sh
44+
# This will start the VS code server with your mep3 repo
45+
make start-code-server
46+
47+
# To stop the VS code server
48+
make stop-code-server
49+
```
50+
3651
## Remote development environment (VNC)
3752

3853

@@ -48,3 +63,7 @@ and set `DISPLAY` environment variable on step 4 to its value (eg `:0`).
4863
```sh
4964
export DISPLAY=:0
5065
```
66+
67+
## NVIDIA GPU
68+
If you happen to have NVIDIA GPUs that you wish to use within these development environments, make sure
69+
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).

0 commit comments

Comments
 (0)