Repository navigation
Expand file tree
/
Copy pathbuild_docker.sh
More file actions
131 lines (110 loc) · 4.21 KB
/
Copy pathbuild_docker.sh
File metadata and controls
131 lines (110 loc) · 4.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# This scripts takes a docker image that already contains the GRL dependencies, copies the local source code in and
# uploads that image into GCR. Once in GCR the docker image can be used for development.
# Each time you update the base image via a "bash docker_build_dependency_image.sh", there will be a slow upload process
# (minutes). However, if you are simply changing local code and not updating dependencies, uploading just takes a few seconds.
# Script to buid a GRL base image locally, example cmd is:
# bash build_docker.sh
set -e
INSTALL_MAXTEXT=false
INSTALL_RAIDEN=false
RAIDEN_WHEEL_DIR=/app/raiden_wheels
INSTALL_DEEPSWE_DEPS=false
SCAFFOLD="${SCAFFOLD:-r2egym}"
usage() {
cat <<'MSG'
Usage: bash build_docker.sh [--maxtext] [--raiden] [--raiden-wheel-dir PATH] [--deepswe] [--scaffold NAME]
Options:
--maxtext Install MaxText-specific dependencies.
--raiden Install Raiden-specific dependencies.
--raiden-wheel-dir PATH Use prebuilt Raiden wheels from PATH inside the Docker build context.
--deepswe Install DeepSWE evaluation dependencies.
--scaffold NAME Agent scaffold (defaults to $SCAFFOLD or r2egym; e.g. openhands installs openhands-k8s-agent-sandbox).
MSG
}
while [[ "$#" -gt 0 ]]; do
case $1 in
--maxtext) INSTALL_MAXTEXT=true; shift ;;
--raiden) INSTALL_RAIDEN=true; shift ;;
--raiden-wheel-dir)
if [[ -z "$2" ]]; then
echo "Error: --raiden-wheel-dir requires a path"
usage
exit 1
fi
RAIDEN_WHEEL_DIR="$2"
shift 2
;;
--deepswe) INSTALL_DEEPSWE_DEPS=true; shift ;;
--scaffold)
if [[ -z "${2:-}" ]]; then
echo "Error: --scaffold requires a non-empty name"
usage
exit 1
fi
SCAFFOLD="$2"
shift 2
;;
--scaffold=*)
SCAFFOLD="${1#*=}"
if [[ -z "$SCAFFOLD" ]]; then
echo "Error: --scaffold requires a non-empty name"
usage
exit 1
fi
shift
;;
--help|-h)
usage
exit 0
;;
*) echo "Unknown parameter: $1"; usage; exit 1 ;;
esac
done
DOCKERFILE=./Dockerfile
if [ ! -f "$DOCKERFILE" ]; then
echo "Error: Dockerfile not found at $DOCKERFILE"
exit 1
fi
export LOCAL_IMAGE_NAME=tunix_base_image
echo "Building base image: $LOCAL_IMAGE_NAME"
echo "Using Dockerfile: $DOCKERFILE"
# Use Docker BuildKit so we can cache pip packages.
export DOCKER_BUILDKIT=1
echo "Starting to build your docker image. This will take a few minutes but the image can be reused as you iterate."
build_ai_image() {
COMMIT_HASH=$(git rev-parse --short HEAD)
echo "Building Tunix Image at commit hash ${COMMIT_HASH}..."
DOCKER_COMMAND="docker"
if docker info >/dev/null 2>&1; then
DOCKER_COMMAND="docker"
else
# Avoid invoking sudo interactively which can prompt for a password.
# Check whether non-interactive sudo would work (no password).
if sudo -n docker info >/dev/null 2>&1; then
DOCKER_COMMAND="sudo docker"
else
cat <<'MSG'
Docker does not appear usable from this account and the build would prompt for a password.
Run the build with sufficient privileges (will prompt): sudo bash build_docker.sh
On Linux, add your user to the docker group so sudo isn't required (you must re-login):
sudo usermod -aG docker "$USER" && newgrp docker
MSG
exit 1
fi
fi
$DOCKER_COMMAND build \
--network=host \
--build-arg INSTALL_MAXTEXT=${INSTALL_MAXTEXT} \
--build-arg INSTALL_RAIDEN=${INSTALL_RAIDEN} \
--build-arg RAIDEN_WHEEL_DIR=${RAIDEN_WHEEL_DIR} \
--build-arg INSTALL_DEEPSWE_DEPS=${INSTALL_DEEPSWE_DEPS} \
--build-arg SCAFFOLD="${SCAFFOLD}" \
-t ${LOCAL_IMAGE_NAME} \
-f ${DOCKERFILE} .
}
build_ai_image
echo ""
echo "*************************
"
echo "Built your docker image and named it ${LOCAL_IMAGE_NAME}.
It now installs Tunix and the pinned vLLM and tpu-inference dependencies from requirements/requirements.txt. "