-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH actions and docker fixes and refactor (#302)
* Introduce docker bake and simplify build and push job Pin VSCode Server version in VNC image due to incompatilibities in newer versions (cpp tools and ros extensions specifically cannot be installed to vscode server during image build) Previously, the build and push job constitued of two parametrized jobs that were taking from the same template to build base and dependent vnc image. The .yml files themselves were somewhat convoluted and contained custom logic that should be unnecessary. Since buildx was already used in workflows, no reason not to use its really good features, like bake. Also, buildx has been installed by default since docker v23.0, and current is v27, so really, there is no reason not to use it, hence changes in the Makefile too (also left previous build goal as build_legacy goal for clarity). The convoluted logic of evaluating tags and targets manually, then passing them around to build and push jobs has been completely moved to docker-bake.hcl, which is way more extendable, and also can be used for both local and remote use. This also removes 2 .yml files which were dependent on each other, and instead makes the CI part of the system clean and simple. In addition, the job that actually builds the images will run faster now, as it is not explicitly sequential as before (basically, think that vnc job is now in some form of hot start mode, as it is not separated, so it can prepare its dependencies that are not dependent on the upstream image) * Refactor bake config file, much more readable, structured and extendible, modify Makefile, add initial Dockerfile.deploy * Enable push on new GH action, add some more comments to docker-bake.hcl
- Loading branch information
Showing
7 changed files
with
201 additions
and
92 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
ARG BASE_IMAGE=osrf/ros:humble-simulation | ||
FROM $BASE_IMAGE | ||
|
||
USER root | ||
|
||
# Essentials | ||
RUN apt-get update && apt-get install --no-install-recommends -y -o Dpkg::Options::="--force-overwrite" \ | ||
ros-humble-navigation2 \ | ||
ros-humble-nav2-bringup \ | ||
ros-humble-rviz2 \ | ||
ros-humble-teleop-twist-keyboard \ | ||
ros-humble-dynamixel-sdk \ | ||
ros-humble-can-msgs \ | ||
ros-humble-ruckig \ | ||
ros-humble-laser-filters \ | ||
ros-humble-domain-bridge \ | ||
ros-humble-rmw-cyclonedds-cpp \ | ||
ros-humble-ros2-control \ | ||
ros-humble-ros2-controllers \ | ||
ros-humble-rqt-common-plugins \ | ||
ros-humble-webots-ros2 \ | ||
ros-humble-dynamixel-workbench-toolbox \ | ||
ros-humble-behaviortree-cpp \ | ||
libopencv-dev \ | ||
# TODO: Question which of these are necessary | ||
python3-pip \ | ||
python3-pil \ | ||
alsa \ | ||
libxshmfence1 \ | ||
libgtk-3-dev \ | ||
git \ | ||
git-lfs \ | ||
curl \ | ||
wget \ | ||
vim \ | ||
rsync \ | ||
dialog \ | ||
fuse | ||
|
||
RUN python3 -m pip install scipy transforms3d | ||
|
||
#HOTFIX: https://github.com/ros-controls/ros2_controllers/issues/482 | ||
RUN wget -O /tmp/diff_drive_controller.deb http://snapshots.ros.org/humble/2022-11-23/ubuntu/pool/main/r/ros-humble-diff-drive-controller/ros-humble-diff-drive-controller_2.12.0-1jammy.20221108.202153_amd64.deb && \ | ||
apt install -y --allow-downgrades /tmp/diff_drive_controller.deb && \ | ||
rm -f /tmp/diff_drive_controller.deb | ||
|
||
# User config | ||
COPY ./config/bashrc /tmp/bashrc | ||
|
||
RUN mkdir -p /memristor && \ | ||
cat /tmp/bashrc >> /memristor/.bashrc && \ | ||
rm -f /tmp/bashrc && \ | ||
mkdir -p /memristor/ros2_ws/src/mep3 | ||
|
||
# Set the working directory | ||
WORKDIR /root/ros2_ws | ||
|
||
RUN git clone https://github.com/memristor/mep3 src/mep3 | ||
|
||
RUN touch src/mep3/mep3_simulation/COLCON_IGNORE | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y python3-vcstool && \ | ||
rosdep update && \ | ||
rosdep install --from-paths src --ignore-src -r -y | ||
|
||
# Build the packages | ||
RUN . /opt/ros/humble/setup.sh && \ | ||
colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=RelWithDebInfo | ||
|
||
ENTRYPOINT ["/bin/bash", "-c", "source install/local_setup.bash && exec bash"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
ARG BASE_IMAGE=ghcr.io/memristor/mep3 | ||
FROM $BASE_IMAGE | ||
FROM mep3 | ||
|
||
USER root | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
variable "COMMIT_SHA" {} | ||
|
||
variable "GITHUB_REPO" {} | ||
|
||
variable "TARGET_IMAGE_NAME_MAPPING" { | ||
default = { | ||
"base" = "mep3" | ||
"vnc" = "mep3-vnc" | ||
"deploy" = "mep3-deploy" | ||
} | ||
} | ||
|
||
variable CONTEXTS_MAPPING { | ||
default = { | ||
"vnc" = { | ||
"mep3" = "target:mep3" | ||
} | ||
} | ||
} | ||
|
||
function "eval_tags" { | ||
params = [image_name, commit_sha, github_repo] | ||
result = [ | ||
// If GITHUB_REPO is not set, then we are building locally | ||
equal("", github_repo) ? image_name : "", | ||
equal("", github_repo) && notequal("", commit_sha) ? "${image_name}:${commit_sha}" : "", | ||
// otherwise, we are building on GitHub Actions | ||
notequal("", github_repo) ? "ghcr.io/${github_repo}/${image_name}:latest" : "", | ||
notequal("", github_repo) && notequal("", commit_sha) ? "ghcr.io/${github_repo}:${commit_sha}" : "" | ||
] | ||
} | ||
|
||
target "default" { | ||
name = lookup(TARGET_IMAGE_NAME_MAPPING, tgt, "") | ||
matrix = { | ||
tgt = keys(TARGET_IMAGE_NAME_MAPPING) | ||
} | ||
|
||
tags = eval_tags(lookup(TARGET_IMAGE_NAME_MAPPING, tgt, ""), COMMIT_SHA, GITHUB_REPO) | ||
|
||
# Use Dockerfile.${tgt} for each target as defined by targets in TARGET_IMAGE_NAME_MAPPING | ||
dockerfile = "Dockerfile.${tgt}" | ||
|
||
# Cache settings, enable caching from previous builds | ||
cache-to = [format("%s%s", "type=gha,mode=max,scope=", lookup(TARGET_IMAGE_NAME_MAPPING, tgt, ""))] | ||
cache-from = [format("%s%s", "type=gha,scope=", lookup(TARGET_IMAGE_NAME_MAPPING, tgt, ""))] | ||
|
||
# Contexts for dependent images, as defined in CONTEXTS_MAPPING graph, i.e. mep3-vnc builds atop mep3 | ||
contexts = lookup(CONTEXTS_MAPPING, tgt, {}) | ||
} |