forked from Helicone/helicone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpush_new_docker.sh
64 lines (52 loc) · 1.44 KB
/
push_new_docker.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
#!/bin/bash
set -e
TEST_MODE=0
# Parse arguments
while getopts ":t" opt; do
case ${opt} in
t )
TEST_MODE=1
;;
\? )
echo "Invalid option: $OPTARG" 1>&2
exit 1
;;
esac
done
echo "y" | docker system prune -a
# Get the current date
DATE=$(date +%Y.%m.%d)
DATE="v$DATE"
# Docker images to build and push
declare -a docker_images=( \
"helicone/supabase-migration-runner" \
"helicone/worker-helicone-api" \
"helicone/worker-openai-proxy" \
"helicone/web" \
"helicone/clickhouse-migration-runner" \
)
run_or_echo() {
if [[ $TEST_MODE -eq 1 ]]; then
echo "$@"
else
"$@"
fi
}
for image in "${docker_images[@]}"; do
# Get the Docker tags for the current image from Docker Hub
tags=$(curl -s "https://hub.docker.com/v2/repositories/${image}/tags/?page_size=100" | jq -r '.results|.[]|.name')
# Check if the current date tag exists already
tag=$DATE
counter=1
while [[ $tags =~ $tag ]]; do
# If it does, increment the counter and append it to the date tag
tag=$DATE-$counter
((counter++))
done
# Replace dash "-" with underscore "_" in Dockerfile name
dockerfile_name=$(basename $image | tr '-' '_')
run_or_echo docker build --platform linux/amd64 -t ${image}:$tag -f dockerfiles/dockerfile_${dockerfile_name} ..
run_or_echo docker push ${image}:$tag
run_or_echo docker tag ${image}:$tag ${image}:latest
run_or_echo docker push ${image}:latest
done