build_docker.sh 810 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/sh
  2. set -eu
  3. . $(dirname $0)/env.sh
  4. # Set PUSH to a non-empty string to trigger push instead of load
  5. PUSH=${PUSH:-""}
  6. if [ -z "${PUSH}" ] ; then
  7. echo "Building ${FINAL_IMAGE_REPO}:$VERSION locally. set PUSH=1 to push"
  8. LOAD_OR_PUSH="--load"
  9. else
  10. echo "Will be pushing ${FINAL_IMAGE_REPO}:$VERSION"
  11. LOAD_OR_PUSH="--push"
  12. fi
  13. docker buildx build \
  14. ${LOAD_OR_PUSH} \
  15. --platform=${PLATFORM} \
  16. ${OLLAMA_COMMON_BUILD_ARGS} \
  17. -f Dockerfile \
  18. -t ${FINAL_IMAGE_REPO}:$VERSION \
  19. .
  20. if echo $PLATFORM | grep "amd64" > /dev/null; then
  21. docker buildx build \
  22. ${LOAD_OR_PUSH} \
  23. --platform=linux/amd64 \
  24. ${OLLAMA_COMMON_BUILD_ARGS} \
  25. --target runtime-rocm \
  26. -f Dockerfile \
  27. -t ${FINAL_IMAGE_REPO}:$VERSION-rocm \
  28. .
  29. fi