Skip to content

Commit c166c0a

Browse files
committed
Begin process of packaging PRAGmatic
Building Pragmatic into a container image is fairly easy. podman build --build-arg IMAGE=quay.io/ramalama/rocm -t quay.io/ramalama/rocm-rag container-images/pragmatic Signed-off-by: Daniel J Walsh <[email protected]>
1 parent 03cbf9b commit c166c0a

File tree

4 files changed

+75
-5
lines changed

4 files changed

+75
-5
lines changed

.github/workflows/ci-images.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,4 @@ jobs:
6969
7070
- name: Build Images
7171
run: |
72-
make build_rm
72+
make build-rm

Makefile

+21-4
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,27 @@ SHAREDIR ?= ${PREFIX}/share
77
PYTHON ?= $(shell command -v python3 python|head -n1)
88
DESTDIR ?= /
99
PATH := $(PATH):$(HOME)/.local/bin
10-
10+
IMAGE ?= ramalama
11+
GPU ?= cpu
1112

1213
default: help
1314

1415
help:
15-
@echo "Build Container"
16+
@echo "Build Container Image"
1617
@echo
1718
@echo " - make build"
1819
@echo " - make build IMAGE=ramalama"
1920
@echo " - make multi-arch"
2021
@echo " - make multi-arch IMAGE=ramalama"
2122
@echo
23+
@echo "Build RAG Container Image"
24+
@echo
25+
@echo " - make build-rag IMAGE=quay.io/ramalama/ramalama GPU=ramalama"
26+
@echo
27+
@echo "Build Docling Container Image"
28+
@echo
29+
@echo " - make build-docling IMAGE=quay.io/ramalama/ramalama GPU=ramalama"
30+
@echo
2231
@echo "Build docs"
2332
@echo
2433
@echo " - make docs"
@@ -79,14 +88,22 @@ install: docs completions
7988
build:
8089
./container_build.sh build $(IMAGE)
8190

82-
.PHONY: build_rm
83-
build_rm:
91+
.PHONY: build-rm
92+
build-rm:
8493
./container_build.sh -r build $(IMAGE)
8594

8695
.PHONY: build_multi_arch
8796
build_multi_arch:
8897
./container_build.sh multi-arch $(IMAGE)
8998

99+
.PHONY: build-rag
100+
build-rag:
101+
podman build --build-arg IMAGE=${IMAGE} --build-arg GPU=${GPU} -t ${IMAGE}-rag container-images/pragmatic
102+
103+
.PHONY: build-docling
104+
build-docling:
105+
podman build --build-arg IMAGE=${IMAGE} --build-arg CONTENT=docling --build-arg GPU=${GPU} -t ${IMAGE}-docling container-images/pragmatic
106+
90107
.PHONY: install-docs
91108
install-docs: docs
92109
make -C docs install
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
ARG IMAGE=quay.io/ramalama/ramalama:latest
2+
FROM $IMAGE
3+
4+
ARG GPU=cpu
5+
ARG CONTENT=rag
6+
COPY ./build_pragmatic.sh /tmp/
7+
RUN echo $CONTENT
8+
RUN sh /tmp/build_pragmatic.sh ${GPU} ${CONTENT}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash
2+
3+
set -exu -o pipefail
4+
5+
export PYTHON_VERSION="python3 -m"
6+
if [ "$(python3 --version)" \< "Python 3.11" ]; then
7+
dnf install -y python3.11 python3.11-pip git
8+
export PYTHON_VERSION="/usr/bin/python3.11 -m"
9+
else
10+
dnf install -y python3-pip git
11+
fi
12+
13+
cuda="cu124"
14+
15+
rocm="rocm6.2"
16+
17+
cpu="cpu"
18+
19+
vulkan=$cpu
20+
21+
asahi=$cpu
22+
23+
install_pytorch() {
24+
version=${!1}
25+
echo ${PYTHON_VERSION} pip install torch==${version} -f https://download.pytorch.org/whl/torch_stable.html
26+
${PYTHON_VERSION} pip install torch==${version} -f https://download.pytorch.org/whl/torch_stable.html
27+
}
28+
29+
clone_and_build_pragmatic() {
30+
if [ "$2" == "docling" ]; then
31+
${PYTHON_VERSION} pip install docling --extra-index-url https://download.pytorch.org/whl/$1
32+
fi
33+
git clone https://github.com/redhat-et/PRAGmatic
34+
cd PRAGmatic
35+
git submodule update --init --recursive
36+
37+
${PYTHON_VERSION} pip install -r requirements.txt --prefix=/usr
38+
${PYTHON_VERSION} pip install --prefix=/usr .
39+
cd ..
40+
}
41+
42+
clone_and_build_pragmatic ${!1} $2
43+
rm -rf /var/cache/*dnf* /opt/rocm-*/lib/*/library/*gfx9* /root/.cache /root/buildinfo PRAGmatic
44+
dnf -y clean all
45+
ldconfig

0 commit comments

Comments
 (0)