-
Notifications
You must be signed in to change notification settings - Fork 17
Add Docker BuildX config #266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
evan-palmer
merged 27 commits into
Robotic-Decision-Making-Lab:main
from
apl-ocean-engineering:dev/use_buildx_bake
Aug 22, 2024
Merged
Changes from 19 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
a714d8b
Allow pushing to apl-ocean-engineering
amarburg fb1d847
Merge remote-tracking branch 'upstream/main' into main
amarburg 298343c
Merge branch 'main' of https://github.com/Robotic-Decision-Making-Lab…
amarburg 5020803
Merge branch 'main' of https://github.com/Robotic-Decision-Making-Lab…
amarburg 5932e10
Merge branch 'main' of github.com:apl-ocean-engineering/blue into main
amarburg 064c426
Merge branch 'main' of https://github.com/Robotic-Decision-Making-Lab…
amarburg 0a7fe16
Install cppzmq-dev for Gazebo
amarburg 5ad14a3
Allow pushing to apl-ocean-engineering
amarburg 9632b0f
Reverse change in docker.yaml action.
amarburg 9d98b26
Preliminary version of docker-bake.hcl and updated Docker workflow.
amarburg 4fb87d7
Updated comments in Dockerfile
amarburg 9b7be45
Attempt to allow manual triggering of builds
amarburg 6ab2769
Nope, that's not it.
amarburg 028e3e6
Add preliminary label to all Docker images.
amarburg 830f3da
Removed redundant libcppzmq-dev
amarburg e06a30c
Hack to lowercase repo name
amarburg 10d8dc7
Re-activate the metadata-action, go back to stages in matrix.
amarburg 3b3538d
Add comment on lowercasing.
amarburg e873d09
Place files config at correct level.
amarburg f74c060
Merge branch 'dev/reimplement_metadata_action_presquash' into dev/use…
amarburg 5c81971
Re-activate the metadata-action, go back to stages in matrix.
amarburg df4809a
Place files config at correct level.
amarburg 5ffee9d
Switch to registry cache for CI
amarburg 40da1cf
Merge branch 'dev/use_buildx_bake' of github.com:apl-ocean-engineerin…
amarburg 042584f
Removed stage from matrix
amarburg 1ebbfe3
Merge branch 'main' of github.com:apl-ocean-engineering/blue into dev…
amarburg 2032dd1
Update repo URL, fix list formatting.
amarburg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,94 @@ | ||
# | ||
# 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"] | ||
} | ||
|
||
# These are populated by the metadata-action Github action for each target | ||
# when building in CI | ||
# | ||
target "docker-metadata-action-ci" {} | ||
target "docker-metadata-action-robot" {} | ||
target "docker-metadata-action-desktop" {} | ||
target "docker-metadata-action-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" { | ||
inherits = ["docker-metadata-action-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}:cache-${BLUE_ROS_DISTRO}-ci", | ||
"ghcr.io/${BLUE_GITHUB_REPO}:cache-${BLUE_ROS_DISTRO}-robot", | ||
"ghcr.io/${BLUE_GITHUB_REPO}:cache-${BLUE_ROS_DISTRO}-desktop", | ||
"ghcr.io/${BLUE_GITHUB_REPO}:cache-${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", "docker-metadata-action-robot" ] | ||
target = "robot" | ||
tags = [ | ||
"ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-robot" | ||
] | ||
cache_to = [ | ||
"type=local,dest=.docker-cache" | ||
] | ||
} | ||
|
||
target "desktop" { | ||
inherits = [ "ci", "docker-metadata-action-desktop" ] | ||
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", "docker-metadata-action-desktop-nvidia" ] | ||
target = "desktop-nvidia" | ||
tags = [ | ||
"ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-desktop-nvidia" | ||
] | ||
cache_to = [ | ||
"type=local,dest=.docker-cache" | ||
] | ||
} |
This file contains hidden or 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,8 +1,9 @@ | ||
name: Docker | ||
|
||
on: | ||
schedule: | ||
- cron: "0 17 * * 6" | ||
# Disable schedule for preliminary testing | ||
# schedule: | ||
# - cron: "0 17 * * 6" | ||
push: | ||
branches: | ||
- main | ||
|
@@ -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: | ||
|
@@ -28,164 +29,114 @@ jobs: | |
packages: write | ||
contents: read | ||
steps: | ||
- name: Checkout repository | ||
- | ||
name: Checkout | ||
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 }} | ||
|
||
- 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] | ||
- | ||
# 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: Set up Docker Buildx | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- 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 | ||
# buildx bake, unfortunately, requires lower-cased repository names | ||
# This shell ... er, hack, creates a local variable containing | ||
# a down-cased version of $GITHUB_REPOSITORY | ||
# | ||
- id: lower-repo | ||
name: Repository to lowercase | ||
run: | | ||
echo "repository=${GITHUB_REPOSITORY@L}" >> $GITHUB_OUTPUT | ||
evan-palmer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# Set metadata for each stage-image separately | ||
- | ||
name: Set Docker metadata for "ci" | ||
if: env.PUSH == 'true' | ||
id: meta | ||
id: meta-ci | ||
uses: docker/[email protected] | ||
with: | ||
images: ghcr.io/${{ github.repository }} | ||
bake-target: docker-metadata-action-ci | ||
tags: | | ||
type=raw,value=${{ matrix.ROS_DISTRO }}-${{ github.job }} | ||
type=raw,value=${{ matrix.ROS_DISTRO }}-ci | ||
|
||
- 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' | ||
uses: docker/[email protected] | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract Docker metadata | ||
- | ||
name: Set Docker metadata for "robot" | ||
if: env.PUSH == 'true' | ||
id: meta | ||
id: meta-robot | ||
uses: docker/[email protected] | ||
with: | ||
images: ghcr.io/${{ github.repository }} | ||
bake-target: docker-metadata-action-robot | ||
tags: | | ||
type=raw,value=${{ matrix.ROS_DISTRO }}-${{ github.job }} | ||
type=raw,value=${{ matrix.ROS_DISTRO }}-robot | ||
|
||
- 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 }} | ||
|
||
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 | ||
- | ||
name: Set Docker metadata for "desktop" | ||
if: env.PUSH == 'true' | ||
uses: docker/[email protected] | ||
id: meta-desktop | ||
uses: docker/[email protected] | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
images: ghcr.io/${{ github.repository }} | ||
bake-target: docker-metadata-action-desktop | ||
tags: | | ||
type=raw,value=${{ matrix.ROS_DISTRO }}-desktop | ||
|
||
- name: Extract Docker metadata | ||
- | ||
name: Set Docker metadata for "desktop-nvidia" | ||
if: env.PUSH == 'true' | ||
id: meta | ||
id: meta-desktop-nvidia | ||
uses: docker/[email protected] | ||
with: | ||
images: ghcr.io/${{ github.repository }} | ||
bake-target: docker-metadata-action-desktop-nvidia | ||
tags: | | ||
type=raw,value=${{ matrix.ROS_DISTRO }}-${{ github.job }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/[email protected] | ||
type=raw,value=${{ matrix.ROS_DISTRO }}-desktop-nvidia | ||
|
||
- if: github.event_name == 'push' | ||
name: Build and push (non PR) | ||
uses: docker/[email protected] | ||
env: | ||
BLUE_ROS_DISTRO: ${{ matrix.ROS_DISTRO }} | ||
BLUE_GITHUB_REPO: ${{ steps.lower-repo.outputs.repository }} | ||
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 | ||
files: | | ||
./docker-bake.hcl | ||
${{ steps.meta-ci.outputs.bake-file }} | ||
${{ steps.meta-robot.outputs.bake-file }} | ||
${{ steps.meta-desktop.outputs.bake-file }} | ||
${{ steps.meta-desktop-nvidia.outputs.bake-file }} | ||
push: ${{ env.PUSH }} | ||
set: | | ||
*.cache-from=type=registry,ref=ghcr.io/${{ github.repository }}:cache-${{ matrix.ROS_DISTRO }} | ||
*.cache-to=type=registry,mode=max,ref=ghcr.io/${{ github.repository }}:cache-${{ matrix.ROS_DISTRO }} | ||
|
||
# Pull request builds are not cached; and only built for AMD64 | ||
evan-palmer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- if: github.event_name == 'pull_request' | ||
name: Build and push (PR) | ||
uses: docker/[email protected] | ||
env: | ||
BLUE_ROS_DISTRO: ${{ matrix.ROS_DISTRO }} | ||
BLUE_GITHUB_REPO: ${{ steps.lower-repo.outputs.repository }} | ||
with: | ||
workdir: .docker | ||
files: | | ||
./docker-bake.hcl | ||
set: | | ||
*.platform=linux/amd64 | ||
*.cache-from=type=registry,ref=ghcr.io/${{ github.repository }}:cache-${{ matrix.ROS_DISTRO }} | ||
*.cache-to= |
This file contains hidden or 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 |
---|---|---|
|
@@ -16,3 +16,6 @@ mav.parm | |
mav.tlog | ||
mav.tlog.raw | ||
logs/ | ||
|
||
# Allow overrides in docker-bake | ||
.docker/docker-bake.override.hcl |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.