-
Notifications
You must be signed in to change notification settings - Fork 51
Description
What kind of request is this?
New feature
What is your request or suggestion?
First, an example Dockerfile:
FROM golang AS build
WORKDIr /src
COPY . .
RUN go build -o /out .
FROM scrach AS final
COPY --from=build /out /In the above dockerfile, we can see there are 2 targets: build and final.
You can pass these directly to docker build via the --target flag.
Note: let's clarify some terms here before proceeding:
- Docker target - The actual target passed to
docker buildand also returned by thefrontend.targetsAPI call. - Distro target - The OS distribution reference used inside dalec, e.g.
jammy,windowscross
A "Docker target" is, in effect, an API endpoint, from here on referred to as BT.
A"Distro target" is the underlying implementation that a BT request is sent to, from here on referred to as DT.
Dalec takes a different approach where the frontend just supports a static set of BT's.
There is no way from looking at a spec to determine what BT's are actually supported.
e.g.
name: foo
sources:
src: ...
build:
steps: ...
artifacts: ...This is a minimal and nonsense example, but the issue is the same, or potentially worse, with more complex specs.
If you ask dalec what BT's are available (assuming I wrote a valid spec above) you'd always get a static list, regardless of the content of the spec, but dependent on the version of dalec used.
Example list here:
dalec/website/docs/examples/targets.md
Lines 1 to 71 in 4b293ff
| TARGET DESCRIPTION | |
| almalinux8/container (default) Builds a container image for AlmaLinux 8 | |
| almalinux8/container/depsonly Builds a container image with only the runtime dependencies installed. | |
| almalinux8/rpm Builds an rpm and src.rpm. | |
| almalinux8/rpm/debug Debug options for rpm builds. | |
| almalinux8/worker Builds the base worker image responsible for building the rpm | |
| almalinux9/container (default) Builds a container image for AlmaLinux 9 | |
| almalinux9/container/depsonly Builds a container image with only the runtime dependencies installed. | |
| almalinux9/rpm Builds an rpm and src.rpm. | |
| almalinux9/rpm/debug Debug options for rpm builds. | |
| almalinux9/worker Builds the base worker image responsible for building the rpm | |
| azlinux3/container (default) Builds a container image for Azure Linux 3 | |
| azlinux3/container/depsonly Builds a container image with only the runtime dependencies installed. | |
| azlinux3/rpm Builds an rpm and src.rpm. | |
| azlinux3/rpm/debug Debug options for rpm builds. | |
| azlinux3/testing/sysext Builds a systemd system extension image. | |
| azlinux3/worker Builds the base worker image responsible for building the rpm | |
| bionic/deb (default) Builds a deb package. | |
| bionic/dsc Builds a Debian source package. | |
| bionic/testing/container Builds a container image for testing purposes only. | |
| bionic/worker Builds the worker image. | |
| bookworm/deb (default) Builds a deb package. | |
| bookworm/dsc Builds a Debian source package. | |
| bookworm/testing/container Builds a container image for testing purposes only. | |
| bookworm/worker Builds the worker image. | |
| bullseye/deb (default) Builds a deb package. | |
| bullseye/dsc Builds a Debian source package. | |
| bullseye/testing/container Builds a container image for testing purposes only. | |
| bullseye/worker Builds the worker image. | |
| debug/cargohome Outputs all the Cargo dependencies for the spec | |
| debug/gomods Outputs all the gomodule dependencies for the spec | |
| debug/patched-sources Outputs all patched sources from a dalec spec file. | |
| debug/pip Outputs all the pip dependencies for the spec | |
| debug/resolve Outputs the resolved dalec spec file with build args applied. | |
| debug/sources Outputs all sources from a dalec spec file. | |
| focal/deb (default) Builds a deb package. | |
| focal/dsc Builds a Debian source package. | |
| focal/testing/container Builds a container image for testing purposes only. | |
| focal/worker Builds the worker image. | |
| jammy/deb (default) Builds a deb package. | |
| jammy/dsc Builds a Debian source package. | |
| jammy/testing/container Builds a container image for testing purposes only. | |
| jammy/worker Builds the worker image. | |
| mariner2/container (default) Builds a container image for CBL-Mariner 2 | |
| mariner2/container/depsonly Builds a container image with only the runtime dependencies installed. | |
| mariner2/rpm Builds an rpm and src.rpm. | |
| mariner2/rpm/debug Debug options for rpm builds. | |
| mariner2/worker Builds the base worker image responsible for building the rpm | |
| noble/deb (default) Builds a deb package. | |
| noble/dsc Builds a Debian source package. | |
| noble/testing/container Builds a container image for testing purposes only. | |
| noble/testing/sysext Builds a systemd system extension image. | |
| noble/worker Builds the worker image. | |
| rockylinux8/container (default) Builds a container image for RockyLinux 8 | |
| rockylinux8/container/depsonly Builds a container image with only the runtime dependencies installed. | |
| rockylinux8/rpm Builds an rpm and src.rpm. | |
| rockylinux8/rpm/debug Debug options for rpm builds. | |
| rockylinux8/worker Builds the base worker image responsible for building the rpm | |
| rockylinux9/container (default) Builds a container image for RockyLinux 9 | |
| rockylinux9/container/depsonly Builds a container image with only the runtime dependencies installed. | |
| rockylinux9/rpm Builds an rpm and src.rpm. | |
| rockylinux9/rpm/debug Debug options for rpm builds. | |
| rockylinux9/worker Builds the base worker image responsible for building the rpm | |
| trixie/deb (default) Builds a deb package. | |
| trixie/dsc Builds a Debian source package. | |
| trixie/testing/container Builds a container image for testing purposes only. | |
| trixie/testing/sysext Builds a systemd system extension image. | |
| trixie/worker Builds the worker image. | |
| windowscross/container (default) Builds binaries and installs them into a Windows base image | |
| windowscross/worker Builds the base worker image responsible for building the package | |
| windowscross/zip Builds binaries combined into a zip file |
This is a huge list, that only gets bigger and likely is like to not technically valid, in terms of actually being build-able, unless the spec author was deliberate about it.
We do have the targets section which lets spec authors define DT customizations, but these are just customizations not filtering down the list of BT's. It is perfectly valid to have some things defined in the root of the spec and some things not.
There is also no way to set a default BT, i.e. what to build if no BT is provided to docker build --target=<BT>.
In the Dockerfile format the default BT is the last build stage in the file (e.g. final in the above Dockerfile)
Historically dalec used to look if there is anything defined under targets and used that to filter the list of available BT's, but this was extremely confusing and, as mentioned above, not really inline with how the spec is parsed out.
Internally we have built tooling that adds an extension field to the spec which declares the BT's we are going to build, which our internal tooling parses and generates the appropriate build matrix for our CI:
x-build-extensions:
build-targets:
- azlinux3/rpm
- azlinux3/container
- bookworm/debSo it seems natural to want to say exactly which BT's a given dalec spec is for.
In the past I may thought (ok, I definitely thought, at least in part, and pulled it back as mentioned above!) we could use targets to know which BT's a spec can be used for, however with the addition of <DT>/sysext this again can have some cases where a spec for a package could definitely not be valid for <DT>/sysext.
I don't have a specific proposal for what it would look like to add declarative BT's, but wanted to raise this to discuss since it does seem like a missing piece.
Are you willing to submit PRs to contribute to this feature request?
- Yes, I am willing to implement it.