How to add a "build stage" to a blue-build image? #20
-
I've been working on migrating my ublue-template repository into blue-build. However, I've had a problem. When I was allowed to manually change the containerfile, I used this for adding build-stages for software I want in my image that has to be manually built, so they build on the CI and all of the build dependencies aren't installed in the main image. How I did it was the following:
FROM ${BASE_IMAGE_URL}:${IMAGE_MAJOR_VERSION} as first-stage # Here is the important bit, adding the name. I used first-stage
# From here on out, it's the containerfile as defined by the template, no modifications made.
ARG RECIPE=recipe.yml
ARG IMAGE_REGISTRY=ghcr.io/ublue-os
ARG GH_GET_TOKEN
COPY cosign.pub /usr/share/ublue-os/cosign.pub
COPY --from=ghcr.io/ublue-os/bling:latest /rpms /tmp/bling/rpms
COPY --from=ghcr.io/ublue-os/bling:latest /files /tmp/bling/files
# etc...
# This RUN command finalizes the container build with the build script
RUN chmod +x /tmp/build.sh && /tmp/build.sh && \
rm -rf /tmp/* /var/*
# Instead of now running "RUN ostree container commit", I start building some software in a fedora container of the same version, using a script copied from a directory called "sources" in the main repository.
FROM fedora:${IMAGE_MAJOR_VERSION} as lightly-qt-builder # Name this image for later
COPY sources/build-scripts /tmp/build-scripts
RUN chmod +x /tmp/build-scripts/lightly-qt.sh && \
/tmp/build-scripts/lightly-qt.sh
FROM first-stage
# Copy Bup and Kup artifacts from builder into image
COPY --from=kup-builder /tmp/kupbuilt/usr /usr
COPY --from=kup-builder /tmp/kupbuilt/etc /usr/etc
COPY --from=kup-builder /tmp/bupbuilt/usr /usr
RUN ostree container commit I have seen there is a containerfile module, which doesn't seem like it can solve my issue. All it can do is add commands after the main image, not before. From what I can tell, there is no way to either:
Perhaps there is something I missed that could help me accomplish this with the complied containerfile format blue-build uses, in that case I'd be very grateful if it was pointed out. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Support for stages is planned, but does not exist as of now. blue-build/cli#108 For now, a clunky workaround would be to do the builds in a separate container. |
Beta Was this translation helpful? Give feedback.
By a separate container, I mean that you would create a file such as
auraos-software-builds.Containerfile
in your repo, and use a new GitHub workflow to build it. (we have an 'example' here) Then you could just use thecontainerfile
module to addCOPY --from=ghcr.io/auraherreroruiz/auraos-software-builds /tmp/kupbuilt/whatever /whatever
to your main build.That should work, and is better if you want multiple images to share the same custom-built software, or want to build the software with a different schedule than your image.