-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathvalidate-dockerfile.sh
More file actions
executable file
·66 lines (53 loc) · 1.63 KB
/
validate-dockerfile.sh
File metadata and controls
executable file
·66 lines (53 loc) · 1.63 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
#!/bin/bash
# Script to validate Dockerfile locally
# This script can be run locally to test the Dockerfile before pushing
set -e
echo "🔍 Validating Dockerfile..."
# Check if Docker is available
if ! command -v docker &> /dev/null; then
echo "❌ Docker is not installed or not in PATH"
exit 1
fi
# Check if Dockerfile exists
if [ ! -f "Dockerfile" ]; then
echo "❌ Dockerfile not found in current directory"
exit 1
fi
echo "✅ Docker is available"
echo "✅ Dockerfile found"
# Build the Docker image
echo "🏗️ Building Docker image..."
if docker build -t dockerfile-test:latest .; then
echo "✅ Docker image built successfully"
else
echo "❌ Docker build failed"
exit 1
fi
# Test basic functionality
echo "🧪 Testing Docker image..."
# Test that the image runs
if docker run --rm dockerfile-test:latest /bin/sh -c "echo 'Container started successfully'"; then
echo "✅ Container runs successfully"
else
echo "❌ Container failed to run"
exit 1
fi
# Test that required binaries are present
echo "🔍 Checking required binaries..."
if docker run --rm dockerfile-test:latest /bin/sh -c "which okteto && which jq && which ruby"; then
echo "✅ All required binaries are present"
else
echo "❌ Some required binaries are missing"
exit 1
fi
# Test that entrypoint is executable
if docker run --rm dockerfile-test:latest /bin/sh -c "test -x /entrypoint.sh"; then
echo "✅ Entrypoint is executable"
else
echo "❌ Entrypoint is not executable"
exit 1
fi
# Clean up
echo "🧹 Cleaning up..."
docker rmi dockerfile-test:latest
echo "🎉 All tests passed! Dockerfile is valid."