Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 26 additions & 31 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,49 +1,44 @@
ARG BASE_IMAGE=ros:humble
ARG BASE_IMAGE=lcas.lincoln.ac.uk/lcas/limo_platform:2

FROM ${BASE_IMAGE} as base

Check warning on line 3 in .devcontainer/Dockerfile

View workflow job for this annotation

GitHub Actions / build-docker-image

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

USER root

ENV DEBIAN_FRONTEND=noninteractive
# making the standard global variables available for target-specific builds
ARG TARGETARCH

RUN apt-get update \
&& apt-get install -qq -y --no-install-recommends \
git \
python3-pip \
python3-rosdep \
ros-humble-rviz2 \
ros-humble-gazebo-plugins \
zenoh-bridge-ros2dds
USER root

# get the source tree and analyse it for its package.xml only
FROM base as sourcefilter

Check warning on line 11 in .devcontainer/Dockerfile

View workflow job for this annotation

GitHub Actions / build-docker-image

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/
COPY ./src /tmp/src
RUN mkdir -p /tmp/src/
COPY ./src/*/package.xml /tmp/src/_workspace/src/_pkgs_xmls
COPY ./src/*/*/package.xml /tmp/src/_workspace/src/_pkgs_xmls
COPY ./src/*/*/*/package.xml /tmp/src/_workspace/src/_pkgs_xmls
COPY ./src/*/*/*/*/package.xml /tmp/src/_workspace/src/_pkgs_xmls

# remove everything that isn't package.xml
RUN find /tmp/src -type f \! -name "package.xml" -print | xargs rm -rf

# install all dependencies listed in the package.xml
FROM base as depbuilder
FROM base as devcontainer

Check warning on line 22 in .devcontainer/Dockerfile

View workflow job for this annotation

GitHub Actions / build-docker-image

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/
# copy the reduced source tree (only package.xml) from previous stage
COPY --from=sourcefilter /tmp/src /tmp/src
RUN rosdep update && apt-get update
RUN cd /tmp/src && rosdep install --from-paths . --ignore-src -r -y && cd && rm -rf /tmp/src
RUN rosdep update --rosdistro=${ROS_DISTRO} && apt-get update
RUN . /opt/ros/lcas/install/setup.sh && rosdep install --from-paths /tmp/src --ignore-src -y && rm -rf /tmp/src && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/src

FROM depbuilder as final
# add user ros with sudo rights if it doesn't exist
RUN if ! id ros; then \
useradd -ms /bin/bash ros && echo "ros:ros" | chpasswd && adduser ros sudo; \
echo "ALL ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers; \
echo "source /opt/ros/humble/setup.bash" >> /etc/bash.bashrc; \
else echo "user ros already exists"; \
fi

# add sudo without password
ENV DEBIAN_FRONTEND=noninteractive
FROM devcontainer as compiled

Check warning on line 29 in .devcontainer/Dockerfile

View workflow job for this annotation

GitHub Actions / build-docker-image

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

# add commit history to bust cache if and when needed.
ADD "https://api.github.com/repos/LCAS/limo_ros2/commits?per_page=1&sha=humble" .lcas_addons.limo_ros2.commits
COPY ./src /opt/ros/lcas/src/workspace/src
RUN . /opt/ros/lcas/install/setup.sh && \
apt update && \
rosdep --rosdistro=${ROS_DISTRO} update && \
rosdep install --from-paths /opt/ros/lcas/src/workspace/src --ignore-src -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

COPY .devcontainer/*repos .devcontainer/*.sh /tmp/.devcontainer/
RUN bash /tmp/.devcontainer/install.sh
RUN cd /opt/ros/lcas && colcon build && \
rm -rf /opt/ros/lcas/src/ /opt/ros/lcas/build/ /opt/ros/lcas/log/

USER ros
USER ros
WORKDIR /home/ros
ENV SHELL=/bin/bash
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu
{
"name": "L-CAS Humble CUDA-OpenGL ROB2002 Devcontainer",
"image": "lcas.lincoln.ac.uk/devcontainer/lcas/rob2002:cuda-opengl-deployment",
//"build": {
// "dockerfile": "../Dockerfile",
// "args": {
// "BASE_IMAGE": "lcas.lincoln.ac.uk/lcas/ros:jammy-humble-cuda12.2-opengl"
// },
// "context": "../.."
//},
"name": "L-CAS Humble Robotics Teaching Devcontainer",
// Use the below image to not build locally (pushed by GitHub Action)
// disable the "build" section below in this case
//"image": "lcas.lincoln.ac.uk/devcontainer/lcas/cmp9767",
"build": {
"dockerfile": "./Dockerfile",
"args": {
"BASE_IMAGE": "lcas.lincoln.ac.uk/lcas/limo_platform:2.2"
},
"context": ".."
},

// forward the virtual desktop port
"forwardPorts": [5801],
"portsAttributes": {
"5801": {
Expand Down Expand Up @@ -44,4 +47,4 @@
"cpus": 2,
"memory": "6gb"
}
}
}
19 changes: 0 additions & 19 deletions .devcontainer/install.sh

This file was deleted.

6 changes: 0 additions & 6 deletions .devcontainer/lcas.repos

This file was deleted.

31 changes: 23 additions & 8 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
#!/bin/bash

# source additional packages
set -xe


function add_config_if_not_exist {
if ! grep -F -q "$1" $HOME/.bashrc; then
echo "$1" >> $HOME/.bashrc
fi
}

add_config_if_not_exist "source /opt/ros/humble/setup.bash"
add_config_if_not_exist "source /opt/ros/lcas/install/setup.bash"

# you may add some aliases here
#add_config_if_not_exist "alias rviz_sensors='rviz2 -d /opt/ros/lcas/install/limo_description/share/limo_description/rviz/model_sensors_real.rviz'"
#add_config_if_not_exist "alias tidybot_sim='ros2 launch uol_tidybot tidybot.launch.py'"

source /opt/ros/humble/setup.bash
source /opt/ros/lcas/install/setup.bash

# ensure students always have the latest index of everything
sudo apt update
rosdep --rosdistro=humble update
colcon build --symlink-install --continue-on-error || true

LOCAL_SETUP_FILE=`pwd`/install/setup.bash
add_config_if_not_exist "if [ -r $LOCAL_SETUP_FILE ]; then source $LOCAL_SETUP_FILE; fi"

# ensure the additional packages are always sources:
if ! grep -q "source /opt/ros/lcas/install/setup.bash" ~/.bashrc; then
echo "source /opt/ros/lcas/install/setup.bash" >> ~/.bashrc
fi
sleep 10
DISPLAY=:1 xfconf-query -c xfce4-desktop -p $(xfconf-query -c xfce4-desktop -l | grep "workspace0/last-image") -s /usr/share/backgrounds/xfce/lcas.jpg || true
68 changes: 68 additions & 0 deletions .github/workflows/container-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@

name: Build Docker image

on:
workflow_dispatch:
push:
branches: [ main ]
tags:
- 'v*'
pull_request:
branches: [ main ]

jobs:
build-docker-image:
if: github.repository_owner == 'LCAS'
runs-on:
- lcas
- qemu
steps:
- name: Node Js
uses: actions/setup-node@v4

- uses: actions/checkout@v3
with:
fetch-depth: 1
submodules: 'recursive'

- name: What
run: echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV

- name: Docker Login LCAS
uses: docker/login-action@v3
with:
registry: lcas.lincoln.ac.uk
username: ${{ secrets.LCAS_REGISTRY_PUSHER }}
password: ${{ secrets.LCAS_REGISTRY_TOKEN }}

- name: "image name from repo name"
id: docker_image_name
run: echo "docker_image=${{ github.repository }}" | tr '[:upper:]' '[:lower:]' |sed 's/[^0-9,a-z,A-Z,=,_,\/]/-/g' >>${GITHUB_OUTPUT}

- name: Docker meta
id: meta_public
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: lcas.lincoln.ac.uk/${{ steps.docker_image_name.outputs.docker_image }}
# generate Docker tags based on the following events/attributes
tags: |
type=raw,value=staging
type=ref,enable=${{ github.event_name != 'pull_request' }},event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}

- name: Build Public Docker Image
uses: docker/build-push-action@v6
with:
context: .
file: .devcontainer/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
cache-from: type=registry,ref=lcas.lincoln.ac.uk/cache/${{ steps.docker_image_name.outputs.docker_image }}:latest
cache-to: type=registry,ref=lcas.lincoln.ac.uk/cache/${{ steps.docker_image_name.outputs.docker_image }}:latest,mode=max
tags: ${{ steps.meta_public.outputs.tags }}
labels: ${{ steps.meta_public.outputs.labels }}
build-args: |
BASE_IMAGE=lcas.lincoln.ac.uk/lcas/limo_platform:2.2
33 changes: 17 additions & 16 deletions .github/workflows/dev-container.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
name: 'devcontainer CI'
on:
workflow_dispatch:
pull_request:
branches:
- main
push:
branches:
- main
tags:
- '*'


jobs:
build_devcontainer:
runs-on: ubuntu-latest
strategy:
matrix:
config:
- cuda-opengl
build:
runs-on: lcas
steps:
- name: Checkout from github
uses: actions/checkout@v3
- name: extract the github reference
- name: Node Js
uses: actions/setup-node@v4
with:
node-version: "^16.13.0 || >=18.0.0"
- name: Checkout (GitHub)
uses: actions/checkout@v4
with:
fetch-depth: 1
submodules: 'recursive'
- name: What
run: echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV
- name: "image name from repo name"
id: docker_image_name
run: echo "docker_image=${{ github.repository }}" | tr '[:upper:]' '[:lower:]' |sed 's/[^0-9,a-z,A-Z,=,_,\/]/-/g' >>${GITHUB_OUTPUT}
- name: Build dev container task
- name: Build container
uses: devcontainers/ci@v0.3
with:
imageName: lcas.lincoln.ac.uk/devcontainer/${{ steps.docker_image_name.outputs.docker_image }}
configFile: ./.devcontainer/${{ matrix.config }}/devcontainer.json
push: never
imageTag: ${{ matrix.config }}-${{ env.BRANCH }}
#runCmd: "bash .devcontainer/run-ci.sh"
imageTag: ci
#runCmd: "bash .devcontainer/run-ci.sh"
70 changes: 0 additions & 70 deletions .github/workflows/ros-ci.yml

This file was deleted.

Loading