Skip to content

feat: Add --target-containerfile argument #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ repos:
language: python
'types': [python]
pass_filenames: false
stages: [commit]
stages: [pre-commit]
49 changes: 29 additions & 20 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,34 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

## Added

- Add `--target-containerfile` argument to override the default `Dockerfile` value ([#44]).

[#44]: https://github.com/stackabletech/image-tools/pull/44

## 0.0.13 - 2024-09-06

### Added

- `conf.py` now can contain a `args` dict, which contains arguments available to all products, they can be overridden by product specific or CLI arguments ([#41])
- `conf.py` now can contain a `args` dict, which contains arguments available to all products, they
can be overridden by product specific or CLI arguments ([#41]).

### Fixed

- `--build-arg` was not case-insensitive as claimed in the docs, this has been fixed ([#41])
- `--build-arg` was not case-insensitive as claimed in the docs, this has been fixed ([#41]).

[#41]: https://github.com/stackabletech/image-tools/pull/41

## [0.0.12] - 2024-07-08

### Added

- New `bake` command line argument `--build-arg` to override conf.py build arguments ([#38])
- New `bake` command line argument `--build-arg` to override conf.py build arguments ([#38]).

### Fixed

- check-container: fix regression introduced by 0.0.9. Add dummy cache property ([#39])
- check-container: fix regression introduced by 0.0.9. Add dummy cache property ([#39]).

[#38]: https://github.com/stackabletech/image-tools/pull/38
[#39]: https://github.com/stackabletech/image-tools/pull/39
Expand All @@ -33,16 +40,16 @@ All notable changes to this project will be documented in this file.

### Added

- Automatically create labels and annotations recording the git revision and build time ([#34])
- Automatically create labels and annotations recording the git revision and build time ([#34]).

[#34]: https://github.com/stackabletech/image-tools/pull/34

## [0.0.10] - 2024-07-03

### Fixed

- Add architecture identifier to the build cache backend ref name ([#31])
- Backwards compat: don't assume conf.cache exists ([#32])
- Add architecture identifier to the build cache backend ref name ([#31]).
- Backwards compat: don't assume conf.cache exists ([#32]).

[#31]: https://github.com/stackabletech/image-tools/pull/31
[#32]: https://github.com/stackabletech/image-tools/pull/32
Expand All @@ -51,21 +58,22 @@ All notable changes to this project will be documented in this file.

### Added

- New command line arg to `bake`: `--cache`. Requires cache backend configuration in conf.py ([#29])
- New command line arg to `bake`: `--cache`. Requires cache backend configuration in
`conf.py` ([#29]).

[#29]: https://github.com/stackabletech/image-tools/pull/29

## [0.0.8] - 2024-07-02

### Added

- New command line arg to `bake`: `--version`. Also switch to relative imports. ([#17])
- Raise lint dependency versions ([#17])
- Drop support for python 3.10 and add explicit support for 3.12 ([#17])
- New command line arg to `bake`: `--version`. Also switch to relative imports ([#17]).
- Raise lint dependency versions ([#17]).
- Drop support for python 3.10 and add explicit support for 3.12 ([#17]).

### Fixed

- Use cwd in module path so imports in conf.py work ([#27])
- Use cwd in module path so imports in `conf.py` work ([#27]).

[#17]: https://github.com/stackabletech/image-tools/pull/17
[#27]: https://github.com/stackabletech/image-tools/pull/27
Expand All @@ -74,47 +82,48 @@ All notable changes to this project will be documented in this file.

### Fixed

- Invalid 'buildx bake' configuration file generated due to architecture not being a list anymore. ([#13])
- Invalid 'buildx bake' configuration file generated due to architecture not being a list
anymore ([#13]).

[#13]: https://github.com/stackabletech/image-tools/pull/13

## [0.0.6] - 2024-04-24

### Changed

- Add platform argument for preflight checks ([#12])
- Add platform argument for preflight checks ([#12]).

[#12]: https://github.com/stackabletech/image-tools/pull/12

## [0.0.5] - 2023-10-19

### Changed

- Relax schema for image tags ([#7])
- Relax schema for image tags ([#7]).

[#7]: https://github.com/stackabletech/image-tools/pull/7

## [0.0.4] - 2023-10-17

### Added

- New `bake` argument (`--export-tags-file`) to write target tags to text file ([#4])
- New `bake` argument (`--export-tags-file`) to write target tags to text file ([#4]).

### Changed

- Changed `conf` schema to drop support for versions as strings. Only dicts are supported ([#4])
- Changed `conf` schema to drop support for versions as strings. Only dicts are supported ([#4]).

[#4]: https://github.com/stackabletech/image-tools/pull/4

## [0.0.3] - 2023-10-16

### Added

- Allow `bake` product names to accept a version as suffix separated by "=" ([#2])
- New `bake` command line options `--shard-index` and `--shard-count` ([#2])
- Allow `bake` product names to accept a version as suffix separated by "=" ([#2]).
- New `bake` command line options `--shard-index` and `--shard-count` ([#2]).

### Changed

- Make stackable image version (`-i`) for `bake` optional and default to `0.0.0-dev` ([#2])
- Make stackable image version (`-i`) for `bake` optional and default to `0.0.0-dev` ([#2]).

[#2]: https://github.com/stackabletech/image-tools/pull/2
7 changes: 7 additions & 0 deletions src/image_tools/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ def bake_args() -> Namespace:
type=check_build_arg,
)

parser.add_argument(
"--target-containerfile",
help="Override the target containerfile used, points to <PRODUCT>/<TARGET_CONTAINERFILE>. Default: Dockerfile",
default="Dockerfile",
)

result = parser.parse_args()

if result.shard_index >= result.shard_count:
Expand Down Expand Up @@ -239,6 +245,7 @@ def load_configuration(conf_file_name: str, cli_build_args: List[Tuple[str, str]
return module
raise ImportError(name=module_name, path=conf_file_name)


def assemble_final_build_args(conf: ModuleType, cli_build_args: List[Tuple[str, str]] = []) -> None:
cli_build_args = cli_build_args or []
# Convert user_build_args to a dictionary with lowercase keys for easier, case-insensitive lookup
Expand Down
2 changes: 1 addition & 1 deletion src/image_tools/bake.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def bakefile_product_version_targets(
"build-date": rfc3339_date_time,
"org.opencontainers.image.revision": revision,
},
"dockerfile": f"{product_name}/Dockerfile",
"dockerfile": f"{product_name}/{args.target_containerfile}",
"tags": tags,
"args": build_args,
"platforms": [args.architecture],
Expand Down