Skip to content

Commit e78450e

Browse files
refactor: remove deprecated repository configurations and update base… (#52)
* refactor: remove deprecated repository configurations and update base image in devcontainer * allow push of staging * fix: update base image in container build workflow * fix: remove conditional check for pull request in container build workflow * fix: update image name and tag in devcontainer CI workflow
1 parent 14cebcf commit e78450e

File tree

8 files changed

+23
-208
lines changed

8 files changed

+23
-208
lines changed

.devcontainer/Dockerfile

Lines changed: 12 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG BASE_IMAGE=lcas.lincoln.ac.uk/lcas/ros:jammy-humble-cuda12.2-opengl
1+
ARG BASE_IMAGE=lcas.lincoln.ac.uk/lcas/limo_platform_amd64:1
22

33
FROM ${BASE_IMAGE} as base
44

@@ -7,94 +7,38 @@ ARG TARGETARCH
77

88
USER root
99

10-
ENV DEBIAN_FRONTEND=noninteractive
11-
12-
13-
RUN echo "building for ${TARGETARCH}"
14-
RUN if [ "${TARGETARCH}" = "arm64" ]; then \
15-
add-apt-repository -s -y ppa:openrobotics/gazebo11-non-amd64; \
16-
fi
17-
18-
RUN apt-get update && \
19-
apt-get upgrade -y && \
20-
apt-get install -qq -y --no-install-recommends \
21-
git \
22-
python3-pip \
23-
python3-rosdep \
24-
python3-matplotlib \
25-
python3-pandas && \
26-
apt-get clean && \
27-
rm -rf /var/lib/apt/lists/*
28-
2910
# get the source tree and analyse it for its package.xml only
3011
FROM base as sourcefilter
31-
COPY ./src /tmp/src/_workspace/src
32-
COPY ./.devcontainer/*repos /tmp/.devcontainer/
33-
RUN cd /tmp/src && vcs import < /tmp/.devcontainer/lcas.repos
34-
RUN if [ "${TARGETARCH}" = "arm64" ]; then \
35-
cd /tmp/src; \
36-
vcs import < /tmp/.devcontainer/gazebo_ros_pkgs.repos; \
37-
fi
38-
RUN cd /tmp/src && vcs pull
12+
RUN mkdir -p /tmp/src/
13+
COPY ./src/*/package.xml /tmp/src/_workspace/src/_pkgs_xmls
14+
COPY ./src/*/*/package.xml /tmp/src/_workspace/src/_pkgs_xmls
15+
COPY ./src/*/*/*/package.xml /tmp/src/_workspace/src/_pkgs_xmls
16+
COPY ./src/*/*/*/*/package.xml /tmp/src/_workspace/src/_pkgs_xmls
3917

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

4321
# install all dependencies listed in the package.xml
44-
FROM base as depinstaller
22+
FROM base as devcontainer
4523
# copy the reduced source tree (only package.xml) from previous stage
4624
COPY --from=sourcefilter /tmp/src /tmp/src
4725
RUN rosdep update --rosdistro=${ROS_DISTRO} && apt-get update
48-
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
49-
50-
FROM depinstaller as depbuilder
51-
COPY .devcontainer/*repos .devcontainer/*.sh /tmp/.devcontainer/
52-
53-
# get the source tree and build it (include gazebo only for arm64 platform as it is not available for arm64)
54-
# see https://github.com/gazebosim/gazebo-classic/issues/3236
55-
RUN mkdir -p /opt/ros/lcas/src && \
56-
cd /opt/ros/lcas/src && \
57-
vcs import < /tmp/.devcontainer/lcas.repos
58-
RUN if [ "${TARGETARCH}" = "arm64" ]; then cd /opt/ros/lcas/src; vcs import < /tmp/.devcontainer/gazebo_ros_pkgs.repos; fi
26+
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
5927

60-
RUN . /opt/ros/humble/setup.sh && \
61-
apt update && \
62-
rosdep --rosdistro=${ROS_DISTRO} update && \
63-
cd /opt/ros/lcas/src && \
64-
vcs pull && \
65-
rosdep install --from-paths . -i -y && \
66-
apt-get clean && \
67-
rm -rf /var/lib/apt/lists/*
68-
69-
# build the workspace but only until limo_gazebosim to avoid building the hardware specific packages
70-
RUN cd /opt/ros/lcas; colcon build --packages-up-to limo_gazebosim; \
71-
rm -rf /opt/ros/lcas/src/ /opt/ros/lcas/build/ /opt/ros/lcas/log/
72-
73-
FROM depbuilder as devcontainer
74-
# add user ros with sudo rights if it doesn't exist
75-
RUN if ! id ros; then \
76-
useradd -ms /bin/bash ros && echo "ros:ros" | chpasswd && adduser ros sudo; \
77-
echo "ALL ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers; \
78-
echo "source /opt/ros/humble/setup.bash" >> /etc/bash.bashrc; \
79-
else echo "user ros already exists"; \
80-
fi
81-
RUN echo "source /opt/ros/lcas/install/setup.bash" >> ~ros/.bashrc
8228

8329
FROM devcontainer as compiled
8430

85-
COPY ./src /opt/ros/lcas/src/teaching-code/src
31+
COPY ./src /opt/ros/lcas/src/workspace/src
8632
RUN . /opt/ros/lcas/install/setup.sh && \
8733
apt update && \
8834
rosdep --rosdistro=${ROS_DISTRO} update && \
89-
rosdep install --from-paths /opt/ros/lcas/src/teaching-code/src --ignore-src -y && \
35+
rosdep install --from-paths /opt/ros/lcas/src/workspace/src --ignore-src -y && \
9036
apt-get clean && \
9137
rm -rf /var/lib/apt/lists/*
9238

93-
RUN cd /opt/ros/lcas && colcon build --packages-up-to uol_tidybot_control && \
39+
RUN cd /opt/ros/lcas && colcon build && \
9440
rm -rf /opt/ros/lcas/src/ /opt/ros/lcas/build/ /opt/ros/lcas/log/
9541

96-
RUN echo "source /opt/ros/lcas/install/setup.bash" >> ~/.bashrc
97-
RUN find /opt/ros/lcas/
98-
9942
USER ros
43+
WORKDIR /home/ros
10044
ENV SHELL=/bin/bash

.devcontainer/devcontainer.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@
99
"dockerfile": "./Dockerfile",
1010
"args": {
1111
// set the base image, add `-arm64` as a suffix if you have an ARM (e.g. Apple Mx) CPU:
12-
"BASE_IMAGE": "lcas.lincoln.ac.uk/lcas/ros:jammy-humble-cuda12.2-opengl"
12+
"BASE_IMAGE": "lcas.lincoln.ac.uk/lcas/limo_platform_amd64:1"
1313
},
1414
// change this to linux/arm64 if you have an ARM (e.g. Apple Mx) CPU:
1515
"platform": "linux/amd64",
16-
"context": "..",
17-
"target": "devcontainer"
16+
"context": ".."
1817
},
1918

2019
// forward the virtual desktop port

.devcontainer/gazebo_ros_pkgs.repos

Lines changed: 0 additions & 6 deletions
This file was deleted.

.devcontainer/lcas.repos

Lines changed: 0 additions & 5 deletions
This file was deleted.

.devcontainer/post-create.sh

Lines changed: 0 additions & 14 deletions
This file was deleted.

.github/workflows/container-build.yml

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,3 @@
1-
# ## Build OpenGL-supported Docker Images
2-
3-
# 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.
4-
5-
# ### Jobs
6-
7-
# #### build
8-
9-
# This job runs on the `lcas` runner and defines a matrix strategy to build Docker images for different configurations.
10-
11-
# ##### Matrix Configuration
12-
13-
# The matrix configuration includes the following variables:
14-
15-
# - `base_image`: The base image for the Docker image.
16-
# - `ros_distro`: The ROS (Robot Operating System) distribution.
17-
# - `robot_platform`: The platform for the robot.
18-
# - `push_tag`: The tag to be used when pushing the Docker image.
19-
20-
# ##### Steps
21-
22-
# The steps in the `build` job are as follows:
23-
24-
# 1. Set up Node.js using the `actions/setup-node` action.
25-
# 2. Check out the repository using the `actions/checkout` action.
26-
# 3. Set the `BRANCH` environment variable to the branch name using a shell command.
27-
# 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.
28-
# 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.
291

302
name: Build Docker image
313

@@ -46,8 +18,7 @@ jobs:
4618
fail-fast: false
4719
matrix:
4820
include:
49-
- base_image: lcas.lincoln.ac.uk/lcas/ros:jammy-humble-cuda12.2-opengl-1
50-
ros_distro: humble
21+
- base_image: lcas.lincoln.ac.uk/lcas/limo_platform_amd64:1
5122
push_image: lcas.lincoln.ac.uk/devcontainer/ros2-teaching
5223

5324
steps:
@@ -59,12 +30,12 @@ jobs:
5930
- uses: actions/checkout@v3
6031
with:
6132
fetch-depth: 1
33+
submodules: 'recursive'
6234

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

6638
- name: Docker Login LCAS
67-
if: ${{ github.event_name != 'pull_request' }}
6839
uses: docker/login-action@v3
6940
with:
7041
registry: lcas.lincoln.ac.uk
@@ -102,7 +73,6 @@ jobs:
10273
build-args: |
10374
BASE_IMAGE=${{ matrix.base_image }}
10475
BRANCH=${{ env.BRANCH }}
105-
ROS_DISTRO=${{ matrix.ros_distro }}
10676
10777
10878
build-arm-docker-image:
@@ -114,7 +84,7 @@ jobs:
11484
fail-fast: false
11585
matrix:
11686
include:
117-
- base_image: lcas.lincoln.ac.uk/lcas/ros:jammy-humble-cuda12.2-opengl-arm64-1
87+
- base_image: lcas.lincoln.ac.uk/lcas/limo_platform_arm64:1
11888
ros_distro: humble
11989
push_image: lcas.lincoln.ac.uk/devcontainer/ros2-teaching-arm64
12090

@@ -127,12 +97,12 @@ jobs:
12797
- uses: actions/checkout@v3
12898
with:
12999
fetch-depth: 1
100+
submodules: 'recursive'
130101

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

134105
- name: Docker Login LCAS
135-
if: ${{ github.event_name != 'pull_request' }}
136106
uses: docker/login-action@v3
137107
with:
138108
registry: lcas.lincoln.ac.uk
@@ -171,5 +141,4 @@ jobs:
171141
build-args: |
172142
BASE_IMAGE=${{ matrix.base_image }}
173143
BRANCH=${{ env.BRANCH }}
174-
ROS_DISTRO=${{ matrix.ros_distro }}
175144

.github/workflows/devcontainer-ci.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ jobs:
1818
node-version: "^16.13.0 || >=18.0.0"
1919
- name: Checkout (GitHub)
2020
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 1
23+
submodules: 'recursive'
2124
- name: What
2225
run: echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV
2326
- name: Build container
24-
if: ${{ github.event_name != 'pull_request' }}
2527
uses: devcontainers/ci@v0.3
2628
with:
27-
imageName: devcontainer/ros2-teaching
29+
imageName: lcas.lincoln.ac.uk/devcontainer/ros2-teaching
2830
push: never
29-
imageTag: ${{ env.BRANCH }}
31+
imageTag: ci
3032
#runCmd: "bash .devcontainer/run-ci.sh"

.github/workflows/ros-ci.yml.OFF

Lines changed: 0 additions & 74 deletions
This file was deleted.

0 commit comments

Comments
 (0)