Skip to content
Merged
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
61 changes: 61 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
on:
workflow_dispatch:
inputs:
image-prefix:
description: "gets suffixed with 'base' and 'sdk' to create actual image name"
default: ghcr.io/viamrobotics/cpp-
dockerfile:
default: Dockerfile.debian.bullseye
tag:
default: bullseye-amd64
build-base:
description: "whether to build the base image. the base images change less often and may not be necessary to rebuild."
type: boolean
default: false
build-sdk:
description: "whether to build the SDK image. if this is true and no corresponding base image exists, the job will fail."
type: boolean
default: false
push:
description: "whether to push the images after building them"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just for my own understanding, In what cases would we run this workflow without pushing images to GHCR? why do we have the option to disable pushing inputs.push here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

push=false for testing only; for commands with a big side effect (in this case overwriting a public image), I like to have a 'dry run' option

type: boolean
default: false

jobs:
build-container:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4

# build base (if inputs.build-base)
- uses: docker/metadata-action@v5
id: base-meta
if: inputs.build-base
with:
images: ${{ inputs.image-prefix }}base
- uses: docker/build-push-action@v5
if: inputs.build-base
with:
push: ${{ inputs.push }}
tags: "${{ inputs.image-prefix }}base:${{ inputs.tag }}"
file: etc/docker/base-images/${{ inputs.dockerfile }}
labels: ${{ steps.base-meta.output.labels }}

# build sdk (if inputs.build-sdk)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain the purpose of separating build-base and build-sdk into two separate steps? are there times where only one would be built?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did this because the instructions in the readme were already two-step

but in general the purpose of 'base images' is to save time on the constant part of the build

here specifically, could imagine us rebuilding the base images weekly or monthly, and rebuilding the sdk image on every release or on main branch update

- uses: docker/metadata-action@v5
id: sdk-meta
if: inputs.build-sdk
with:
images: ${{ inputs.image-prefix }}sdk
- uses: docker/build-push-action@v5
if: inputs.build-sdk
with:
build-args: |
BASE_TAG=${{ inputs.image-prefix }}base:${{ inputs.tag }}
push: ${{ inputs.push }}
tags: "${{ inputs.image-prefix }}sdk:${{ inputs.tag }}"
file: etc/docker/Dockerfile.sdk-build
labels: ${{ steps.sdk-meta.output.labels }}