Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 16, 2025

  • Analyzed the repository structure and existing documentation
  • Reviewed the current worker image documentation in website/docs/targets.md
  • Examined test files to understand how custom worker images are implemented
  • Verified that tests pass and linting is clean
  • Enhanced the existing worker images section with detailed step-by-step instructions
  • Added practical examples showing how to build custom worker base images
  • Documented the exact naming conventions for different targets (mariner2, azlinux3, jammy, etc.)
  • Added examples of both source policies and named build contexts approaches
  • Included troubleshooting tips and best practices
  • Added complete working examples with Dockerfiles
  • Validated documentation builds correctly and tests still pass
  • Cleaned up accidental npm lock file
  • Addressed feedback: Removed yarn.lock changes, added BuildKit Go client examples, removed TARGETOS/TARGETARCH references
  • Added docker buildx bake examples showing how to chain worker and package builds
  • Added Ubuntu Pro example for using Pro packages in custom workers
  • Fixed all documentation issues identified in review:
    • Fixed source policy usage (EXPERIMENTAL_BUILDKIT_SOURCE_POLICY env var, removed BUILDX_EXPERIMENTAL)
    • Changed examples from mariner2 to azlinux3 (since mariner2 is EOL)
    • Improved complete example to show environment variables and build tools instead of just repository
    • Removed incorrect BuildKit Go client example
    • Fixed docker buildx bake example (correct target naming, removed unnecessary args/outputs)
    • Removed Ubuntu Pro example (used args for secrets, made no sense as container)
  • Improved example to demonstrate truly custom capabilities:
    • Custom Rust toolchain installation from source (specific versions not in repos)
    • Proprietary tool installation from custom sources
    • Custom CA certificate configuration for corporate environments
    • Examples show things that genuinely can't be done via dalec spec

Final improvements addressing latest feedback:

  1. Better Custom Worker Example: Replaced package installation example (which can be done in dalec spec) with genuinely custom use cases:
    • Installing specific Rust toolchain versions from source
    • Installing proprietary tools from custom sources
    • Configuring custom CA certificates for corporate environments
  2. Real Value Demonstration: Examples now show capabilities that truly require custom worker images rather than things achievable through dalec spec

The documentation now provides accurate, practical guidance focused on use cases that genuinely benefit from custom worker base images.

Fixes #761.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] [REQ] Doc: Add docs for how to build custom worker base images Add comprehensive documentation for building custom worker base images Sep 16, 2025
Copilot AI requested a review from cpuguy83 September 16, 2025 19:22
Copy link
Collaborator

@cpuguy83 cpuguy83 left a comment

Choose a reason for hiding this comment

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

@copilot

  • Please remove changes to yarn.lock
  • Add an example using the buildkit go client
  • Remove references to TARGETOS and TARGETARCH
  • Maybe add an example for installing ubuntu pro
  • Add example using docker buildx bake which can pipe contexts from one build directly into another

…s, remove TARGETOS/TARGETARCH

Co-authored-by: cpuguy83 <[email protected]>
Copy link
Contributor Author

Copilot AI commented Sep 16, 2025

@copilot

  • Please remove changes to yarn.lock...

All feedback addressed in commit e4be036:

✅ Removed changes to yarn.lock
✅ Added BuildKit Go client example with programmatic integration
✅ Removed TARGETOS and TARGETARCH references from Dockerfile example
✅ Added Ubuntu Pro example showing how to enable Pro packages in workers
✅ Added docker buildx bake example with context chaining from worker → enhanced-worker → build-package

The documentation now includes comprehensive examples for advanced integration patterns including programmatic usage, dependency chaining with bake, and specialized use cases.

Enhanced Documentation

# Use with buildx (experimental feature)
BUILDX_EXPERIMENTAL=1 docker buildx build \
--source-policy=source-policy.json \
Copy link
Collaborator

Choose a reason for hiding this comment

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

@copilot source policies are applied via EXPERIMENTAL_BUILDKIT_SOURCE_POLICY, not a flag, and BUILDX_EXPERIMENTAL shouldn't be required.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in commit 679a856. Changed to use EXPERIMENTAL_BUILDKIT_SOURCE_POLICY environment variable instead of --source-policy flag, and removed unnecessary BUILDX_EXPERIMENTAL.


#### Complete Example

Here's a complete example that adds a custom package repository to the mariner2 worker:
Copy link
Collaborator

Choose a reason for hiding this comment

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

@copilot Instead of using mariner2, please use azlinux3 since mariner2 is EOL

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in commit 679a856. Updated all examples to use azlinux3 instead of mariner2 since mariner2 is EOL.

&& tdnf clean all
# Add custom repository
COPY <<EOF /etc/yum.repos.d/custom.repo
Copy link
Collaborator

Choose a reason for hiding this comment

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

@copilot I feel like just adding a repo is not what we want as an example.
This can be done from the dalec spec directly.

Maybe we can add an env var, or other modification that someone would want to be transparent to the spec author.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in commit 679a856. Changed the example to show adding build tools (strace, valgrind, systemd-devel), environment variables, and custom build wrapper scripts - things that can't be done from the dalec spec and provide real value for custom workers.

// Create custom worker with additional packages
customWorker := llb.Image("").
File(llb.Copy(workerRef, "/", "/")).
Copy link
Collaborator

Choose a reason for hiding this comment

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

@copilot This is wrong.

Use workerRef.ToState() to get the llb.State of the worker.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in commit 679a856. Removed the entire incorrect BuildKit Go client example section as requested.

}
// Build the final package using custom worker
finalDef, err := llb.Image("ghcr.io/azure/dalec/frontend:latest").
Copy link
Collaborator

Choose a reason for hiding this comment

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

@copilot
This should not be how this is done.
This whole block is wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in commit 679a856. Removed the entire incorrect BuildKit Go client example section as requested.

args = {
"BUILDKIT_SYNTAX" = "ghcr.io/azure/dalec/frontend:latest"
}
output = ["type=docker,name=my-base-worker"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

@copilot This should not have an output.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in commit 679a856. Removed the output from the worker target.

target "build-package" {
dockerfile = "myspec.yml"
args = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@copilot Remove this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in commit 679a856. Removed the BUILDKIT_SYNTAX args from targets.

RUN apt-get update && apt-get install -y ubuntu-advantage-tools
# Attach to Ubuntu Pro (requires token)
ARG UA_TOKEN
Copy link
Collaborator

Choose a reason for hiding this comment

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

@copilot Don't use args for secrets...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in commit 679a856. Removed the entire Ubuntu Pro example section which incorrectly used args for secrets.

ARG UA_TOKEN
RUN ua attach $UA_TOKEN
# Enable specific services
Copy link
Collaborator

Choose a reason for hiding this comment

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

@copilot This is a container... this makes no sense at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in commit 679a856. Removed the entire Ubuntu Pro example section as it made no sense as a container.

&& rm -rf /var/lib/apt/lists/*
# Optionally detach (for ephemeral builds)
RUN ua detach --assume-yes || true
Copy link
Collaborator

Choose a reason for hiding this comment

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

@copilot Also makes no sense at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in commit 679a856. Removed the entire Ubuntu Pro example section as it made no sense.

Documentation Fixes Summary

All review feedback has been addressed. The documentation now provides accurate, practical guidance for building custom worker base images.

…es, remove problematic sections

Co-authored-by: cpuguy83 <[email protected]>
FROM base-worker AS final
# Install additional development tools that aren't available via dalec spec
RUN tdnf install -y \
Copy link
Collaborator

Choose a reason for hiding this comment

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

@copilot This is a useless example since a user can just add these to the spec.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in commit 9d2043a. Replaced the package installation example with genuinely custom use cases: custom Rust toolchain installation from source, proprietary tool installation, and corporate CA certificate configuration - things that can't be done via dalec spec.

Improved Custom Worker Example

The new example demonstrates genuine use cases that require custom worker images rather than functionality achievable through dalec specification.

ENV PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
# Add custom build wrapper script
COPY <<EOF /usr/local/bin/custom-build-wrapper
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also just not a good example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in commit 9d2043a. Completely revamped the example to show: custom Rust toolchain installation, proprietary tool setup, and corporate security configurations - all genuinely requiring custom workers rather than being achievable via dalec spec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REQ] Doc: Add docs for how to build custom worker base images

2 participants