Skip to content

Commit 97b6dac

Browse files
committed
add option --remove-images
1 parent 1c312b4 commit 97b6dac

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

.github/workflows/build_images.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ jobs:
3838
docker images
3939
- name: Build Docker Images
4040
run: |
41-
./build_images.py --branch '${{ github.event.inputs.branch }}' --repo '${{ github.event.inputs.repo }}' --root-image-name '${{ github.event.inputs.root_image_name }}'
41+
./build_images.py \
42+
--branch '${{ github.event.inputs.branch }}' \
43+
--repo '${{ github.event.inputs.repo }}' \
44+
--root-image-name '${{ github.event.inputs.root_image_name }}'
4245
- name: Show Building Graph
4346
run: |
4447
cat graph.yaml

.github/workflows/build_images_regular.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Build Docker Images Regularly
2525
run: |
2626
df -lh
27-
./build_images.py --branch "" --repo "" --root-image-name ""
27+
./build_images.py --branch "" --repo "" --root-image-name "" --remove-images
2828
cat graph.yaml
2929
df -lh
3030
- name: Set Environment Variable

build_images.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ def parse_args(args=None, namespace=None) -> Namespace:
6161
required=True,
6262
help="The name of the base/root Docker image in dependency resolving.",
6363
)
64+
parser.add_argument(
65+
"--remove-images",
66+
dest="remove_images",
67+
action="store_true",
68+
help="Remove a Docker image when it's not needed (for building other images).",
69+
)
6470
return parser.parse_args(args=args, namespace=namespace)
6571

6672

@@ -73,7 +79,7 @@ def main() -> None:
7379
args.branch = "dev"
7480
branch_urls = {args.branch: {args.repo: args.root_image_name}}
7581
builder = DockerImageBuilder(branch_urls)
76-
builder.build_images(remove=True)
82+
builder.build_images(remove=args.remove_images)
7783
builder.save_graph()
7884

7985

0 commit comments

Comments
 (0)