-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild-image.sh
More file actions
executable file
·90 lines (77 loc) · 2.89 KB
/
build-image.sh
File metadata and controls
executable file
·90 lines (77 loc) · 2.89 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
#!/bin/bash
. /etc/bash/gaboshlib.include
g_lockfile
g_nice
g_all-to-syslog
cd /home/docker/dabo.$(hostname)
if git log --since="24 hours ago" | grep -q commit
then
git push origin main
else
g_echo_error_exit "No change in the last 24 hours. Stopping!"
fi
if [ $(find version -mmin -1430) ]
then
g_echo_error_exit "Last version younger then 24 hours"
fi
if cat ~/.docker/config.json | jq '.auths["ghcr.io"]' -e > /dev/null
then
echo "Logged in" >/dev/null
else
g_echo_warn "Please first log in with:
echo APIKEY | docker login ghcr.io -u egabosh --password-stdin"
exit 1
fi
version=$(cat version)
version=$((version+1))
docker logout
if ! docker login ghcr.io
then
g_echo_warn "You may need/create a new github/ghcr.io APIKEY!
=== GitHub PAT for ghcr.io ===
1. Go to https://github.com/settings/tokens
2. 'Generate new token (classic)'
3. Scopes: write:packages, read:packages
=== Docker Login ===
echo \"YOUR_TOKEN\" | docker login ghcr.io -u egabosh --password-stdin
"
exit 1
fi
set -e
for edition in dabo dabo-without-ai
do
date
g_echo "====== Building ghcr.io/egabosh/${edition}:0.${version}"
set -x
docker buildx ls | grep -q $edition || docker buildx create --name $edition
docker buildx use --builder $edition --default
pip_packages="ccxt tensorflow[and-cuda] pandas scikit-learn"
[[ "$edition" == "dabo-without-ai" ]] && pip_packages="ccxt"
builddate=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
description="dabo crypto trading bot ($edition)"
time docker buildx build \
-f Dockerfile \
--platform linux/amd64,linux/arm64 \
-t ghcr.io/egabosh/${edition}:0.${version} \
-t ghcr.io/egabosh/${edition}:latest \
--build-arg VERSION=0.$version \
--build-arg BUILD_DATE=$builddate \
--build-arg PIP_PACKAGES="$pip_packages" \
--build-arg DESCRIPTION="$description" \
--annotation "index,manifest:org.opencontainers.image.source=https://github.com/egabosh/dabo" \
--annotation "index,manifest:org.opencontainers.image.description=$description" \
--annotation "index,manifest:org.opencontainers.image.version=0.$version" \
--annotation "index,manifest:org.opencontainers.image.authors=Oliver Bohlen (aka olli/egabosh)" \
--annotation "index,manifest:org.opencontainers.image.licenses=GPL-3.0 (for dabo-bot in /dabo)" \
--annotation "index,manifest:org.opencontainers.image.created=$builddate" \
--annotation "index,manifest:org.opencontainers.image.vendor=egabosh" \
--annotation "index,manifest:org.opencontainers.image.documentation=https://github.com/egabosh/dabo#readme" \
--annotation "index,manifest:org.opencontainers.image.base.name=Debian Linux" \
--annotation "index,manifest:org.opencontainers.image.base.licenses=Various, see https://www.debian.org/legal/licenses/" \
--push .
set +x
done
echo $version >version
git commit -m "new image version" version
git push origin main
g_echo "====== ghcr.io/egabosh/${edition}:0.${version} released!!!"