Skip to content

Commit

Permalink
Merge pull request #819 from rhatdan/entrypoint
Browse files Browse the repository at this point in the history
Add entrypoint container images
  • Loading branch information
rhatdan authored Feb 17, 2025
2 parents 53a5994 + 4d209b9 commit c6a91af
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
16 changes: 15 additions & 1 deletion container-images/scripts/build_llama_and_whisper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dnf_install_intel_gpu() {
}

dnf_install() {
local rpm_list=("python3" "python3-pip" "python3-argcomplete" \
local rpm_list=("podman-remote" "python3" "python3-pip" "python3-argcomplete" \
"python3-dnf-plugin-versionlock" "gcc-c++" "cmake" "vim" \
"procps-ng" "git" "dnf-plugins-core" "libcurl-devel")
local vulkan_rpms=("vulkan-headers" "vulkan-loader-devel" "vulkan-tools" \
Expand Down Expand Up @@ -122,6 +122,17 @@ clone_and_build_llama_cpp() {
rm -rf llama.cpp
}

clone_and_build_ramalama() {
# link podman-remote to podman for use by RamaLama
ln -sf /usr/bin/podman-remote /usr/bin/podman
git clone https://github.com/containers/ramalama
cd ramalama
git submodule update --init --recursive
pip install . --prefix=/usr
cd ..
rm -rf ramalama
}

main() {
set -ex

Expand All @@ -134,6 +145,9 @@ main() {
configure_common_flags
common_flags+=("-DGGML_CCACHE=OFF" "-DCMAKE_INSTALL_PREFIX=$install_prefix")
available dnf && dnf_install
if [ -n "$containerfile" ]; then
clone_and_build_ramalama
fi
clone_and_build_whisper_cpp
common_flags+=("-DLLAMA_CURL=ON")
case "$containerfile" in
Expand Down
18 changes: 18 additions & 0 deletions container_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,22 @@ rm_container_image() {
fi
}

add_entrypoint() {
containerfile=$(mktemp)
cat > ${containerfile} <<EOF
FROM $2
ENTRYPOINT [ "/usr/bin/$3.sh" ]
EOF
echo $1 build --no-cache -t "$2-$3" -f ${containerfile} .
eval $1 build --no-cache -t "$2-$3" -f ${containerfile} .
rm ${containerfile}
}

add_entrypoints() {
add_entrypoint "$1" "$2" "whisper-server"
add_entrypoint "$1" "$2" "llama-server"
}

build() {
cd "container-images"
local image_name="${1//container-images\//}"
Expand All @@ -55,13 +71,15 @@ build() {
echo "${conman_build[@]}"
"${conman_build[@]}"
"${conman_show_size[@]}"
add_entrypoints "${conman[@]}" "$REGISTRY_PATH"/"$image_name"
rm_container_image
;;
push)
"${conman[@]}" push "$REGISTRY_PATH/$image_name"
;;
multi-arch)
podman farm build -t "$REGISTRY_PATH"/"$image_name" -f "$image_name"/Containerfile .
add_entrypoints "podman farm" "$REGISTRY_PATH"/"$image_name"
;;
*)
echo "Invalid command: ${2:-}. Use 'build', 'push' or 'multi-arch'."
Expand Down

0 comments on commit c6a91af

Please sign in to comment.