From 9db277da28e2aeb68ecdddd2516b3d09341be202 Mon Sep 17 00:00:00 2001 From: Jon Azpiazu <jon.azpiazu@tecnalia.com> Date: Mon, 2 Dec 2019 13:41:55 +0100 Subject: [PATCH] Deploy code template as artifact --- .gitlab-ci.yml | 8 +++ vscode_devcontainer/.devcontainer/Dockerfile | 49 +++++++++++++++++++ .../.devcontainer/catkin_ws_init.sh | 33 +++++++++++++ .../.devcontainer/devcontainer.json | 36 ++++++++++++++ vscode_devcontainer/README.md | 3 ++ 5 files changed, 129 insertions(+) create mode 100644 vscode_devcontainer/.devcontainer/Dockerfile create mode 100644 vscode_devcontainer/.devcontainer/catkin_ws_init.sh create mode 100644 vscode_devcontainer/.devcontainer/devcontainer.json create mode 100644 vscode_devcontainer/README.md diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 778ddfd..26831d3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -26,3 +26,11 @@ yamllint: script: yamllint $(find . -name '*.yml' -o -name '*.yaml') tags: - docker + +deploy_devcontainer: + script: + - tar cvfz dot_devcontainer.tar.gz -C vscode_devcontainer .devcontainer/ + artifacts: + paths: + - dot_devcontainer.tar.gz + expire_in: 1 year diff --git a/vscode_devcontainer/.devcontainer/Dockerfile b/vscode_devcontainer/.devcontainer/Dockerfile new file mode 100644 index 0000000..f293099 --- /dev/null +++ b/vscode_devcontainer/.devcontainer/Dockerfile @@ -0,0 +1,49 @@ +#------------------------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. +#------------------------------------------------------------------------------------------------------------- + +FROM tecnalia-robotics-docker.artifact.tecnalia.com/flexbotics-base-devel:kinetic + +# Avoid warnings by switching to noninteractive +ENV DEBIAN_FRONTEND=noninteractive + +# This Dockerfile adds a non-root 'vscode' user with sudo access. However, for Linux, +# this user's GID/UID must match your local user UID/GID to avoid permission issues +# with bind mounts. Update USER_UID / USER_GID if yours is not 1000. See +# https://aka.ms/vscode-remote/containers/non-root-user for details. +ARG USERNAME=vscode +ARG USER_UID=1000 +ARG USER_GID=$USER_UID + +# Configure apt and install packages +RUN apt-get update \ + && apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \ + # + # Verify git, process tools, lsb-release (common in install instructions for CLIs) installed + && apt-get -y install git iproute2 procps lsb-release curl \ + && apt install -y git openssh-client python-catkin-tools \ + # + # Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user. + && groupadd --gid $USER_GID $USERNAME \ + && useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \ + # [Optional] Add sudo support for the non-root user + && apt-get install -y sudo \ + && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\ + && chmod 0440 /etc/sudoers.d/$USERNAME \ + # + && rosdep init || true + +USER $USERNAME +RUN rosdep update \ + && mkdir -p /home/${USERNAME}/robot_ws/src/ + +COPY .devcontainer/catkin_ws_init.sh /tmp/ + + # Clean up + # && apt-get autoremove -y \ + # && apt-get clean -y \ + # && rm -rf /var/lib/apt/lists/* + +# Switch back to dialog for any ad-hoc use of apt-get +ENV DEBIAN_FRONTEND= diff --git a/vscode_devcontainer/.devcontainer/catkin_ws_init.sh b/vscode_devcontainer/.devcontainer/catkin_ws_init.sh new file mode 100644 index 0000000..98e230b --- /dev/null +++ b/vscode_devcontainer/.devcontainer/catkin_ws_init.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +if [[ -z "${ROS_PACKAGE_PATH}" ]]; then + . $(find /opt/ros/ -name "setup.bash") +fi + +if [[ -z "${ROS_DISTRO}" ]]; then + export ROS_DISTRO=$(basename $(find /opt/ros/* -maxdepth 0 -type d | head -1)) +fi + +pkg_name=$(basename $(find /workspaces/ -maxdepth 1 -mindepth 1 -type d)) +mkdir -p ~/robot_ws/src +cd ~/robot_ws/src +ln -s /workspaces/${pkg_name} +cd .. +wstool init src +if [ -f "src/${pkg_name}/.rosinstall" ]; then + wstool merge "src/${pkg_name}/.rosinstall" -t src +fi + +mkdir -p ~/.ssh/ +cat << EOF >> ~/.ssh/config +Host * + StrictHostKeyChecking no +EOF +wstool update -t src +find -L src -name ci_entry_script.bash -exec bash -c 'echo Running entry script from $(basename $(dirname $1)) ; $1 ' _ {} \; +rosdep update +rosdep install --from-paths src --ignore-src --rosdistro $ROS_DISTRO -r -y +catkin init +catkin config --cmake-args -DCMAKE_CXX_FLAGS=-w -- + +echo "source $(find /opt/ros/ -name 'setup.bash')" >> ~/.bashrc diff --git a/vscode_devcontainer/.devcontainer/devcontainer.json b/vscode_devcontainer/.devcontainer/devcontainer.json new file mode 100644 index 0000000..c30b596 --- /dev/null +++ b/vscode_devcontainer/.devcontainer/devcontainer.json @@ -0,0 +1,36 @@ +// For format details, see https://aka.ms/vscode-remote/devcontainer.json +{ + "name": "flexbotics fat kinetic", + "context": "..", + "dockerFile": "Dockerfile", + + // Use 'settings' to set *default* container specific settings.json values on container create. + // You can edit these settings after create using File > Preferences > Settings > Remote. + "settings": { + "terminal.integrated.shell.linux": "/bin/bash" + }, + + // Uncomment the next line if you want to publish any ports. + // "appPort": [], + + // Uncomment the next line to run commands after the container is created. + "postCreateCommand": "bash /tmp/catkin_ws_init.sh", + + "workspaceFolder": "/home/vscode/robot_ws/src/", + + // Uncomment the next line to use a non-root user. On Linux, this will prevent + // new files getting created as root, but you may need to update the USER_UID + // and USER_GID in .devcontainer/Dockerfile to match your user if not 1000. + "runArgs": [ "-u", "vscode", + "-v", "${env:SSH_AUTH_SOCK}:/ssh-agent", + "-e", "SSH_AUTH_SOCK=/ssh-agent", + "-e", "DISPLAY=${env:DISPLAY}", + "-v", "/tmp/.X11-unix:/tmp/.X11-unix" + ], + + // Add the IDs of extensions you want installed when the container is created in the array below. + "extensions": [ + "ms-python.python", + "ms-iot.vscode-ros" + ] +} diff --git a/vscode_devcontainer/README.md b/vscode_devcontainer/README.md new file mode 100644 index 0000000..ff0c679 --- /dev/null +++ b/vscode_devcontainer/README.md @@ -0,0 +1,3 @@ +# vscode_devcontainer + +.devcontainer configuration for ROS projects \ No newline at end of file -- GitLab