Skip to content

Build Monorepo Base Images #11

Build Monorepo Base Images

Build Monorepo Base Images #11

name: Build Monorepo Base Images
on:
workflow_dispatch:
inputs:
pull_image:
description: "Pull Images from GitHub Registry"
type: boolean
default: true
push_image:
description: "Push Images to GitHub Registry"
type: boolean
default: true
pull_request:
branches:
- main
jobs:
setup-environment:
name: Setup environment
runs-on: ubuntu-latest
outputs:
registry: ${{ steps.docker-environment.outputs.registry }}
repository: ${{ steps.docker-environment.outputs.repository }}
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Generate Docker Environment
id: docker-environment
uses: "./.github/templates/docker_context"
build:
name: Build Image and Run Initial Unit Testing Suite
runs-on: ubuntu-latest
needs: setup-environment
env:
DOCKER_REGISTRY: ${{ needs.setup.outputs.registry }}
DOCKER_REPOSITORY: ${{ needs.setup.outputs.repository }}
strategy:
fail-fast: false
matrix:
include:
- tag: humble-ubuntu22.04
external_image: ros:humble-ros-base
- tag: cuda12.0.1-humble-ubuntu22.04
dockerfile: cuda_ros.Dockerfile
params:
UBUNTU_DISTRO: ubuntu22.04
CUDA_VERSION: 12.0.1
ROS_DISTRO: humble
steps:
# Initial workflow setup
- name: Checkout repository
uses: actions/checkout@v3
- name: Construct Registry URL
id: construct-registry-url
run: |
echo "url=${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_REPOSITORY }}/base:${{ matrix.tag }}" \
>> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
id: buildx
- name: Docker Login
uses: docker/login-action@v3
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ secrets.GHCR_USER }}
password: ${{ secrets.GHCR_PWD }}
- name: Build Generic Image
uses: docker/build-push-action@v5
with:
context: .
file: docker/base/${{ matrix.dockerfile }}
push: true
tags: |
${{ steps.construct-registry-url.outputs.url }}_generic
cache-from: |
${{ steps.construct-registry-url.outputs.url }}_generic
cache-to: type=inline
builder: ${{ steps.buildx.outputs.name }}
target: devel
build-args: |
UBUNTU_DISTRO=${{ matrix.params.UBUNTU_DISTRO }}
CUDA_VERSION=${{ matrix.params.CUDA_VERSION }}
ROS_DISTRO=${{ matrix.params.ROS_DISTRO }}
- name: Prepare Generic Image as Monorepo Base Image
uses: docker/build-push-action@v5
with:
context: .
file: docker/base/wato_base.Dockerfile
push: true
tags: |
${{ steps.construct-registry-url.outputs.url }}
cache-from: |
${{ steps.construct-registry-url.outputs.url }}
cache-to: type=inline
builder: ${{ steps.buildx.outputs.name }}
target: wato_base
build-args: |
GENERIC_BASE=${{ steps.construct-registry-url.outputs.url }}_generic