-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathdocker-run.sh
More file actions
executable file
·105 lines (87 loc) · 3.28 KB
/
docker-run.sh
File metadata and controls
executable file
·105 lines (87 loc) · 3.28 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash
# Docker Run Script for Document Translation Web Application
# This script runs the Docker container with proper configuration
set -e # Exit on any error
# Configuration
IMAGE_NAME="document-translation-web:latest"
CONTAINER_NAME="document-translation"
PORT="8080"
echo "🚀 Running Document Translation Web Application in Docker"
echo "======================================================="
# Check if Docker is available
if ! command -v docker &> /dev/null; then
echo "❌ Error: Docker is not installed or not available."
echo " Please install Docker Desktop and ensure WSL integration is enabled."
exit 1
fi
# Check if image exists
if ! docker image inspect "$IMAGE_NAME" &> /dev/null; then
echo "❌ Error: Docker image '$IMAGE_NAME' not found."
echo " Please build the image first using: ./docker-build.sh"
exit 1
fi
# Stop and remove existing container if it exists
if docker ps -a --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then
echo "🛑 Stopping existing container..."
docker stop "$CONTAINER_NAME" || true
echo "🗑️ Removing existing container..."
docker rm "$CONTAINER_NAME" || true
fi
echo "📋 Container Information:"
echo " - Image: $IMAGE_NAME"
echo " - Container Name: $CONTAINER_NAME"
echo " - Port: $PORT"
echo ""
# Run the container
echo "🐳 Starting container..."
docker run -d \
--name "$CONTAINER_NAME" \
--port "$PORT:8080" \
--restart unless-stopped \
--env ASPNETCORE_ENVIRONMENT=Production \
--env ASPNETCORE_URLS=http://+:8080 \
"$IMAGE_NAME"
if [ $? -eq 0 ]; then
echo ""
echo "✅ Container started successfully!"
echo ""
# Wait a moment for the application to start
echo "⏳ Waiting for application to start..."
sleep 5
# Check container status
if docker ps --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then
echo "✅ Container is running!"
echo ""
echo "🌐 Application URLs:"
echo " - Main Application: http://localhost:$PORT"
echo " - Health Check: http://localhost:$PORT/health"
echo " - API Documentation: http://localhost:$PORT/swagger"
echo ""
echo "📊 Container Status:"
docker ps --filter "name=$CONTAINER_NAME" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
echo ""
echo "🔧 Useful Commands:"
echo " - View logs: docker logs $CONTAINER_NAME"
echo " - Follow logs: docker logs -f $CONTAINER_NAME"
echo " - Stop container: docker stop $CONTAINER_NAME"
echo " - Access container shell: docker exec -it $CONTAINER_NAME /bin/bash"
echo ""
# Test health endpoint
echo "🩺 Testing health endpoint..."
if curl -f "http://localhost:$PORT/health" &> /dev/null; then
echo "✅ Health check passed!"
else
echo "⚠️ Health check failed or endpoint not ready yet."
echo " Try again in a few moments: curl http://localhost:$PORT/health"
fi
else
echo "❌ Container failed to start properly."
echo "📋 Container logs:"
docker logs "$CONTAINER_NAME"
exit 1
fi
else
echo ""
echo "❌ Failed to start container!"
exit 1
fi