Skip to content

Commit ed2d303

Browse files
mikebonnetieaves
authored andcommitted
build layered images from Containerfiles
Move the Containerfiles for the entrypoint and rag images out of container_build.sh and into their own files. This is necessary so they can be built with Konflux. Signed-off-by: Mike Bonnet <[email protected]>
1 parent f6c318e commit ed2d303

File tree

3 files changed

+26
-22
lines changed

3 files changed

+26
-22
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
ARG PARENT
2+
FROM $PARENT
3+
4+
ARG ENTRYPOINT
5+
ENV ENTRYPOINT="$ENTRYPOINT"
6+
7+
ENTRYPOINT exec $ENTRYPOINT
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
ARG PARENT
2+
FROM $PARENT
3+
4+
ARG GPU
5+
6+
USER root
7+
RUN /usr/bin/build_rag.sh "$GPU"
8+
ENTRYPOINT []

container_build.sh

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,19 @@ add_entrypoint() {
4848
tag=$tag-$4
4949
fi
5050
tag=$tag-$3
51-
containerfile=$(mktemp)
52-
cat > "${containerfile}" <<EOF
53-
FROM $2
54-
ENTRYPOINT [ "/usr/bin/$3.sh" ]
55-
EOF
56-
echo "$1 build ${nocache} -t $tag -f ${containerfile} ."
57-
eval "$1 build ${nocache} -t $tag -f ${containerfile} ."
58-
rm "${containerfile}"
51+
containerfile="container-images/common/Containerfile.entrypoint"
52+
build_args=("--build-arg" "PARENT=$2" "--build-arg" "ENTRYPOINT=/usr/bin/${3}.sh")
53+
echo "$1 build ${nocache} ${build_args[*]} -t $tag -f ${containerfile} ."
54+
eval "$1 build ${nocache} ${build_args[*]} -t $tag -f ${containerfile} ."
5955
}
6056

6157
add_rag() {
6258
tag="$2"
6359
if [ -n "$3" ]; then
6460
tag=$tag-$3
6561
fi
66-
containerfile=$(mktemp)
62+
tag=$tag-rag
63+
containerfile="container-images/common/Containerfile.rag"
6764
GPU=cpu
6865
case $2 in
6966
cuda)
@@ -79,17 +76,9 @@ add_rag() {
7976
GPU=cpu
8077
;;
8178
esac
82-
cat > "${containerfile}" <<EOF
83-
ARG REGISTRY_PATH=quay.io/ramalama
84-
FROM ${REGISTRY_PATH}/$2
85-
86-
USER root
87-
RUN /usr/bin/build_rag.sh ${GPU}
88-
ENTRYPOINT []
89-
EOF
90-
echo "$1 build ${nocache} -t ${REGISTRY_PATH}/$tag-rag -f ${containerfile} ."
91-
eval "$1 build ${nocache} -t ${REGISTRY_PATH}/$tag-rag -f ${containerfile} ."
92-
rm "${containerfile}"
79+
build_args=("--build-arg" "PARENT=$2" "--build-arg" "GPU=$GPU")
80+
echo "$1 build ${nocache} ${build_args[*]} -t $tag -f ${containerfile} ."
81+
eval "$1 build ${nocache} ${build_args[*]} -t $tag -f ${containerfile} ."
9382
}
9483

9584
add_entrypoints() {
@@ -121,7 +110,7 @@ build() {
121110
*)
122111
if [ "${build_all}" -eq 1 ]; then
123112
add_entrypoints "${conman[@]}" "${REGISTRY_PATH}"/"${target}" "${version}"
124-
add_rag "${conman[@]}" "${target}" "${version}"
113+
add_rag "${conman[@]}" "${REGISTRY_PATH}"/"${target}" "${version}"
125114
rm_container_image
126115
fi
127116
esac
@@ -215,7 +204,7 @@ process_all_targets() {
215204
for i in ./container-images/*; do
216205
i=$(basename "$i")
217206
# skip these directories
218-
if [[ "$i" =~ ^(scripts|ramalama)$ ]]; then
207+
if [[ "$i" =~ ^(scripts|ramalama|common)$ ]]; then
219208
continue
220209
fi
221210

0 commit comments

Comments
 (0)