-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-docker.sh
More file actions
executable file
·67 lines (54 loc) · 1.9 KB
/
build-docker.sh
File metadata and controls
executable file
·67 lines (54 loc) · 1.9 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
echo "Enter version of file monitor to use with docker (e.g. 1.0.0):"
if [ -z "$1" ]; then
read -r version
else
version="$1"
fi
echo "Building Docker image with version: $version"
if ! command -v gh &> /dev/null; then
echo "gh CLI is not installed. Please install it first and proceed with authentication."
exit 1
fi
if ! gh auth status &> /dev/null; then
echo "You are not authenticated with GitHub CLI. Please authenticate first."
exit 1
fi
gh release download v${version} --repo SentinalFS/file-monitor --clobber --pattern "monitor.bpf.o"
if [ $? -ne 0 ]; then
echo "Failed to download the file monitor binary. Please check the version and try again."
exit 1
fi
echo "Running go releaser"
if ! command -v go &> /dev/null; then
echo "Go is not installed. Please install Go and try again."
exit 1
fi
if ! command -v goreleaser &> /dev/null; then
echo "Goreleaser is not installed. Please install Goreleaser and try again."
exit 1
fi
goreleaser release --snapshot --skip=publish --clean
if docker --version &> /dev/null; then
echo "Docker is installed. Proceeding with build."
else
echo "Docker is not installed. Please install Docker and try again."
exit 1
fi
arch=$(uname -m)
if [ "$arch" = "aarch64" ] || [ "$arch" = "arm64" ]; then
echo "Detected ARM architecture. Building Docker image for ARM."
docker build -t go-logger-arm:latest -f Dockerfile.amd64 --build-arg TARGETARCH=arm64 .
if [ $? -ne 0 ]; then
echo "Docker build for ARM failed."
exit 1
fi
elif [ "$arch" = "x86_64" ]; then
echo "Detected x86_64 architecture. Building Docker image for x86_64."
docker build -t go-logger-amd64:latest -f Dockerfile.amd64 --build-arg TARGETARCH=amd64 .
if [ $? -ne 0 ]; then
echo "Docker build for x86_64 failed."
exit 1
fi
else
echo "Non-ARM architecture detected. No additional ARM build required."
fi