瀏覽代碼

Refine container image build script

Allow overriding the platform, image name, and tag latest for
standard and rocm images.
Daniel Hiltgen 1 年之前
父節點
當前提交
98e0b7e94f
共有 1 個文件被更改,包括 12 次插入3 次删除
  1. 12 3
      scripts/build_docker.sh

+ 12 - 3
scripts/build_docker.sh

@@ -5,13 +5,15 @@ set -eu
 export VERSION=${VERSION:-$(git describe --tags --first-parent --abbrev=7 --long --dirty --always | sed -e "s/^v//g")}
 export VERSION=${VERSION:-$(git describe --tags --first-parent --abbrev=7 --long --dirty --always | sed -e "s/^v//g")}
 export GOFLAGS="'-ldflags=-w -s \"-X=github.com/jmorganca/ollama/version.Version=$VERSION\" \"-X=github.com/jmorganca/ollama/server.mode=release\"'"
 export GOFLAGS="'-ldflags=-w -s \"-X=github.com/jmorganca/ollama/version.Version=$VERSION\" \"-X=github.com/jmorganca/ollama/server.mode=release\"'"
 
 
+IMAGE_NAME=${IMAGE_NAME:-"ollama/ollama"}
+BUILD_PLATFORM=${BUILD_PLATFORM:-"linux/arm64,linux/amd64"}
 docker build \
 docker build \
     --load \
     --load \
-    --platform=linux/arm64,linux/amd64 \
+    --platform=${BUILD_PLATFORM} \
     --build-arg=VERSION \
     --build-arg=VERSION \
     --build-arg=GOFLAGS \
     --build-arg=GOFLAGS \
     -f Dockerfile \
     -f Dockerfile \
-    -t ollama/ollama:$VERSION \
+    -t ${IMAGE_NAME}:$VERSION \
     .
     .
 
 
 docker build \
 docker build \
@@ -21,5 +23,12 @@ docker build \
     --build-arg=GOFLAGS \
     --build-arg=GOFLAGS \
     --target runtime-rocm \
     --target runtime-rocm \
     -f Dockerfile \
     -f Dockerfile \
-    -t ollama/ollama:$VERSION-rocm \
+    -t ${IMAGE_NAME}:$VERSION-rocm \
     .
     .
+
+docker tag ${IMAGE_NAME}:$VERSION ${IMAGE_NAME}:latest
+docker tag ${IMAGE_NAME}:$VERSION-rocm ${IMAGE_NAME}:rocm
+
+echo "To release, run:"
+echo "  docker push ${IMAGE_NAME}:$VERSION && docker push ${IMAGE_NAME}:latest"
+echo "  docker push ${IMAGE_NAME}:$VERSION-rocm && docker push ${IMAGE_NAME}:rocm"