Skip to content

Commit 555dce2

Browse files
committed
[DNM] try build multi stage build with tempest promtool
Signed-off-by: Chandan Kumar (raukadah) <[email protected]>
1 parent cc8e980 commit 555dce2

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

Diff for: container-images/tcib/base/os/tempest/tempest-all/tempest-all.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@ tcib_packages:
2525
- qemu-img
2626

2727
tcib_user: tempest
28+
tcib_builder: quay.io/prometheus/prometheus:latest
29+
tcib_builder_copies:
30+
- /bin/promtool:/bin/promtool

Diff for: roles/container_image_build/defaults/main.yml

+6
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,9 @@ tcib_actions: []
7676

7777
# List of Strings, optional, <item>, Collects file from the host and stores them in the build directory.
7878
tcib_gather_files: []
79+
80+
# String, Optional, 'item', Additional params to copy content from different container using buildah multi stage build
81+
tcib_builder: ''
82+
83+
# List of Strings, Optional, items, A list of files to copy from and to respective location seperated by :
84+
tcib_builder_copies: []

Diff for: roles/container_image_build/templates/Containerfile.j2

+8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
# License for the specific language governing permissions and limitations
1414
# under the License.
1515

16+
{% if tcib_builder | length > 0 %}
17+
FROM {{ tcib_builder }} as builder
18+
{% endif %}
1619
FROM {{ tcib_from }}
1720
{% for key, value in tcib_args.items() %}
1821
ARG {{ key }}={{ value | to_json }}
@@ -42,6 +45,11 @@ EXPOSE {{ item }}
4245
{% for item in tcib_copies %}
4346
COPY {{ item }}
4447
{% endfor %}
48+
{% if tcib_builder | length > 0 and tcib_builder_copies | length > 0 %}
49+
{% for item in tcib_builder_copies %}
50+
COPY --from=builder {{ tcib_builder_copies | split(':') | first }} {{ tcib_builder_copies | split(':') | last }}
51+
{% endfor %}
52+
{% endif %}
4553
{% if tcib_shell | length > 0 %}
4654
SHELL {{ tcib_shell.split() | to_json }}
4755
{% endif %}

Diff for: roles/container_image_build/templates/buildahfile.sh.j2

+8
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ set -ev
3434
{% for key, value in tcib_args.items() %}
3535
export {{ key }}={{ value | to_json }}
3636
{% endfor %}
37+
{% if tcib_builder | length > 0 %}
38+
BUILDER_CONTAINER=$(buildah from {{ tcib_builder }})
39+
BUILDER_MOUNTPOINT=$(buildah mount ${BUILDER_CONTAINER})
40+
{% endif %}
3741
CONTAINER=$(buildah from {{ tcib_from }})
3842
MOUNTPOINT=$(buildah mount ${CONTAINER})
3943
{% for key, value in tcib_labels.items() %}
@@ -75,6 +79,10 @@ buildah add ${CONTAINER} {{ item }}
7579
{% for item in tcib_copies %}
7680
buildah copy ${CONTAINER} {{ item }}
7781
{% endfor %}
82+
{% if tcib_builder | length > 0 and tcib_builder_copies | length > 0 %}
83+
{% for item in tcib_builder_copies %}
84+
buildah copy ${BUILDER_CONTAINER} {{ tcib_builder_copies | split(':') | first }} {{ tcib_builder_copies | split(':') | last }}
85+
{% endfor %}
7886
{% for item in tcib_runs %}
7987
{% if item is iterable and item is not string %}
8088
buildah run ${CONTAINER} {{ item | join(' ') }}

0 commit comments

Comments
 (0)