Skip to content

Commit 7ada4ad

Browse files
authored
[image] fix manual docker image building script (ray-project#46490)
remove stuff that does not work anymore, and fixes the ray image building parts Signed-off-by: Lonnie Liu <[email protected]>
1 parent 27d3d81 commit 7ada4ad

File tree

6 files changed

+86
-145
lines changed

6 files changed

+86
-145
lines changed

build-docker.sh

Lines changed: 81 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,100 @@
11
#!/bin/bash
22
# shellcheck disable=SC2086
33
# This script is for users to build docker images locally. It is most useful for users wishing to edit the
4-
# base-deps, ray-deps, or ray images. This script is *not* tested.
5-
6-
set -x
4+
# base-deps, or ray images. This script is *not* tested.
75

86
GPU=""
97
BASE_IMAGE="ubuntu:22.04"
108
WHEEL_URL="https://s3-us-west-2.amazonaws.com/ray-wheels/latest/ray-3.0.0.dev0-cp39-cp39-manylinux2014_x86_64.whl"
11-
PYTHON_VERSION="3.9.19"
9+
CPP_WHEEL_URL="https://s3-us-west-2.amazonaws.com/ray-wheels/latest/ray_cpp-3.0.0.dev0-cp39-cp39-manylinux2014_x86_64.whl"
10+
PYTHON_VERSION="3.9"
1211

12+
BUILD_ARGS=()
1313

14-
while [[ $# -gt 0 ]]
15-
do
16-
key="$1"
17-
case $key in
18-
--gpu)
19-
GPU="-gpu"
20-
BASE_IMAGE="nvidia/cuda:11.8.0-cudnn8-devel-ubuntu22.04"
21-
;;
22-
--base-image)
23-
# Override for the base image.
24-
shift
25-
BASE_IMAGE=$1
26-
;;
27-
--no-cache-build)
28-
NO_CACHE="--no-cache"
29-
;;
30-
--build-development-image)
31-
BUILD_DEV=YES
32-
;;
33-
--build-examples)
34-
BUILD_EXAMPLES=YES
35-
;;
36-
--shas-only)
37-
# output the SHA sum of each build. This is useful for scripting tests,
38-
# especially when builds of different versions are running on the same machine.
39-
# It also can facilitate cleanup.
40-
OUTPUT_SHA=YES
41-
;;
42-
--python-version)
43-
# Python version to install. e.g. 3.9.19.
44-
# Changing python versions may require a different wheel.
45-
# If not provided defaults to 3.9.19
14+
while [[ $# -gt 0 ]]; do
15+
case "$1" in
16+
--gpu)
17+
GPU="-gpu"
18+
BASE_IMAGE="nvidia/cuda:11.8.0-cudnn8-devel-ubuntu22.04"
19+
;;
20+
--base-image)
21+
# Override for the base image.
22+
shift
23+
BASE_IMAGE="$1"
24+
;;
25+
--no-cache-build)
26+
BUILD_ARGS+=("--no-cache")
27+
;;
28+
--shas-only)
29+
# output the SHA sum of each build. This is useful for scripting tests,
30+
# especially when builds of different versions are running on the same machine.
31+
# It also can facilitate cleanup.
32+
OUTPUT_SHA=YES
33+
BUILD_ARGS+=("-q")
34+
;;
35+
--python-version)
36+
# Python version to install. e.g. 3.9
37+
# Changing python versions may require a different wheel.
38+
# If not provided defaults to 3.9
39+
shift
40+
PYTHON_VERSION="$1"
41+
;;
42+
*)
43+
echo "Usage: build-docker.sh [ --gpu ] [ --base-image ] [ --no-cache-build ] [ --shas-only ] [ --build-development-image ] [ --build-examples ] [ --python-version ]"
44+
exit 1
45+
esac
4646
shift
47-
PYTHON_VERSION=$1
48-
;;
49-
*)
50-
echo "Usage: build-docker.sh [ --gpu ] [ --base-image ] [ --no-cache-build ] [ --shas-only ] [ --build-development-image ] [ --build-examples ] [ --python-version ]"
51-
exit 1
52-
esac
53-
shift
5447
done
5548

56-
WHEEL_DIR=$(mktemp -d)
57-
wget --quiet "$WHEEL_URL" -P "$WHEEL_DIR"
58-
WHEEL="$WHEEL_DIR/$(basename "$WHEEL_DIR"/*.whl)"
59-
# Build base-deps, ray-deps, and ray.
60-
for IMAGE in "base-deps" "ray-deps" "ray"
61-
do
62-
cp "$WHEEL" "docker/$IMAGE/$(basename "$WHEEL")"
63-
if [ "$OUTPUT_SHA" ]; then
64-
IMAGE_SHA=$(docker build $NO_CACHE --build-arg GPU="$GPU" --build-arg BASE_IMAGE="$BASE_IMAGE" --build-arg WHEEL_PATH="$(basename "$WHEEL")" --build-arg PYTHON_VERSION="$PYTHON_VERSION" -q -t "rayproject/$IMAGE:nightly$GPU" "docker/$IMAGE")
65-
echo "rayproject/$IMAGE:nightly$GPU SHA:$IMAGE_SHA"
66-
else
67-
docker build $NO_CACHE --build-arg GPU="$GPU" --build-arg BASE_IMAGE="$BASE_IMAGE" --build-arg WHEEL_PATH="$(basename "$WHEEL")" --build-arg PYTHON_VERSION="$PYTHON_VERSION" -t "rayproject/$IMAGE:nightly$GPU" "docker/$IMAGE"
68-
fi
69-
rm "docker/$IMAGE/$(basename "$WHEEL")"
70-
done
49+
export DOCKER_BUILDKIT=1
50+
7151

52+
# Build base-deps image
53+
if [[ "$OUTPUT_SHA" != "YES" ]]; then
54+
echo "=== Building base-deps image ===" >/dev/stderr
55+
fi
56+
57+
BUILD_CMD=(
58+
docker build "${BUILD_ARGS[@]}"
59+
--build-arg BASE_IMAG="$BASE_IMAGE"
60+
--build-arg PYTHON_VERSION="${PYTHON_VERSION}"
61+
-t "rayproject/base-deps:dev$GPU" "docker/base-deps"
62+
)
7263

73-
# Build the current Ray source
74-
if [ $BUILD_DEV ]; then
75-
git rev-parse HEAD > ./docker/development/git-rev
76-
git archive -o ./docker/development/ray.tar "$(git rev-parse HEAD)"
77-
if [ $OUTPUT_SHA ]; then
78-
IMAGE_SHA=$(docker build $NO_CACHE -q -t rayproject/development docker/development)
79-
echo "rayproject/development:latest SHA:$IMAGE_SHA"
80-
else
81-
docker build $NO_CACHE -t rayproject/development docker/development
82-
fi
83-
rm ./docker/development/ray.tar ./docker/development/git-rev
64+
if [[ "$OUTPUT_SHA" == "YES" ]]; then
65+
IMAGE_SHA="$("${BUILD_CMD[@]}")"
66+
echo "rayproject/base-deps:dev$GPU SHA:$IMAGE_SHA"
67+
else
68+
"${BUILD_CMD[@]}"
8469
fi
8570

86-
if [ $BUILD_EXAMPLES ]; then
87-
if [ $OUTPUT_SHA ]; then
88-
IMAGE_SHA=$(docker build $NO_CACHE -q -t rayproject/examples docker/examples)
89-
echo "rayproject/examples:latest SHA:$IMAGE_SHA"
90-
else
91-
docker build $NO_CACHE -t rayproject/examples docker/examples
92-
fi
71+
72+
# Build ray image
73+
if [[ "$OUTPUT_SHA" != "YES" ]]; then
74+
echo "=== Building ray image ===" >/dev/stderr
75+
fi
76+
77+
RAY_BUILD_DIR="$(mktemp -d)"
78+
mkdir -p "$RAY_BUILD_DIR/.whl"
79+
wget --quiet "$WHEEL_URL" -P "$RAY_BUILD_DIR/.whl"
80+
wget --quiet "$CPP_WHEEL_URL" -P "$RAY_BUILD_DIR/.whl"
81+
cp python/requirements_compiled.txt "$RAY_BUILD_DIR"
82+
cp docker/ray/Dockerfile "$RAY_BUILD_DIR"
83+
84+
WHEEL="$(basename "$WHEEL_DIR"/.whl/ray-*.whl)"
85+
86+
BUILD_CMD=(
87+
docker build "${BUILD_ARGS[@]}"
88+
--build-arg FULL_BASE_IMAGE="rayproject/base-deps:dev$GPU"
89+
--build-arg WHEEL_PATH=".whl/${WHEEL}"
90+
-t "rayproject/ray:dev$GPU" "$RAY_BUILD_DIR"
91+
)
92+
93+
if [[ "$OUTPUT_SHA" == "YES" ]]; then
94+
IMAGE_SHA="$("${BUILD_CMD[@]}")"
95+
echo "rayproject/ray:dev$GPU SHA:$IMAGE_SHA"
96+
else
97+
"${BUILD_CMD[@]}"
9398
fi
9499

95100
rm -rf "$WHEEL_DIR"

doc/source/ray-overview/installation.rst

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -354,11 +354,6 @@ If you want to tweak some aspects of these images and build them locally, refer
354354
cd ray
355355
./build-docker.sh
356356
357-
Beyond creating the above Docker images, this script can also produce the following two images.
358-
359-
- The ``rayproject/development`` image has the ray source code included and is setup for development.
360-
- The ``rayproject/examples`` image adds additional libraries for running examples.
361-
362357
Review images by listing them:
363358

364359
.. code-block:: bash
@@ -370,8 +365,7 @@ Output should look something like the following:
370365
.. code-block:: bash
371366
372367
REPOSITORY TAG IMAGE ID CREATED SIZE
373-
rayproject/ray latest 7243a11ac068 2 days ago 1.11 GB
374-
rayproject/ray-deps latest b6b39d979d73 8 days ago 996 MB
368+
rayproject/ray dev 7243a11ac068 2 days ago 1.11 GB
375369
rayproject/base-deps latest 5606591eeab9 8 days ago 512 MB
376370
ubuntu 22.04 1e4467b07108 3 weeks ago 73.9 MB
377371

docker/README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,9 @@ Images without a "-cpu" or "-gpu" tag are built on ``ubuntu:22.04``. They are ju
55
```
66
ubuntu:22.04
77
└── base-deps:cpu
8-
└── ray-deps:cpu
9-
└── ray:cpu
10-
└── ray-ml:cpu
8+
└── ray:cpu
119
1210
nvidia/cuda
1311
└── base-deps:gpu
14-
└── ray-deps:gpu
15-
└── ray:gpu
16-
└── ray-ml:gpu
12+
└── ray:gpu
1713
```

docker/base-deps/README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ Please note that suffixes are only used to specify `aarch64` images. No suffix m
3737
| no tag | Defaults to `amd64` |
3838

3939

40-
## Other Images
41-
* [`rayproject/ray`](https://hub.docker.com/repository/docker/rayproject/ray) - Ray and all of its dependencies.
42-
* [`rayproject/ray-ml`](https://hub.docker.com/repository/docker/rayproject/ray-ml) - This image with common ML libraries to make development & deployment more smooth!
43-
<br></br><br></br>
40+
----
4441

45-
* [`rayproject/ray-deps`](https://hub.docker.com/repository/docker/rayproject/ray-deps) - Internal image with python-level dependencies.
42+
See [`rayproject/ray`](https://hub.docker.com/repository/docker/rayproject/ray) for Ray and all of its dependencies.

docker/development/Dockerfile

Lines changed: 0 additions & 18 deletions
This file was deleted.

docker/examples/Dockerfile

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)