Skip to content

Commit

Permalink
feat(ros2): 🚀 add ros 2 foxy build pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
tunahanertekin authored May 25, 2023
2 parents a5f2cdd + 35b3a9a commit f709e75
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 6 deletions.
30 changes: 30 additions & 0 deletions dockerfiles/ros2/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

ARG BASE_IMAGE="ubuntu:20.04"
FROM ${BASE_IMAGE}-${TARGETARCH}

SHELL ["/bin/bash", "-c"]
ARG DEBIAN_FRONTEND=noninteractive

ARG ROS_DISTRO_CODE=foxy

RUN apt update && apt install -y \
gnupg2 \
lsb-release \
curl \
ssh \
&& rm -rf /var/lib/apt/lists/*

RUN curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(source /etc/os-release && echo $UBUNTU_CODENAME) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null

RUN apt update && apt install -y ros-${ROS_DISTRO_CODE}-ros-base

RUN echo "source /opt/ros/${ROS_DISTRO_CODE}/setup.bash" >> ~/.bashrc
RUN apt update && apt install -y \
python3-rosdep \
python3-rosinstall \
python3-rosinstall-generator \
python3-wstool \
build-essential \
python3-colcon-common-extensions \
&& rm -rf /var/lib/apt/lists/*
17 changes: 17 additions & 0 deletions pipelines/ros2/foxy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: foxy
registry: docker.io
organization: robolaunchio
steps:
- name: foxy
image:
repository: devspace-robotics
tag: foxy-xfce
path: "dockerfiles/ros2"
dockerfile: "Dockerfile"
buildArgs:
"BASE_IMAGE": "robolaunchio/devspace:focal-xfce"
"ROS_DISTRO_CODE": "foxy"
platforms:
- "linux/amd64"
- "linux/arm64"
push: false
38 changes: 38 additions & 0 deletions pipelines/test/test-multiarch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: testing
registry: docker.io
organization: tunahanertekin
steps:
- name: ascii
image:
repository: test
tag: ascii
path: "dockerfiles/testing"
dockerfile: "Dockerfile.ascii"
buildArgs:
"BASE_IMAGE": "ubuntu:focal"
platforms:
- "linux/amd64"
- "linux/arm64"
push: true
- name: iputils
image:
repository: test
tag: ascii-iputils
baseStep: ascii
path: "dockerfiles/testing"
dockerfile: "Dockerfile.iputils"
platforms:
- "linux/amd64"
- "linux/arm64"
push: true
- name: dnsutils
image:
repository: test
tag: ascii-iputils-dnsutils
baseStep: iputils
path: "dockerfiles/testing"
dockerfile: "Dockerfile.dnsutils"
platforms:
- "linux/amd64"
- "linux/arm64"
push: true
5 changes: 1 addition & 4 deletions pipelines/test.yaml → pipelines/test/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,17 @@ steps:
dockerfile: "Dockerfile.ascii"
buildArgs:
"BASE_IMAGE": "ubuntu:focal"
push: false
- name: iputils
image:
repository: test
tag: ascii-iputils
baseStep: ascii
path: "dockerfiles/testing"
dockerfile: "Dockerfile.iputils"
push: false
- name: dnsutils
image:
repository: test
tag: ascii-iputils-dnsutils
baseStep: iputils
path: "dockerfiles/testing"
dockerfile: "Dockerfile.dnsutils"
push: false
dockerfile: "Dockerfile.dnsutils"
5 changes: 5 additions & 0 deletions pkg/docker/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ func BuildMultiplatform(ctx context.Context, dfName, dfPath, buildContext, baseI
step.Image.Name,
}

for k, v := range step.BuildArgs {
cmdBuildElements = append(cmdBuildElements, "--build-arg")
cmdBuildElements = append(cmdBuildElements, strings.ToUpper(k)+"="+*v)
}

if step.Push {
cmdBuildElements = append(cmdBuildElements, "--push")
}
Expand Down
9 changes: 7 additions & 2 deletions pkg/process/step.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,18 @@ func start(step *api.Step, status *api.StepStatus, lc api.LaunchConfig) error {
func build(step *api.Step, baseStep api.Step, stepStatus *api.StepStatus, lc api.LaunchConfig) error {

stepStatus.Phase = api.StepPhaseBuilding
GetSpinner(StepLog, " Building step: "+step.Name)
logSpinner.Start()
if len(step.Platforms) == 0 {
GetSpinner(StepLog, " Building step: "+step.Name)
logSpinner.Start()
if err := docker.Build(context.Background(), step.Dockerfile, step.Path, step.Context, *step, lc); err != nil {
return err
}
} else {
GetSpinner(StepLog, " Building step: "+step.Name)
if step.Push {
GetSpinner(StepLog, " Building and pushing step: "+step.Name)
}
logSpinner.Start()
if err := docker.BuildMultiplatform(context.Background(), step.Dockerfile, step.Path, step.Context, baseStep.Image.Name, *step, lc); err != nil {
return err
}
Expand Down

0 comments on commit f709e75

Please sign in to comment.