Skip to content

Commit 2b73546

Browse files
authored
Squash image layers to save disk space (#366)
Related: containers/podman#5806
1 parent 5849030 commit 2b73546

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

.github/actions/build-test/action.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ runs:
4646
ansible-builder create -f ${{ github.workspace }}/execution-environment.yml --output-filename Containerfile -v3
4747
4848
- name: Build base image for ${{ matrix.platform }}
49-
uses: docker/build-push-action@v5
49+
uses: docker/build-push-action@v6
5050
id: build-base
5151
with:
5252
context: context
@@ -66,7 +66,7 @@ runs:
6666
6767
- name: Build final image for ${{ matrix.platform }}
6868
id: build-final
69-
uses: docker/build-push-action@v5
69+
uses: docker/build-push-action@v6
7070
with:
7171
context: ${{ github.workspace }}/final
7272
provenance: false
@@ -80,6 +80,12 @@ runs:
8080
cache-from: type=gha,scope=build-${{ env.PLATFORM_PAIR }}
8181
cache-to: type=gha,scope=build-${{ env.PLATFORM_PAIR }}
8282

83+
- name: Squash image layers to save disk space
84+
shell: bash
85+
run: |
86+
python3 -m pip install --upgrade docker-squash
87+
docker-squash ${{ inputs.namespace }}/${{ inputs.final_image }}:test
88+
8389
- name: Run tests against the container
8490
shell: bash
8591
run: |
@@ -90,7 +96,7 @@ runs:
9096
- name: Push the built image to ${{ inputs.registry }} by digest for ${{ matrix.platform }}
9197
id: push-final
9298
if: inputs.push == 'true'
93-
uses: docker/build-push-action@v5
99+
uses: docker/build-push-action@v6
94100
with:
95101
context: ${{ github.workspace }}/final
96102
provenance: false

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,4 @@ _readthedocs
176176

177177
# ansible-builder
178178
context
179+
collections

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ commands_pre =
122122
commands =
123123
python -m build --outdir {toxinidir}/final/dist/ --wheel {toxinidir}
124124
ansible-builder create -f execution-environment.yml --output-filename Containerfile -v3
125-
podman build context/ --tag community-ansible-dev-tools-base:latest
126-
podman build final/ --tag community-ansible-dev-tools:test
125+
podman build --squash-all context/ --tag community-ansible-dev-tools-base:latest
126+
podman build --squash-all final/ --tag community-ansible-dev-tools:test
127127
pytest --only-container --image-name community-ansible-dev-tools:test
128128
allowlist_externals =
129129
podman

0 commit comments

Comments
 (0)