build_docker.sh 810 Bytes
Newer Older
xuxzh1's avatar
init  
xuxzh1 committed
1
2
3
4
#!/bin/sh

set -eu

xuxzh1's avatar
update  
xuxzh1 committed
5
. $(dirname $0)/env.sh
xuxzh1's avatar
init  
xuxzh1 committed
6
7
8
9
10

# Set PUSH to a non-empty string to trigger push instead of load
PUSH=${PUSH:-""}

if [ -z "${PUSH}" ] ; then
xuxzh1's avatar
update  
xuxzh1 committed
11
    echo "Building ${FINAL_IMAGE_REPO}:$VERSION locally.  set PUSH=1 to push"
xuxzh1's avatar
init  
xuxzh1 committed
12
13
    LOAD_OR_PUSH="--load"
else
xuxzh1's avatar
update  
xuxzh1 committed
14
    echo "Will be pushing ${FINAL_IMAGE_REPO}:$VERSION"
xuxzh1's avatar
init  
xuxzh1 committed
15
16
17
    LOAD_OR_PUSH="--push"
fi

xuxzh1's avatar
update  
xuxzh1 committed
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
docker buildx build \
    ${LOAD_OR_PUSH} \
    --platform=${PLATFORM} \
    ${OLLAMA_COMMON_BUILD_ARGS} \
    -f Dockerfile \
    -t ${FINAL_IMAGE_REPO}:$VERSION \
    .

if echo $PLATFORM | grep "amd64" > /dev/null; then
    docker buildx build \
        ${LOAD_OR_PUSH} \
        --platform=linux/amd64 \
        ${OLLAMA_COMMON_BUILD_ARGS} \
        --target runtime-rocm \
        -f Dockerfile \
        -t ${FINAL_IMAGE_REPO}:$VERSION-rocm \
        .
fi