-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_docker_test.sh
More file actions
executable file
·48 lines (39 loc) · 1.09 KB
/
run_docker_test.sh
File metadata and controls
executable file
·48 lines (39 loc) · 1.09 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
#!/bin/bash
# Exit on error
set -e
# Check for Docker
if ! command -v docker &>/dev/null; then
echo "Error: Docker is not installed or not found in PATH"
exit 1
fi
# Variables
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
DOCKERFILE="$SCRIPT_DIR/Dockerfile.test"
IMAGE_NAME="dotfiles-test"
ARCH=$(uname -m)
# Set appropriate platform flag
PLATFORM_FLAG=""
case "$ARCH" in
x86_64)
PLATFORM_FLAG="--platform=linux/amd64"
;;
arm64 | aarch64)
PLATFORM_FLAG="--platform=linux/arm64"
;;
*)
echo "Warning: Unsupported architecture $ARCH, will try native build"
;;
esac
# Handle errors
handle_error() {
echo "Error: $1"
exit 1
}
# Build the Docker image
echo "Building Docker test environment for $ARCH architecture..."
docker build $PLATFORM_FLAG -t "$IMAGE_NAME" -f "$DOCKERFILE" "$SCRIPT_DIR" || handle_error "Failed to build Docker image"
echo "Dotfiles test environment is ready!"
# Run the container - the installation will be tested automatically
echo "Running installation test..."
docker run $PLATFORM_FLAG --rm "$IMAGE_NAME"
echo "Docker test completed."