Skip to content
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

Add support for specifing multiple build paths #1192

Merged
merged 1 commit into from
Aug 26, 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
24 changes: 19 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,38 @@ The following steps are a guideline for modifying/creating Dockerfiles.
Team code owners must be assigned to each Dockerfile for maintenance and issue assignment purposes.

2. Validate the changes locally by running [build.ps1](./build.ps1).
It is strongly suggested to specify the `-DockerfilePath` option to avoid the overhead of building all the images.
It is strongly suggested to specify the `-Paths` option to avoid the overhead of building all the images.

For example, if editing the [Fedora 40 Dockerfile](./src/fedora/40/amd64/Dockerfile), then run the following command to build just that Dockerfile.

```powershell
.\build.ps1 -DockerfilePath "*fedora/40/amd64*"
.\build.ps1 -Paths "*fedora/40/amd64*"
```

It is a good practice to use `--dry-run` option on the first attempt to verify what commands will get run.

```powershell
.\build.ps1 -DockerfilePath "*fedora/40/amd64*" -ImageBuilderCustomArgs "--dry-run"
.\build.ps1 -Paths "*fedora/40/amd64*" -OptionalImageBuilderArgs "--dry-run"
```

Partial paths and wildcards in the `-DockerfilePath` option are also supported. The following example will build all the Fedora Dockerfiles.
Partial paths and wildcards in the `-Paths` option are also supported. The following example will build all the Fedora Dockerfiles.

```powershell
.\build.ps1 -DockerfilePath "*fedora/*"
.\build.ps1 -Paths "*fedora/*"
```

To build a dependency graph when there are [dependent images](#image-dependency), multiple paths can be specified.

```powershell
.\build.ps1 -Paths "*alpine/3.20/amd64*","*alpine/3.20/withnode/amd64*"
```

Alternatively, wildcards can by utilized to specify everything under a shared directory.
Using wildcards can sometimes cause extra images to be built outside of the dependency graph which may be undersirable.
In this case, it is recommended to utilize the multiple `paths` approach.

```powershell
.\build.ps1 -Paths "*alpine/3.20*"
```

3. Prepare a PR
Expand Down
9 changes: 6 additions & 3 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
[cmdletbinding()]
param(
[string]$DockerfilePath = "*",
[string]$ImageBuilderCustomArgs
# Paths to the Dockerfiles to build
[string[]]$Paths,

# Additional args to pass to ImageBuilder
[string]$OptionalImageBuilderArgs
)

Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
pushd $PSScriptRoot
try {
./eng/common/Invoke-ImageBuilder.ps1 "build --path '$DockerfilePath' $ImageBuilderCustomArgs"
./eng/common/build.ps1 -Paths $Paths -OptionalImageBuilderArgs $OptionalImageBuilderArgs
}
finally {
popd
Expand Down