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
80 changes: 12 additions & 68 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,100 +1,44 @@
ARG BASE_IMAGE=lcas.lincoln.ac.uk/lcas/ros:jammy-humble-cuda12.2-opengl
ARG BASE_IMAGE=lcas.lincoln.ac.uk/lcas/limo_platform_amd64:1

FROM ${BASE_IMAGE} as base

Check warning on line 3 in .devcontainer/Dockerfile

View workflow job for this annotation

GitHub Actions / build-docker-image (lcas.lincoln.ac.uk/lcas/limo_platform_amd64:1, lcas.lincoln.ac.uk/devcontaine...

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/

# making the standard global variables available for target-specific builds
ARG TARGETARCH

USER root

ENV DEBIAN_FRONTEND=noninteractive


RUN echo "building for ${TARGETARCH}"
RUN if [ "${TARGETARCH}" = "arm64" ]; then \
add-apt-repository -s -y ppa:openrobotics/gazebo11-non-amd64; \
fi

RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -qq -y --no-install-recommends \
git \
python3-pip \
python3-rosdep \
python3-matplotlib \
python3-pandas && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# 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 (lcas.lincoln.ac.uk/lcas/limo_platform_amd64:1, lcas.lincoln.ac.uk/devcontaine...

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/_workspace/src
COPY ./.devcontainer/*repos /tmp/.devcontainer/
RUN cd /tmp/src && vcs import < /tmp/.devcontainer/lcas.repos
RUN if [ "${TARGETARCH}" = "arm64" ]; then \
cd /tmp/src; \
vcs import < /tmp/.devcontainer/gazebo_ros_pkgs.repos; \
fi
RUN cd /tmp/src && vcs pull
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 depinstaller
FROM base as devcontainer

Check warning on line 22 in .devcontainer/Dockerfile

View workflow job for this annotation

GitHub Actions / build-docker-image (lcas.lincoln.ac.uk/lcas/limo_platform_amd64:1, lcas.lincoln.ac.uk/devcontaine...

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 --rosdistro=${ROS_DISTRO} && apt-get update
RUN rosdep install --from-paths /tmp/src --ignore-src -r -y && rm -rf /tmp/src && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/src

FROM depinstaller as depbuilder
COPY .devcontainer/*repos .devcontainer/*.sh /tmp/.devcontainer/

# get the source tree and build it (include gazebo only for arm64 platform as it is not available for arm64)
# see https://github.com/gazebosim/gazebo-classic/issues/3236
RUN mkdir -p /opt/ros/lcas/src && \
cd /opt/ros/lcas/src && \
vcs import < /tmp/.devcontainer/lcas.repos
RUN if [ "${TARGETARCH}" = "arm64" ]; then cd /opt/ros/lcas/src; vcs import < /tmp/.devcontainer/gazebo_ros_pkgs.repos; fi
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

RUN . /opt/ros/humble/setup.sh && \
apt update && \
rosdep --rosdistro=${ROS_DISTRO} update && \
cd /opt/ros/lcas/src && \
vcs pull && \
rosdep install --from-paths . -i -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# build the workspace but only until limo_gazebosim to avoid building the hardware specific packages
RUN cd /opt/ros/lcas; colcon build --packages-up-to limo_gazebosim; \
rm -rf /opt/ros/lcas/src/ /opt/ros/lcas/build/ /opt/ros/lcas/log/

FROM depbuilder as devcontainer
# 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
RUN echo "source /opt/ros/lcas/install/setup.bash" >> ~ros/.bashrc

FROM devcontainer as compiled

Check warning on line 29 in .devcontainer/Dockerfile

View workflow job for this annotation

GitHub Actions / build-docker-image (lcas.lincoln.ac.uk/lcas/limo_platform_amd64:1, lcas.lincoln.ac.uk/devcontaine...

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 /opt/ros/lcas/src/teaching-code/src
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/teaching-code/src --ignore-src -y && \
rosdep install --from-paths /opt/ros/lcas/src/workspace/src --ignore-src -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

RUN cd /opt/ros/lcas && colcon build --packages-up-to uol_tidybot_control && \
RUN cd /opt/ros/lcas && colcon build && \
rm -rf /opt/ros/lcas/src/ /opt/ros/lcas/build/ /opt/ros/lcas/log/

RUN echo "source /opt/ros/lcas/install/setup.bash" >> ~/.bashrc
RUN find /opt/ros/lcas/

USER ros
WORKDIR /home/ros
ENV SHELL=/bin/bash
5 changes: 2 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
"dockerfile": "./Dockerfile",
"args": {
// set the base image, add `-arm64` as a suffix if you have an ARM (e.g. Apple Mx) CPU:
"BASE_IMAGE": "lcas.lincoln.ac.uk/lcas/ros:jammy-humble-cuda12.2-opengl"
"BASE_IMAGE": "lcas.lincoln.ac.uk/lcas/limo_platform_amd64:1"
},
// change this to linux/arm64 if you have an ARM (e.g. Apple Mx) CPU:
"platform": "linux/amd64",
"context": "..",
"target": "devcontainer"
"context": ".."
},

// forward the virtual desktop port
Expand Down
6 changes: 0 additions & 6 deletions .devcontainer/gazebo_ros_pkgs.repos

This file was deleted.

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

This file was deleted.

14 changes: 0 additions & 14 deletions .devcontainer/post-create.sh

This file was deleted.

39 changes: 4 additions & 35 deletions .github/workflows/container-build.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,3 @@
# ## Build OpenGL-supported Docker Images

# This GitHub Actions workflow is triggered when there is a push to the `2425-devel` branch or when a tag is created. It also runs when there is a pull request to the `2425-devel` branch.

# ### Jobs

# #### build

# This job runs on the `lcas` runner and defines a matrix strategy to build Docker images for different configurations.

# ##### Matrix Configuration

# The matrix configuration includes the following variables:

# - `base_image`: The base image for the Docker image.
# - `ros_distro`: The ROS (Robot Operating System) distribution.
# - `robot_platform`: The platform for the robot.
# - `push_tag`: The tag to be used when pushing the Docker image.

# ##### Steps

# The steps in the `build` job are as follows:

# 1. Set up Node.js using the `actions/setup-node` action.
# 2. Check out the repository using the `actions/checkout` action.
# 3. Set the `BRANCH` environment variable to the branch name using a shell command.
# 4. Log in to the Docker registry (`lcas.lincoln.ac.uk`) using the `docker/login-action` action. This step is skipped for pull request events.
# 5. Build and push the Docker image using the `docker/build-push-action` action. The Dockerfile is located in the `.devcontainer/docker/ros2` directory. The image is built for the `linux/amd64` platform. The push is only performed for non-pull request events. The tags for the image are determined by the matrix configuration variables.

name: Build Docker image

Expand All @@ -46,8 +18,7 @@ jobs:
fail-fast: false
matrix:
include:
- base_image: lcas.lincoln.ac.uk/lcas/ros:jammy-humble-cuda12.2-opengl-1
ros_distro: humble
- base_image: lcas.lincoln.ac.uk/lcas/limo_platform_amd64:1
push_image: lcas.lincoln.ac.uk/devcontainer/ros2-teaching

steps:
Expand All @@ -59,12 +30,12 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 1
submodules: 'recursive'

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

- name: Docker Login LCAS
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3
with:
registry: lcas.lincoln.ac.uk
Expand Down Expand Up @@ -102,7 +73,6 @@ jobs:
build-args: |
BASE_IMAGE=${{ matrix.base_image }}
BRANCH=${{ env.BRANCH }}
ROS_DISTRO=${{ matrix.ros_distro }}


build-arm-docker-image:
Expand All @@ -114,7 +84,7 @@ jobs:
fail-fast: false
matrix:
include:
- base_image: lcas.lincoln.ac.uk/lcas/ros:jammy-humble-cuda12.2-opengl-arm64-1
- base_image: lcas.lincoln.ac.uk/lcas/limo_platform_arm64:1
ros_distro: humble
push_image: lcas.lincoln.ac.uk/devcontainer/ros2-teaching-arm64

Expand All @@ -127,12 +97,12 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 1
submodules: 'recursive'

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

- name: Docker Login LCAS
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3
with:
registry: lcas.lincoln.ac.uk
Expand Down Expand Up @@ -171,5 +141,4 @@ jobs:
build-args: |
BASE_IMAGE=${{ matrix.base_image }}
BRANCH=${{ env.BRANCH }}
ROS_DISTRO=${{ matrix.ros_distro }}

8 changes: 5 additions & 3 deletions .github/workflows/devcontainer-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ jobs:
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: Build container
if: ${{ github.event_name != 'pull_request' }}
uses: devcontainers/ci@v0.3
with:
imageName: devcontainer/ros2-teaching
imageName: lcas.lincoln.ac.uk/devcontainer/ros2-teaching
push: never
imageTag: ${{ env.BRANCH }}
imageTag: ci
#runCmd: "bash .devcontainer/run-ci.sh"
74 changes: 0 additions & 74 deletions .github/workflows/ros-ci.yml.OFF

This file was deleted.

Loading