We will now have a dedicated alpine based `distrobox` image. Due to restrictions in how the `/tmp` directory in a `distrobox` image works, it will not play nicely with generating a local tarball for rebasing a locally built image. Going further into fixing this would required a rootful setup and I'd rather leave the `distrobox` method as an easy way to try out building a recipe for users who are not booted on a `bluebuild` image. Extra packages are installed to make the `distrobox` setup quicker and a `distrobox.ini` file is provided to easily create the container and export the CLI for use on the host machine. The `podman` binary is passed into the `distrobox` container so that all images that are built will be accessible locally and allows rootless operation without extra setup.
175 lines
4.3 KiB
Text
175 lines
4.3 KiB
Text
VERSION 0.8
|
|
PROJECT blue-build/cli
|
|
|
|
IMPORT github.com/earthly/lib/utils/dind AS dind
|
|
|
|
all:
|
|
BUILD +test-image
|
|
BUILD +test-legacy-image
|
|
BUILD +build
|
|
BUILD +rebase
|
|
BUILD +upgrade
|
|
BUILD +switch
|
|
BUILD +validate
|
|
|
|
test-image:
|
|
FROM +build-template --src=template-containerfile
|
|
WORKDIR /tmp/test
|
|
COPY ./test-scripts/*.sh ./
|
|
|
|
DO +RUN_TESTS
|
|
|
|
test-legacy-image:
|
|
FROM +build-template --src=template-legacy-containerfile
|
|
WORKDIR /tmp/test
|
|
COPY ./test-scripts/*.sh ./
|
|
|
|
DO +RUN_TESTS
|
|
|
|
build-template:
|
|
ARG --required src
|
|
FROM DOCKERFILE \
|
|
-f +$src/test/Containerfile \
|
|
+$src/test/*
|
|
|
|
template-containerfile:
|
|
FROM +test-base
|
|
RUN --no-cache bluebuild -v generate recipes/recipe.yml | tee Containerfile
|
|
|
|
SAVE ARTIFACT /test
|
|
|
|
template-legacy-containerfile:
|
|
FROM +legacy-base
|
|
RUN --no-cache bluebuild -v template config/recipe.yml | tee Containerfile
|
|
|
|
SAVE ARTIFACT /test
|
|
|
|
build:
|
|
FROM +test-base
|
|
|
|
RUN bluebuild -v build recipes/recipe.yml
|
|
|
|
build-full:
|
|
FROM +test-base --MOCK="false"
|
|
|
|
DO dind+INSTALL
|
|
|
|
ENV BB_USERNAME=gmpinder
|
|
ENV BB_REGISTRY=ghcr.io
|
|
ENV BB_REGISTRY_NAMESPACE=blue-build
|
|
|
|
WITH DOCKER
|
|
RUN --secret BB_PASSWORD=github/registry bluebuild build --push -S sigstore -vv recipes/recipe.yml
|
|
END
|
|
|
|
|
|
rebase:
|
|
FROM +legacy-base
|
|
|
|
RUN --no-cache bluebuild -v rebase config/recipe.yml
|
|
|
|
upgrade:
|
|
FROM +legacy-base
|
|
|
|
RUN mkdir -p /etc/bluebuild && touch $BB_TEST_LOCAL_IMAGE
|
|
RUN --no-cache bluebuild -v upgrade config/recipe.yml
|
|
|
|
switch:
|
|
FROM +test-base
|
|
|
|
RUN mkdir -p /etc/bluebuild && touch $BB_TEST_LOCAL_IMAGE
|
|
RUN --no-cache bluebuild -v switch recipes/recipe.yml
|
|
|
|
validate:
|
|
FROM +test-base
|
|
|
|
RUN --no-cache bluebuild -v validate recipes/recipe.yml
|
|
RUN --no-cache bluebuild -v validate recipes/recipe-39.yml
|
|
RUN --no-cache bluebuild -v validate recipes/recipe-arm64.yml
|
|
RUN --no-cache bluebuild -v validate recipes/recipe-invalid.yml && exit 1 || exit 0
|
|
RUN --no-cache bluebuild -v validate recipes/recipe-invalid-module.yml && exit 1 || exit 0
|
|
RUN --no-cache bluebuild -v validate recipes/recipe-invalid-stage.yml && exit 1 || exit 0
|
|
RUN --no-cache bluebuild -v validate recipes/recipe-invalid-from-file.yml && exit 1 || exit 0
|
|
|
|
init:
|
|
FROM +test-base
|
|
|
|
WORKDIR /tmp
|
|
RUN --no-cache bluebuild new test-github \
|
|
--image-name test-github \
|
|
--org-name test \
|
|
--description 'This is a description' \
|
|
--registry 'ghcr.io' \
|
|
--ci-provider github
|
|
RUN --no-cache bluebuild new test-gitlab \
|
|
--image-name test-gitlab \
|
|
--org-name test \
|
|
--description 'This is a description' \
|
|
--registry 'registry.gitlab.com' \
|
|
--ci-provider gitlab
|
|
RUN --no-cache bluebuild new test-none \
|
|
--image-name test-none \
|
|
--org-name test \
|
|
--description 'This is a description' \
|
|
--registry 'docker.io' \
|
|
--ci-provider none \
|
|
--no-git
|
|
|
|
WORKDIR /tmp/test-init
|
|
RUN --no-cache bluebuild init \
|
|
--image-name test-init \
|
|
--org-name test \
|
|
--description 'This is a description' \
|
|
--registry 'docker.io' \
|
|
--ci-provider none \
|
|
--no-git
|
|
|
|
legacy-base:
|
|
FROM ../+blue-build-cli --RELEASE=false
|
|
ENV BB_TEST_LOCAL_IMAGE=/etc/bluebuild/cli_test-legacy.tar.gz
|
|
ENV CLICOLOR_FORCE=1
|
|
|
|
COPY ./mock-scripts/ /usr/bin/
|
|
|
|
WORKDIR /test
|
|
COPY ./legacy-test-repo /test
|
|
|
|
DO ../+INSTALL --OUT_DIR="/usr/bin/" --BUILD_TARGET="x86_64-unknown-linux-musl" --TAGGED="true"
|
|
|
|
DO +GEN_KEYPAIR
|
|
|
|
test-base:
|
|
FROM ../+blue-build-cli --RELEASE=false
|
|
RUN git config --global user.email "you@example.com" && \
|
|
git config --global user.name "Your Name"
|
|
|
|
ENV BB_TEST_LOCAL_IMAGE=/etc/bluebuild/cli_test.tar.gz
|
|
ENV CLICOLOR_FORCE=1
|
|
|
|
ARG MOCK="true"
|
|
IF [ "$MOCK" = "true" ]
|
|
COPY ./mock-scripts/ /usr/bin/
|
|
END
|
|
|
|
WORKDIR /test
|
|
COPY ./test-repo /test
|
|
|
|
DO +GEN_KEYPAIR
|
|
|
|
GEN_KEYPAIR:
|
|
FUNCTION
|
|
# Setup a cosign key pair
|
|
ENV COSIGN_PASSWORD=""
|
|
ENV COSIGN_YES="true"
|
|
RUN cosign generate-key-pair
|
|
ENV COSIGN_PRIVATE_KEY=$(cat cosign.key)
|
|
RUN rm cosign.key
|
|
|
|
RUN_TESTS:
|
|
FUNCTION
|
|
FOR script IN $(ls *.sh)
|
|
RUN --no-cache chmod +x $script \
|
|
&& echo "Running test $script" \
|
|
&& ./$script
|
|
END
|
|
|