From 71b117574c1419304d1f8fb25844407b5715fb9b Mon Sep 17 00:00:00 2001 From: Jakub Kaflik Date: Sat, 27 Jul 2024 21:35:46 +0000 Subject: [PATCH] Update devcontainer --- .devcontainer/Dockerfile | 30 ++-------------- .devcontainer/devcontainer.json | 58 +++++++++++++++++++----------- .devcontainer/docker-compose.yaml | 60 ------------------------------- .devcontainer/entrypoint.sh | 15 -------- 4 files changed, 40 insertions(+), 123 deletions(-) delete mode 100644 .devcontainer/docker-compose.yaml delete mode 100644 .devcontainer/entrypoint.sh diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index dc8c573..d6bb1e7 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,5 +1,5 @@ FROM ros:iron -ARG USERNAME=openmower +ARG USERNAME=dev ARG USER_UID=1000 ARG USER_GID=$USER_UID @@ -7,7 +7,7 @@ RUN groupadd --gid $USER_GID $USERNAME \ && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \ && yes $USERNAME | passwd $USERNAME \ && usermod --shell /bin/bash $USERNAME \ - && usermod -aG dialout openmower + && usermod -aG dialout $USERNAME RUN apt-get update \ && apt-get install -y ssh \ @@ -22,29 +22,5 @@ RUN echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ ENV SHELL /bin/bash -RUN mkdir -p /home/ws/build /home/ws/install /home/ws/log \ - && chown -R $USERNAME:$USERNAME /home/ws - -RUN ( \ - echo "source /opt/ros/iron/setup.bash"; \ - echo "source /home/ws/install/setup.bash"; \ - echo "source /home/ws/.devcontainer/openmower_config.env"; \ - echo "export DISPLAY=:0"; \ - ) >> /home/$USERNAME/.bashrc - -RUN ( \ - echo "PasswordAuthentication yes"; \ - echo "PermitRootLogin yes"; \ -) >> /etc/ssh/sshd_config - -RUN sed -i 's/#Port 22/Port 2222/' /etc/ssh/sshd_config -RUN mkdir /run/sshd - -COPY entrypoint.sh /entrypoint.sh -RUN chmod +x /entrypoint.sh - USER $USERNAME - -ENTRYPOINT ["/entrypoint.sh"] - -CMD ["/usr/bin/sudo", "/usr/sbin/sshd", "-D", "-e", "-f", "/etc/ssh/sshd_config"] +CMD ["/bin/bash"] diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index b3b90e3..a9856d9 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,23 +1,39 @@ { - "name": "OpenMowerNext development environment", - "privileged": true, - "remoteUser": "openmower", - "dockerComposeFile": "docker-compose.yaml", - "service": "workspace", - "workspaceFolder": "/home/ws", - "customizations": { - "vscode": { - "extensions":[ - "ms-vscode.cpptools", - "ms-vscode.cpptools-themes", - "twxs.cmake", - "donjayamanne.python-extension-pack", - "eamodio.gitlens", - "ms-iot.vscode-ros", - "ms-vscode.makefile-tools", - "DotJoshJohnson.xml" - ] - } - }, - "containerUser": "openmower" + "name": "OpenMowerNext development environment", + "privileged": true, + "remoteUser": "dev", + "build": { + "dockerfile": "Dockerfile", + "cacheFrom": "ghcr.io/jkaflik/openmowerros2-devcontainer:main", + "args": { + "USERNAME": "dev" + } + }, + "containerUser": "dev", + "workspaceFolder": "/opt/ws", + "workspaceMount": "source=${localWorkspaceFolder},target=/opt/ws,type=bind", + "containerEnv": { + "DISPLAY": ":0", + "ROS_LOCALHOST_ONLY": "1", + "ROS_DOMAIN_ID": "42" + }, + "runArgs": [ + "--net=host", + "-e", "DISPLAY=${env:DISPLAY}" + ], + "customizations": { + "vscode": { + "extensions": [ + "ms-vscode.cpptools", + "ms-vscode.cpptools-themes", + "twxs.cmake", + "donjayamanne.python-extension-pack", + "eamodio.gitlens", + "ms-iot.vscode-ros", + "ms-vscode.makefile-tools", + "DotJoshJohnson.xml" + ] + } + }, + "postCreateCommand": "sudo apt update && rosdep update && make custom-deps deps && sudo chown -R $(whoami) /opt/ws/" } \ No newline at end of file diff --git a/.devcontainer/docker-compose.yaml b/.devcontainer/docker-compose.yaml deleted file mode 100644 index 7f373ba..0000000 --- a/.devcontainer/docker-compose.yaml +++ /dev/null @@ -1,60 +0,0 @@ -version: '2.3' -services: - xserver: - image: devrt/xserver - ipc: host - security_opt: - - seccomp:unconfined - ports: - - "12345:80" - healthcheck: - test: ["CMD-SHELL", "test -e /tmp/.X11-unix/X0"] - interval: "1s" - retries: 20 - workspace: - build: ./ - ipc: host - pid: host - security_opt: - - seccomp:unconfined - cap_add: - - SYS_PTRACE - ports: - - "2222:2222" - - "8765:8765" # Foxglove Studio websocket - - "9002:9002" # Gazebo websocket - volumes: - - ./home:/home/openmower/.openmower - - /opt/ros - - ../:/home/ws - - build:/home/ws/build # keep container pre-build - - install:/home/ws/install # keep container pre-build - - log:/home/ws/log # keep container pre-build - environment: - - DISPLAY=:0 - volumes_from: - - xserver - depends_on: - - xserver - groot: - image: jkaflik/behaviortree-groot:latest - ipc: host - pid: host - security_opt: - - seccomp:unconfined - cap_add: - - SYS_PTRACE - volumes: - - ../:/home/ws - environment: - - DISPLAY=:0 - volumes_from: - - xserver - - workspace - depends_on: - - xserver - - workspace -volumes: - build: - install: - log: \ No newline at end of file diff --git a/.devcontainer/entrypoint.sh b/.devcontainer/entrypoint.sh deleted file mode 100644 index 7464287..0000000 --- a/.devcontainer/entrypoint.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash -set -e - -if [ ! -d "/home/ws" ]; then - echo "ERROR: /home/ws does not exist. Please mount your workspace to /home/ws" - exit 1 -fi - -cd /home/ws - -sudo apt update -rosdep update -make custom-deps deps - -exec "$@"