-
Notifications
You must be signed in to change notification settings - Fork 27
build docker base images in CI #322
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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" | ||
| 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) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you explain the purpose of separating
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 }} | ||
There was a problem hiding this comment.
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.pushhere?There was a problem hiding this comment.
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