Skip to content
Closed
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
84 changes: 84 additions & 0 deletions .docker/docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#
# Override these variables with environment variables
# e.g.
#
# BLUE_ROS_DISTRO=iron docker buildx bake
#
# or
#
# export BLUE_ROS_DISTRO=iron
# docker buildx bake
#
variable "BLUE_ROS_DISTRO" { default = "rolling" }
variable "BLUE_GITHUB_REPO" { default = "robotic-decision-making-lab/blue" }

group "default" {
targets = ["ci", "robot", "desktop", "desktop-nvidia"]
}

#
# All images can pull cache from the images published at Github
# or local storage (within the Buildkit image)
#
# ... and push cache to local storage
#
target "ci" {
dockerfile = ".docker/Dockerfile"
target = "ci"
context = ".."
args = {
ROS_DISTRO = "${BLUE_ROS_DISTRO}"
}
tags = [
"ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-ci"
]
labels = {
"org.opencontainers.image.source" = "https://github.com/${BLUE_GITHUB_REPO}"
}
cache_from =[
"ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-ci",
"ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-robot",
"ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-desktop",
"ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-desktop-nvidia",
"type=local,dest=.docker-cache"
]
cache_to = [
"type=local,dest=.docker-cache"
]
platforms = ["linux/amd64", "linux/arm64"]
}

target "robot" {
inherits = [ "ci" ]
target = "robot"
tags = [
"ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-robot"
]
cache_to = [
"type=local,dest=.docker-cache"
]
}

target "desktop" {
inherits = [ "ci" ]
target = "desktop"
tags = [
"ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-desktop"
]
cache_to = [
"type=local,dest=.docker-cache"
]
# amd64 only builds for desktop and desktop-nvidia
platforms = ["linux/amd64"]
}

target "desktop-nvidia" {
inherits = [ "desktop" ]
target = "desktop-nvidia"
tags = [
"ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-desktop-nvidia"
]
cache_to = [
"type=local,dest=.docker-cache"
]
}
207 changes: 58 additions & 149 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: Docker

on:
schedule:
- cron: "0 17 * * 6"
# Disable schedule for preliminary testing
# schedule:
# - cron: "0 17 * * 6"
push:
branches:
- main
Expand All @@ -18,7 +19,7 @@ env:
PUSH: ${{ (github.event_name != 'pull_request') && (github.repository == 'Robotic-Decision-Making-Lab/blue') }}

jobs:
ci:
docker_build:
strategy:
fail-fast: false
matrix:
Expand All @@ -27,165 +28,73 @@ jobs:
permissions:
packages: write
contents: read
env:
BLUE_ROS_DISTRO: ${{ matrix.ROS_DISTRO }}
BLUE_GITHUB_REPO: ${{ github.repository }}
steps:
- name: Checkout repository
-
name: Checkout repository
uses: actions/checkout@v4

- name: Log into registry
if: env.PUSH == 'true'
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
# Add support for more platforms with QEMU (optional)
# https://github.com/docker/setup-qemu-action
name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Extract Docker metadata
if: env.PUSH == 'true'
id: meta
uses: docker/[email protected]
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=raw,value=${{ matrix.ROS_DISTRO }}-${{ github.job }}

- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
file: .docker/Dockerfile
build-args: ROS_DISTRO=${{ matrix.ROS_DISTRO }}
target: ${{ github.job }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: ${{ env.PUSH }}

robot:
strategy:
fail-fast: false
matrix:
ROS_DISTRO: [rolling]
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/[email protected]

- name: Set up Docker Buildx
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log into registry
if: env.PUSH == 'true'
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
if: env.PUSH == 'true'
id: meta
uses: docker/[email protected]
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=raw,value=${{ matrix.ROS_DISTRO }}-${{ github.job }}

- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
file: .docker/Dockerfile
build-args: ROS_DISTRO=${{ matrix.ROS_DISTRO }}
target: ${{ github.job }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: ${{ env.PUSH }}
platforms: linux/amd64
#platforms: linux/amd64,linux/arm64

desktop:
strategy:
fail-fast: false
matrix:
ROS_DISTRO: [rolling]
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log into registry
-
if: env.PUSH == 'true'
name: Log into registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
if: env.PUSH == 'true'
id: meta
uses: docker/[email protected]
# tbd: not sure how to update this for buildx
#
# -
# name: Extract Docker metadata
# if: env.PUSH == 'true'
# id: meta
# uses: docker/[email protected]
# with:
# images: ghcr.io/${{ github.repository }}
# tags: |
# type=raw,value=${{ matrix.ROS_DISTRO }}-${{ matrix.stage }}

- if: github.event_name == 'push'
name: Build and push (non PR)
uses: docker/[email protected]
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=raw,value=${{ matrix.ROS_DISTRO }}-${{ github.job }}

- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
file: .docker/Dockerfile
build-args: ROS_DISTRO=${{ matrix.ROS_DISTRO }}
target: ${{ github.job }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
workdir: .docker
push: ${{ env.PUSH }}

desktop-nvidia:
strategy:
fail-fast: false
matrix:
ROS_DISTRO: [rolling]
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log into registry
if: env.PUSH == 'true'
uses: docker/[email protected]
set: |
*.cache-from=type=gha,scope=ci
*.cache-from=type=gha,scope=robot
*.cache-from=type=gha,scope=desktop
*.cache-from=type=gha,scope=desktop-nvidia
ci.cache-to=type=gha,mode=max,scope=ci
robot.cache-to=type=gha,mode=max,scope=robot
desktop.cache-to=type=gha,mode=max,scope=desktop
desktop-nvidia.cache-to=type=gha,mode=max,scope=desktop-nvidia

# Pull request builds are not cached; and only built for AMD64
- if: github.event_name == 'pull_request'
name: Build and push (PR)
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
if: env.PUSH == 'true'
id: meta
uses: docker/[email protected]
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=raw,value=${{ matrix.ROS_DISTRO }}-${{ github.job }}

- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
file: .docker/Dockerfile
build-args: ROS_DISTRO=${{ matrix.ROS_DISTRO }}
target: ${{ github.job }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: ${{ env.PUSH }}
workdir: .docker
targets: |
${{ matrix.stage }}
set: |
*.platform=linux/amd64
*.cache-from=type=gha,scope=ci
*.cache-from=type=gha,scope=robot
*.cache-from=type=gha,scope=desktop
*.cache-from=type=gha,scope=desktop-nvidia
*.cache-to=
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ mav.parm
mav.tlog
mav.tlog.raw
logs/

# Allow overrides in docker-bake
.docker/docker-bake.override.hcl