Commit graph

45 commits

Author SHA1 Message Date
dependabot[bot]
a52d0b6a4b chore(deps): bump directories from 5.0.1 to 6.0.0
Bumps [directories](https://github.com/soc/directories-rs) from 5.0.1 to 6.0.0.
- [Commits](https://github.com/soc/directories-rs/commits)

---
updated-dependencies:
- dependency-name: directories
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-13 09:25:19 -05:00
Gerald Pinder
cbb6efd14d chore: Switch to using my new proc_macro comlexr 2025-01-12 16:15:29 -05:00
Gerald Pinder
2d150e3c93 feat: Support versioned modules 2025-01-05 13:33:11 -05:00
Gerald Pinder
74bd05643f feat: Add support for NuShell scripts 2025-01-05 13:31:29 -05:00
RoyalOughtness
4d18e7e1d4
fix: use ghcr for cosign (#304)
Co-authored-by: Gerald Pinder <gmpinder@gmail.com>
2024-12-21 19:09:50 -05:00
Gerald Pinder
50ed183cde feat: Allow fresh rechunking of image 2024-12-16 21:07:09 -05:00
dependabot[bot]
99ba74f15c chore(deps): bump which from 6.0.3 to 7.0.0
Bumps [which](https://github.com/harryfei/which-rs) from 6.0.3 to 7.0.0.
- [Release notes](https://github.com/harryfei/which-rs/releases)
- [Changelog](https://github.com/harryfei/which-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/harryfei/which-rs/compare/6.0.3...7.0.0)

---
updated-dependencies:
- dependency-name: which
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-12 21:38:26 -05:00
Gerald Pinder
752c957914 chore: Remove need to update .gitignore by making use of temporary directories 2024-11-07 00:01:23 -05:00
Gerald Pinder
1481fba40a feat: Use yaml-rust2 to get line numbers for better errors 2024-11-04 07:10:09 -05:00
Gerald Pinder
32092195d3
chore: Cleanup workflows to be run from just (#238) 2024-10-07 16:34:36 -04:00
Bob Callaway
2aa888d3a1
fix: switch cosign registry from GCR to GHCR (#237)
This changes the Dockerfile to pull the cosign container image from GHCR
instead of Google Cloud. This helps the Sigstore team manage their cloud
spend (as GHCR is provided for free and Google Cloud Artifact Registry
is not).

Note the container hash does not change and images are posted to both
locations upon cosign's release process.
2024-10-06 09:20:36 -04:00
Gerald Pinder
75eae89e4a feat: Add platform arg to force building a specific architecture 2024-10-03 14:47:47 -04:00
Gerald Pinder
65e1ccffaf chore: Make build.rs run again on git change 2024-09-23 12:29:53 -04:00
Gerald Pinder
486961f3d3 fix: Make sigstore driver more resilient to network errors 2024-09-21 18:57:57 -04:00
Gerald Pinder
0c52cf6a54 refactor: Swtich to using bon for builder pattern 2024-09-21 18:42:28 -04:00
Gerald Pinder
020f89d4d1 fix: Fix docker login for oauth logins 2024-09-11 18:33:56 -04:00
Gerald Pinder
9ed47c0884 fix: Properly handle alt-tags so they don't collide with default tags 2024-08-25 14:08:39 -04:00
Gerald Pinder
04972416cb fix: Make sure GitHub job pushes latest image on scheduled job 2024-08-24 18:20:12 -04:00
Gerald Pinder
50ba091ed0 fix: Include $crate for macro calls 2024-08-15 22:25:02 -04:00
Gerald Pinder
8ce83ba7ff
refactor: Create SigningDriver and CiDriver (#197)
This also includes a new `login` command. The signing and CI logic is now using the Driver trait system along with a new experimental sigstore signing driver. New static macros have also been created to make implementation management easier for `Command` usage and `Driver` trait implementation calls.

---------

Co-authored-by: xyny <60004820+xynydev@users.noreply.github.com>
2024-08-12 23:52:07 -04:00
Gerald Pinder
464fdf94a9 fix: Out of bounds panic when not retrying push 2024-08-11 10:37:17 -04:00
Gerald Pinder
e36bb74231 fix: Builds failing due to new Rust version 2024-07-26 15:44:29 -04:00
Gerald Pinder
065fa193e3
refactor: Switch to using miette for errors instead of anyhow (#198)
Switch to a better error crate that will allow setting help texts for
any error we want.
2024-07-05 21:55:43 -04:00
Gerald Pinder
784be9869a
feat: Create RunDriver (#196)
This will be used for running containers for various tasks. There will
be a way to take all output from the process and a way to display output
from a running container like our builds have.
2024-07-05 19:20:38 -04:00
Gerald Pinder
7a563f42da
fix: Support other signals properly (#194) 2024-06-23 18:29:46 -04:00
Gerald Pinder
235b3b358c
fix: Add Ctrl-C handler for spawned children (#193)
This allows spawned children processes to be killed when a user performs
a Ctrl-C operation. Before this change, children processes would end up
continuing in the background with the user unaware.
2024-06-17 20:07:52 -04:00
Gerald Pinder
4ca98c1c2a
feat(experimental): Build multiple recipes in parallel (#182)
The `build` subcommand can now take in any number of recipe files and
will build them all in parallel. Along with this new ability, I've added
a way to easily distinguish which part of the build log belongs to which
recipe. Check out the `docker_build` action of this PR for an example.


![gif](https://gitlab.com/wunker-bunker/wunker-os/-/raw/main/bluebuild.gif)

## Tasks

- [x] Make build log follow same pattern as normal logs to keep things
consistent
- [x] Update color ranges based on @xynydev 's feedback
- [x] Deal with ANSI control characters in log output
- [x] Add [`indicatif`](https://crates.io/crates/indicatif) to make logs
look nicer
- [x] Add ability to print logs to a file
2024-06-07 17:52:26 -04:00
Gerald Pinder
0b29929e93
fix: Fail if cosign private/public key can't be verified (#190) 2024-06-01 19:05:14 -04:00
Gerald Pinder
9dd1ec90f4
fix: Remove hard requirement for login creds to be able to push (#187)
Related to https://github.com/blue-build/github-action/issues/48
2024-05-28 22:56:06 -04:00
Gerald Pinder
02b2fe5434
refactor!: Rename template to generate and move rebase/upgrade under switch (#116)
This updates the `template` subcommand to be `generate`. The `template`
usage will continue to work as an alias to `generate`. A new `switch`
command is added that will manage both `rpm-ostree rebase` and
`rpm-ostree upgrade` and is fully replacing the respective subcommands
as a breaking change.

The new `switch` command is under the feature flag `switch` and will
currently only build for the `main` branch builds until it is moved as a
default feature (`v0.9.0`).

Closes #159
2024-05-26 22:47:34 -04:00
Gerald Pinder
8069006c03
feat: Stages (#173)
## Stages

A new property (`stages`) is being added to the recipe file schema. This
property will allow users to define a list of Containerfile stages each
with their own modules. Stages can be used to compile programs, perform
parallel operations, and copy the results into the final image without
contaminating the final image.

### Module Support

Currently the only modules that work out-of-the-box are `copy`,
`script`, `files`, and `containerfile`. Other modules are dependent on
the programs installed on the image. In order to better support some of
our essential modules, a setup script is ran at the start of each stage
that is not `scratch`. This script will install `curl`, `wget`, `bash`,
and `grep` and use the package manager for the detected distributions.

At this time, the following distributions are supported:

- Debian
- Ubuntu
- Fedora
- Alpine

Contributions to increase the size of this list is
[welcome](https://github.com/blue-build/cli)!

### Syntax

- **Required**
- `from` - The full image ref (image name + tag). This will be set in
the `FROM` statement of the stage.
- `name` - The name of the stage. This is used when referencing the
stage when using the `from:` property in the `copy` module.
- `modules` - The list of modules to execute. The exact same syntax used
by the main recipe `modules:` property.
- **Optional**
- `shell` - Allows a user to pass in an array of strings that are passed
directly into the [`SHELL`
instruction](https://docs.docker.com/reference/dockerfile/#shell).

#### Example

```yaml
stages:
- name: ubuntu-test
  from: ubuntu
  modules:
  - type: files
    files:
    - usr: /usr
  - type: script
    scripts:
    - example.sh
    snippets:
    - echo "test" > /test.txt
  - type: test-module
  - type: containerfile
    containerfiles:
    - labels
    snippets:
    - RUN echo "This is a snippet"
```

### Tasks
- [x] `from-file:` - Allows the user to store their stages in a separate
file so it can be included in multiple recipes
- [x] `no-cache:` - This will be useful for stages that want to pull the
latest changes from a git repo and not have to rely on the base image
getting an update for the build to be triggered again.
- [x] Add setup script to be able to install necessary programs to run
`bluebuild` modules in stages
- [x] Check for circular dependencies and error out

## `copy` module

This is a 1-1 for the [`COPY`
instruction](https://docs.docker.com/reference/dockerfile/#copy). It has
the ability to copy files between stages, making this a very important
addition to complete functionality for the stages feature. Each use of
this "module" will become its own layer.

### Decision to use `--link`

We use the `--link`
[option](https://docs.docker.com/reference/dockerfile/#benefits-of-using---link)
which allows that layer to have the same hash if the files haven't
changed regardless of if the previous instructions have changed. This
allows these layers to not have to be re-downloaded on the user's
computer if the copied files haven't changed.

### Syntax

- **Required**
- `src` - The source directory/file from the repo OR when `from:` is set
the image/stage that is specified.
  - `dest` - The destination directory/file inside the working image.
- **Optional**
  - `from` - The stage/image to copy from.

#### Example

```yaml
modules:
- type: copy
  from: ubuntu-test
  src: /test.txt
  dest: /
```

### Tasks
- [x] make `from:` optional
- [x] Add README.md and module.yml

## Feature gating

Gating this feature until we release for `v0.9.0`. The plan will be to
build all features (including this one) for main branch builds. This
means that these features will be available when using the `main` image
and consequently the `use_unstable_cli:` option on the GitHub Action.
All future `v0.9.0` features will be gated as well to allow for patches
to `v0.8`.

### Tasks
- [x] Build `--all-features` on non-tagged builds
- [x] Add stages and copy features
2024-05-18 13:23:50 +00:00
Gerald Pinder
73f219d4ca fix: Don't create builder if DOCKER_HOST is set 2024-05-14 13:50:33 -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
1d05290266 chore: Remove debug logs from utils 2024-04-24 21:16:09 -04:00
Gerald Pinder
c599138982 chore: Prepare justfile for release 2024-04-22 16:49:47 -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
8050ce73ee chore: Release 2024-03-27 19:46:03 -04:00
Gerald Pinder
189141924b
feat: Improve logging output (#139) 2024-03-26 12:23:10 -04:00
Gerald Pinder
a54b78c8dc refactor: Enable pedantic clippy lints
Updated files to comply with the new lint.
2024-03-12 18:07:46 -04:00
Hikari
580c3d6ce7
fix: use container skopeo (#110)
the `os_version` is defaulting to the `image_tag` inside containers and
causing our template to use latest tag

---------

Co-authored-by: Gerald Pinder <gmpinder@gmail.com>
2024-03-11 23:23:42 +00:00
Gerald Pinder
8753e76eeb chore: Prepare for v0.8.2 release 2024-03-08 19:37:08 -05:00
Gerald Pinder
b169dbacbb chore: Update crates to have their own versions starting at CLI version 2024-03-08 19:32:39 -05:00
Gerald Pinder
e6f97d4258
fix: Add org.opencontainers.image.source LABEL for CI images (#113) 2024-03-03 11:01:24 +00:00
Gerald Pinder
0ba78fab32
refactor: Update build command to use BuildStrategy (#88) 2024-03-01 11:18:02 -06:00
Gerald Pinder
910e0434b6
refactor: Move templates to their own crate (#83)
This PR logically separates out parts of the code to their own crates. This will be useful for future Tauri App development.
2024-02-25 14:45:33 -06:00