forked from princeton-nlp/SWE-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release_dockerhub.sh
executable file
·64 lines (52 loc) · 2.17 KB
/
release_dockerhub.sh
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
#!/usr/bin/env bash
# This script builds the official docker images and pushes them to dockerhub
# after checking with the user.
# NOTE: To clear the buildx cache, run the following command:
# docker buildx prune --all or more specifically docker buildx rm <context_name>
# bash strict mode
set -euo pipefail
# Check if exactly one argument is supplied
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <user> <version>" >&2
exit 1
fi
USER=${1}
VERSION_STR=${2}
if [[ -z "$USER" ]]; then
echo "User name cannot be empty" >&2
exit 3
fi
if [[ "$USER" != "sweagent" ]]; then
echo "Careful here! Even if the username isn't sweagent, swe-eval will still be built on top of the sweagent/swe-agent image." >&2
read -p "Do you want to proceed? (yes) " response
if [[ "${response}" != "yes" ]]; then
echo "Exiting..." >&2
exit 4
fi
fi
# The argument should be in the form of x.x.x where each x can be one or more digits
if [[ $VERSION_STR =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || [ "$VERSION_STR" = "latest" ]; then
echo "Validated version number"
else
echo "Argument must be 'latest' or in the form x.x.x, where x is one or more numbers." >&2
exit 2
fi
DOCKER_CONTEXT_NAME="sweagent-multiplatform"
docker buildx use "$DOCKER_CONTEXT_NAME" || docker buildx create --use --name "$DOCKER_CONTEXT_NAME"
on_error() {
echo "====> ERROR!!! IMPORTANT: Make sure that you've already pushed something to dockerhub or pushed the tag to github!" >&2
}
trap on_error ERR
echo "------------------------------------------"
echo "Building swe-agent"
echo "------------------------------------------"
docker buildx build --platform=linux/amd64,linux/arm64 -t ${USER}/swe-agent:${VERSION_STR} -f docker/swe.Dockerfile --push .
echo "🔥 swe-agent pushed to dockerhub"
echo "------------------------------------------"
echo "Building swe-agent-run"
echo "------------------------------------------"
docker buildx build --platform=linux/amd64,linux/arm64 -t ${USER}/swe-agent-run:${VERSION_STR} --push .
echo "🔥 swe-agent-run pushed to dockerhub"
echo "------------------------------------------"
echo "Building of all images done"
echo "------------------------------------------"