Commit graph

336 commits

Author SHA1 Message Date
Gerald Pinder
3a8d361d4e docs: Update README to revert cargo install instruction since issue is fixed 2024-05-14 10:50:49 -04:00
Gerald Pinder
eddbcb48f7 chore: Release 2024-05-14 10:14:54 -04:00
Gerald Pinder
a3c5b6f06b fix: Create lock on docker setup to prevent race conditions 2024-05-14 10:14:04 -04:00
Gerald Pinder
33f0ff1bfa fix: Don't use '' in format arg 2024-05-12 15:34:16 -04:00
Gerald Pinder
6600d170af feat: Create a bluebuild buildx runner 2024-05-12 13:19:15 -04:00
Gerald Pinder
4374b5f941 fix: Make docker pull latest images when building
This will help with instances where the image was cached already.
2024-05-12 12:03:10 -04:00
Gerald Pinder
f7904e4bde chore: Cleanup install script to instead create the container without running it 2024-05-12 11:47:11 -04:00
Gerald Pinder
2923c417ab chore: Ensure cargo installs use version for build scripts image 2024-05-07 20:16:22 -04:00
Gerald Pinder
55c1b087f7 fix: Add driver args to rebase/upgrade command 2024-05-06 16:53:43 -04:00
Gerald Pinder
5786ce40bf chore: Release 2024-05-05 01:18:08 -04:00
Gerald Pinder
50088db096 chore: Fix release replacements 2024-05-05 01:17:49 -04:00
Gerald Pinder
7ce0ad7cf8
chore: Remove title case (#177) 2024-05-05 00:47:54 -04:00
Gerald Pinder
c2abf3fcb8
fix: Git sha not present during cargo install (#176) 2024-05-05 00:44:22 -04:00
Gerald Pinder
ad7a0f075e chore: Allow tests to pass due to upstream akmods issues 2024-05-05 00:09:09 -04:00
Gerald Pinder
bb5fbdd193 chore: Fix how we get the version in the Earthfile 2024-04-30 16:41:12 -04:00
Gerald Pinder
6c940ea8cd
feat: Add alternate tags for user images (#172)
This adds the ability for the user to add alternate tags to their
images. These are designed to replace the `latest` and timestamp (e.g.
`20240429`) tags.
2024-04-30 09:51:05 -04:00
Gerald Pinder
ac57f9e9f5 chore: Streamline getting version 2024-04-29 23:40:11 -04:00
Gerald Pinder
cfc39817fc chore: Release 2024-04-28 21:56:24 -04:00
Gerald Pinder
83d654d3a2 chore: Improve tagging of images and applying labels 2024-04-28 21:21:54 -04:00
Gerald Pinder
0b5e7599f8 fix: Fix flatpak module errors 2024-04-28 18:56:11 -04:00
Gerald Pinder
76d32bc23a chore: Fix integration tests 2024-04-28 00:36:45 -04:00
Gerald Pinder
232795a932 chore: Pull version using cargo for tag job 2024-04-27 15:41:55 -04:00
Gerald Pinder
d4160fedd9 chore: Remove token from checkout 2024-04-27 15:28:43 -04:00
Gerald Pinder
fbbd2d220a chore: Release 2024-04-27 15:21:48 -04:00
Gerald Pinder
0c7033ccd2
feat: Move module run logic into its own script (#168)
This will help make the Containerfile just a little bit easier to read
(ignoring all the mounts lol). This would also allow us to add logic
later to support modules that run executables other than `*.sh`.
2024-04-27 15:19:58 -04:00
Gerald Pinder
3898202bc3
fix: Pull extra akmods image too (#169)
Adds the new `-extra` image from akmods image
2024-04-27 15:01:06 -04:00
Gerald Pinder
92150693d4
feat: Display full recipe with syntax highlighting (#166)
As I was re-arranging my recipe files, I needed a way to ensure that the
order of my recipe is correct without having to read through the
generated `Containerfile`. So I added a `-d`/`--display-full-recipe` arg
to `template` that will print out all of your modules in the order
defined by following the `from-file` property.

```
$> bluebuild template --help
Generate a Containerfile from a recipe

Usage: bluebuild template [OPTIONS] [RECIPE]

Arguments:
  [RECIPE]
          The recipe file to create a template from

Options:
  -o, --output <OUTPUT>
          File to output to instead of STDOUT

      --registry <REGISTRY>
          The registry domain the image will be published to.

          This is used for modules that need to know where the image is being published (i.e. the signing module).

      --registry-namespace <REGISTRY_NAMESPACE>
          The registry namespace the image will be published to.

          This is used for modules that need to know where the image is being published (i.e. the signing module).

  -d, --display-full-recipe
          Instead of creating a Containerfile, display the full recipe after traversing all `from-file` properties.

          This can be used to help debug the order you defined your recipe.

  -t, --syntax-theme <SYNTAX_THEME>
          Choose a theme for the syntax highlighting for the Containerfile or Yaml.

          The default is `mocha-dark`.

          [possible values: mocha-dark, ocean-dark, ocean-light, eighties-dark, inspired-github, solarized-dark, solarized-light]

  -s, --squash
          Puts the build in a `squash-stage` and COPY's the results to the final stage as one layer.

          WARN: This doesn't work with the docker driver as it has been deprecated.

          NOTE: Squash has a performance benefit for the newer versions of podman and buildah.

  -B, --build-driver <BUILD_DRIVER>
          Select which driver to use to build your image

          [possible values: buildah, podman, docker]

  -v, --verbose...
          Increase logging verbosity

  -I, --inspect-driver <INSPECT_DRIVER>
          Select which driver to use to inspect images

          [possible values: skopeo, podman, docker]

  -q, --quiet...
          Decrease logging verbosity

  -h, --help
          Print help (see a summary with '-h')
```

Preview of Containerfile/Dockerfile syntax highlighting:

![image](https://github.com/blue-build/cli/assets/4626052/cf2c452e-94b1-44f3-97ca-162d50a5047f)

Preview of Yaml highlighting:

![image](https://github.com/blue-build/cli/assets/4626052/b7c48b82-3e9e-431c-a55b-679848cd1fa6)
2024-04-27 09:12:04 -04:00
Gerald Pinder
a7503d561e chore: Make more /var dirs 2024-04-24 23:35:33 -04:00
Gerald Pinder
2bf7c99aaf chore: Use Semver to grab OS version from image 2024-04-24 22:42:44 -04:00
Gerald Pinder
1d05290266 chore: Remove debug logs from utils 2024-04-24 21:16:09 -04:00
Gerald Pinder
29efd47733 chore: Fix tag.yml workflow to pull version from .workspace.package.version 2024-04-22 17:14:01 -04:00
Gerald Pinder
8d140724ae fix: Use shebang in release recipe 2024-04-22 17:07:40 -04:00
Gerald Pinder
8f811200aa chore: Release 2024-04-22 16:50:07 -04:00
Gerald Pinder
c599138982 chore: Prepare justfile for release 2024-04-22 16:49:47 -04:00
Gerald Pinder
71a3bda3c3
chore: Update akmods module to account for upstream changes (#165)
This change updates the akmods module to pull the new nvidia images. The
new property will be a boolean with property name of `nvidia`. If a user
continues to use the old `nvidia-version` property, a warning will be
printed telling them to switch to the new property. The old images will
still be allowed to be used to support backwards compatibility.
2024-04-20 13:00:38 -04:00
Gerald Pinder
4ef0bf9169 fix: Give better errors for read_to_string 2024-04-16 17:34:04 -04:00
Gerald Pinder
7c4c6759ca fix: Create /var/lib/alternatives 2024-04-16 17:17:48 -04:00
Gerald Pinder
9fb2aa1eb9 fix: Create /var/roothome to fix any issues with adding files to /root 2024-04-16 15:02:42 -04:00
Gerald Pinder
2c1d1b9473 fix: Remove /var tmpfs 2024-04-16 13:13:37 -04:00
Gerald Pinder
1b32275a33
fix: Error if any module fails to deserialize (#163)
Previous implementation wasn't taking into account the modules failing
to be read properly and were just being ignored. This changes that to
error out if any `from-file:` usage doesn't deserialize properly.
2024-04-15 09:22:25 -04:00
Gerald Pinder
ff05976917
fix: Add test for rpm-ostree rebase (#161)
Adding this so that we can make sure that `rpm-ostree rebase` tests the
arguments passed in.
2024-04-14 22:59:32 -04:00
Gerald Pinder
f8b7334662
feat: Look for recipes in ./recipes/, build files in ./files/, and Containerfiles in ./containerfiles/ (#157)
Recipe files can now be put into their own directory `./recipes/`. This
directory is NEVER copied into the build so changes to a recipe will no
longer cause cache misses for builds. Here is an example of my build
changing the second to last module and only requiring the last 2 `RUN`
layers to be run again.

```
 => CACHED [stage-config 1/1] COPY ./config /config                                                                                                       0.0s
 => CACHED [stage-modules 1/2] COPY --from=ghcr.io/blue-build/modules:latest /modules /modules                                                            0.0s
 => CACHED [stage-modules 2/2] COPY ./modules /modules                                                                                                    0.0s
 => CACHED [stage-keys 1/1] COPY cosign.pub /keys/jp-desktop-gaming.pub                                                                                   0.0s
 => CACHED [stage-4  2/16] RUN --mount=type=bind,from=stage-keys,src=/keys,dst=/tmp/keys   mkdir -p /usr/etc/pki/containers/   && cp /tmp/keys/* /usr/et  0.0s
 => CACHED [stage-bins 1/3] COPY --from=gcr.io/projectsigstore/cosign /ko-app/cosign /bins/cosign                                                         0.0s
 => CACHED [stage-bins 2/3] COPY --from=docker.io/mikefarah/yq /usr/bin/yq /bins/yq                                                                       0.0s
 => CACHED [stage-bins 3/3] COPY --from=ghcr.io/blue-build/cli:main-installer /out/bluebuild /bins/bluebuild                                              0.0s
 => CACHED [stage-4  3/16] RUN --mount=type=bind,from=stage-bins,src=/bins,dst=/tmp/bins   mkdir -p /usr/bin/   && cp /tmp/bins/* /usr/bin/   && ostree   0.0s
 => CACHED [stage-4  4/16] RUN   --mount=type=tmpfs,target=/var   --mount=type=bind,from=stage-config,src=/config,dst=/tmp/config,rw   --mount=type=bind  0.0s
 => CACHED [stage-4  5/16] RUN   --mount=type=tmpfs,target=/var   --mount=type=bind,from=stage-config,src=/config,dst=/tmp/config,rw   --mount=type=bind  0.0s
 => CACHED [stage-4  6/16] RUN   --mount=type=tmpfs,target=/var   --mount=type=bind,from=stage-config,src=/config,dst=/tmp/config,rw   --mount=type=bind  0.0s
 => CACHED [stage-4  7/16] RUN   --mount=type=tmpfs,target=/var   --mount=type=bind,from=stage-config,src=/config,dst=/tmp/config,rw   --mount=type=bind  0.0s
 => CACHED [stage-4  8/16] RUN   --mount=type=tmpfs,target=/var   --mount=type=bind,from=stage-config,src=/config,dst=/tmp/config,rw   --mount=type=bind  0.0s
 => CACHED [stage-4  9/16] RUN   --mount=type=tmpfs,target=/var   --mount=type=bind,from=stage-config,src=/config,dst=/tmp/config,rw   --mount=type=bind  0.0s
 => CACHED [stage-4 10/16] RUN   --mount=type=tmpfs,target=/var   --mount=type=bind,from=stage-config,src=/config,dst=/tmp/config,rw   --mount=type=bind  0.0s
 => CACHED [stage-4 11/16] RUN   --mount=type=tmpfs,target=/var   --mount=type=bind,from=stage-config,src=/config,dst=/tmp/config,rw   --mount=type=bind  0.0s
 => CACHED [stage-4 12/16] RUN   --mount=type=tmpfs,target=/var   --mount=type=bind,from=stage-config,src=/config,dst=/tmp/config,rw   --mount=type=bind  0.0s
 => CACHED [stage-4 13/16] RUN   --mount=type=tmpfs,target=/var   --mount=type=bind,from=stage-config,src=/config,dst=/tmp/config,rw   --mount=type=bind  0.0s
 => CACHED [stage-4 14/16] RUN   --mount=type=tmpfs,target=/var   --mount=type=bind,from=stage-config,src=/config,dst=/tmp/config,rw   --mount=type=bind  0.0s
 => [stage-4 15/16] RUN   --mount=type=tmpfs,target=/var   --mount=type=bind,from=stage-config,src=/config,dst=/tmp/config,rw   --mount=type=bind,from=  33.4s
 => [stage-4 16/16] RUN   --mount=type=tmpfs,target=/var   --mount=type=bind,from=stage-config,src=/config,dst=/tmp/config,rw   --mount=type=bind,from=s  0.7s
```

Support was also added to put all build files into `./files/` instead of
`./config/`. This is an all or nothing operation, meaning if there
exists a directory of `files` then the `config` directory will be
completely ignored. Work will have to be done in
https://github.com/blue-build/modules to allow users to put their files
directly in `./files/` and not `./files/files` for the `files` module or
`./files/scripts` for the scripts module.

Support was also added to move the `./config/containerfiles/` directory
to the root of the project. Now the directories you can find in the root
of projects are:

```
files/
containerfiles/
recipes/
```
2024-04-13 19:08:31 +00:00
Gerald Pinder
e66e880857
chore: Cleanup images and use hash for exports tag (#158)
I noticed that making changes to the exports script before a release
could cause modules to not build properly if breaking changes got pushed
out. To prevent this, I'm making it so that the hash of the commit is
put in the tag for the exports script image and that the CLI tool will
use that hash when building the `Containerfile`.
2024-04-13 05:55:50 +00:00
Gerald Pinder
b5cca98676 chore: Put LABELS last since they cause cache miss with buildah 2024-04-11 17:21:22 -04:00
Gerald Pinder
6e3a193e92
feat: Squash builds (#155)
### Buildah/Podman support

Buildah and podman can make heavy use of the squash feature. Something
that I've noticed when trying to build from inside of a container,
requiring intermediate layers with mounts causes build times to
skyrocket. Build times are much faster when using the `--squash`
functionality (seen as `--layers=false`).

Here are the following results from my personal build using both squash
and non-squash functionality.

#### Squash upgrade:

```
$> rpm-ostree upgrade
Pulling manifest: ostree-image-signed:docker://registry.gitlab.com/wunker-bunker/wunker-os/jp-laptop
Importing: ostree-image-signed:docker://registry.gitlab.com/wunker-bunker/wunker-os/jp-laptop (digest: sha256:60f743ba322041918d302e7e7f10438c59502e19343c294064bacb676c8eb7b7)
ostree chunk layers already present: 65
custom layers already present: 3
custom layers needed: 1 (814.0 MB)
```

All changes appear to show as a single custom layer. Any small change
even at the end of the build appears to require completely downloading
the new layer (squash only squashes additional layers on top of the base
layer). This makes sense as layers cannot currently be downloaded by
diff.

#### Non-squash upgrade:

```
$> rpm-ostree upgrade
Pulling manifest: ostree-image-signed:docker://registry.gitlab.com/wunker-bunker/wunker-os/jp-desktop-gaming:latest
Importing: ostree-image-signed:docker://registry.gitlab.com/wunker-bunker/wunker-os/jp-desktop-gaming:latest (digest: sha256:0658b51febfcbaa1722961b7a6d2b197d3823a6228e330f45dd1e1aaefd145c5)
ostree chunk layers already present: 65
custom layers already present: 4
custom layers needed: 15 (942.4 MB)
```

As expected, there are more layers when not squashing and the size is
slightly bigger. Most likely due to there being extra information stored
in the layers that is subsequently removed.

### Docker support

Docker is apparently [no longer
supporting](https://github.com/docker/buildx/issues/1287) the use of the
`--squash` arg. The use of squash will not be available for the docker
driver in this case.
2024-04-11 19:15:30 +00:00
Gerald Pinder
e9c96e204d
feat: Add driver selection args (#153)
There are 2 new args available that allow the user to specify which
program to use for building and inspecting images. If the user doesn't
provide an argument, the tool will determine which program to use like
it has been.

Help text:

```
Build an image from a recipe

Usage: bluebuild build [OPTIONS] [RECIPE]

Arguments:
  [RECIPE]
          The recipe file to build an image

Options:
  -p, --push
          Push the image with all the tags.

          Requires `--registry`, `--username`, and `--password` if not building in CI.

  -c, --compression-format <COMPRESSION_FORMAT>
          The compression format the images will be pushed in

          [default: gzip]
          [possible values: gzip, zstd]

  -n, --no-retry-push
          Block `bluebuild` from retrying to push the image

      --retry-count <RETRY_COUNT>
          The number of times to retry pushing the image

          [default: 1]

  -f, --force
          Allow `bluebuild` to overwrite an existing Containerfile without confirmation.

          This is not needed if the Containerfile is in .gitignore or has already been built by `bluebuild`.

  -a, --archive <ARCHIVE>
          Archives the built image into a tarfile in the specified directory

      --registry <REGISTRY>
          The registry's domain name

  -v, --verbose...
          Increase logging verbosity

  -q, --quiet...
          Decrease logging verbosity

      --registry-namespace <REGISTRY_NAMESPACE>
          The url path to your base project images

          [aliases: registry-path]

  -U, --username <USERNAME>
          The username to login to the container registry

  -P, --password <PASSWORD>
          The password to login to the container registry

  -B, --build-driver <BUILD_DRIVER>
          Select which driver to use to build your image

          [possible values: buildah, podman, docker]

  -I, --inspect-driver <INSPECT_DRIVER>
          Select which driver to use to inspect images

          [possible values: skopeo, podman, docker]

  -h, --help
          Print help (see a summary with '-h')
```
2024-04-07 22:15:33 -04:00
Gerald Pinder
0f76b16369 chore: Remove unused files module 2024-04-05 16:43:49 -04:00
Gerald Pinder
05980ee82d fix: Use proper image URI for local rebasing 2024-04-01 17:27:04 -04:00
Michael Haaf
d5f0332d7c
README: add alpine distrobox and shell completions (#149)
A few more tips/tricks I wrote for
https://github.com/blue-build/website/pull/45 that make more sense in
the README
2024-03-31 13:07:58 -04:00
Jordan Pryde
1074a54672
fix: Sign all images in manifest (#148)
Resolves #147

`cosign sign` only signs the provided digest by default. If that digest
is a manifest which is currently the default for images built with
Docker due to
https://docs.docker.com/build/attestations/attestation-storage/, we also
want to sign each image with `--recursive` so that they can be pulled by
any container managers which enforce that (e.g. podman).

Refer to https://github.com/sigstore/cosign/blob/main/doc/cosign_sign.md
for more details.

Co-authored-by: Gerald Pinder <gmpinder@gmail.com>
2024-03-29 19:54:37 -04:00